|
|
@@ -7,7 +7,6 @@ import org.springframework.jms.core.MessageCreator;
|
|
7
|
7
|
import se.citerus.dddsample.application.ApplicationEvents;
|
|
8
|
8
|
import se.citerus.dddsample.domain.model.cargo.Cargo;
|
|
9
|
9
|
import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
10
|
|
-import se.citerus.dddsample.interfaces.handling.HandlingEventRegistrationAttempt;
|
|
11
|
10
|
|
|
12
|
11
|
import javax.jms.Destination;
|
|
13
|
12
|
import javax.jms.JMSException;
|
|
|
@@ -23,8 +22,7 @@ public final class JmsApplicationEventsImpl implements ApplicationEvents {
|
|
23
|
22
|
private Destination cargoHandledQueue;
|
|
24
|
23
|
private Destination misdirectedCargoQueue;
|
|
25
|
24
|
private Destination deliveredCargoQueue;
|
|
26
|
|
- private Destination rejectedRegistrationAttemptsQueue;
|
|
27
|
|
- private Destination handlingEventQueue;
|
|
|
25
|
+ private Destination cargoDeliveryUpdateQueue;
|
|
28
|
26
|
|
|
29
|
27
|
private static final Log logger = LogFactory.getLog(JmsApplicationEventsImpl.class);
|
|
30
|
28
|
|
|
|
@@ -34,37 +32,37 @@ public final class JmsApplicationEventsImpl implements ApplicationEvents {
|
|
34
|
32
|
logger.info("Cargo was handled " + cargo);
|
|
35
|
33
|
jmsOperations.send(cargoHandledQueue, new MessageCreator() {
|
|
36
|
34
|
public Message createMessage(final Session session) throws JMSException {
|
|
37
|
|
- return session.createTextMessage(cargo.trackingId().idString());
|
|
|
35
|
+ return session.createTextMessage(cargo.trackingId().stringValue());
|
|
38
|
36
|
}
|
|
39
|
37
|
});
|
|
40
|
38
|
}
|
|
41
|
39
|
|
|
42
|
40
|
@Override
|
|
43
|
|
- public void cargoWasMisdirected(final Cargo cargo) {
|
|
44
|
|
- logger.info("Cargo was misdirected " + cargo);
|
|
45
|
|
- jmsOperations.send(misdirectedCargoQueue, new MessageCreator() {
|
|
|
41
|
+ public void cargoDeliveryWasUpdated(final Cargo cargo) {
|
|
|
42
|
+ logger.info("Cargo delivery was updated: " + cargo);
|
|
|
43
|
+ jmsOperations.send(cargoDeliveryUpdateQueue, new MessageCreator() {
|
|
46
|
44
|
public Message createMessage(Session session) throws JMSException {
|
|
47
|
|
- return session.createTextMessage(cargo.trackingId().idString());
|
|
|
45
|
+ return session.createTextMessage(cargo.trackingId().stringValue());
|
|
48
|
46
|
}
|
|
49
|
47
|
});
|
|
50
|
48
|
}
|
|
51
|
49
|
|
|
52
|
50
|
@Override
|
|
53
|
|
- public void cargoHasArrived(final Cargo cargo) {
|
|
54
|
|
- logger.info("Cargo has arrived " + cargo);
|
|
55
|
|
- jmsOperations.send(deliveredCargoQueue, new MessageCreator() {
|
|
|
51
|
+ public void cargoWasMisdirected(final Cargo cargo) {
|
|
|
52
|
+ logger.info("Cargo was misdirected " + cargo);
|
|
|
53
|
+ jmsOperations.send(misdirectedCargoQueue, new MessageCreator() {
|
|
56
|
54
|
public Message createMessage(Session session) throws JMSException {
|
|
57
|
|
- return session.createTextMessage(cargo.trackingId().idString());
|
|
|
55
|
+ return session.createTextMessage(cargo.trackingId().stringValue());
|
|
58
|
56
|
}
|
|
59
|
57
|
});
|
|
60
|
58
|
}
|
|
61
|
59
|
|
|
62
|
60
|
@Override
|
|
63
|
|
- public void receivedHandlingEventRegistrationAttempt(final HandlingEventRegistrationAttempt attempt) {
|
|
64
|
|
- logger.info("Received handling event registration attempt " + attempt);
|
|
65
|
|
- jmsOperations.send(handlingEventQueue, new MessageCreator() {
|
|
|
61
|
+ public void cargoHasArrived(final Cargo cargo) {
|
|
|
62
|
+ logger.info("Cargo has arrived " + cargo);
|
|
|
63
|
+ jmsOperations.send(deliveredCargoQueue, new MessageCreator() {
|
|
66
|
64
|
public Message createMessage(Session session) throws JMSException {
|
|
67
|
|
- return session.createObjectMessage(attempt);
|
|
|
65
|
+ return session.createTextMessage(cargo.trackingId().stringValue());
|
|
68
|
66
|
}
|
|
69
|
67
|
});
|
|
70
|
68
|
}
|
|
|
@@ -85,11 +83,7 @@ public final class JmsApplicationEventsImpl implements ApplicationEvents {
|
|
85
|
83
|
this.deliveredCargoQueue = destination;
|
|
86
|
84
|
}
|
|
87
|
85
|
|
|
88
|
|
- public void setRejectedRegistrationAttemptsQueue(Destination destination) {
|
|
89
|
|
- this.rejectedRegistrationAttemptsQueue = destination;
|
|
90
|
|
- }
|
|
91
|
|
-
|
|
92
|
|
- public void setHandlingEventQueue(Destination destination) {
|
|
93
|
|
- this.handlingEventQueue = destination;
|
|
|
86
|
+ public void setCargoDeliveryUpdateQueue(Destination cargoDeliveryUpdateQueue) {
|
|
|
87
|
+ this.cargoDeliveryUpdateQueue = cargoDeliveryUpdateQueue;
|
|
94
|
88
|
}
|
|
95
|
89
|
}
|