|
|
@@ -1,7 +1,5 @@
|
|
1
|
1
|
package se.citerus.dddsample.infrastructure.messaging.jms;
|
|
2
|
2
|
|
|
3
|
|
-import org.apache.commons.logging.Log;
|
|
4
|
|
-import org.apache.commons.logging.LogFactory;
|
|
5
|
3
|
import org.springframework.jms.core.JmsOperations;
|
|
6
|
4
|
import org.springframework.jms.core.MessageCreator;
|
|
7
|
5
|
import se.citerus.dddsample.application.ApplicationEvents;
|
|
|
@@ -19,50 +17,24 @@ import javax.jms.Session;
|
|
19
|
17
|
public final class JmsApplicationEventsImpl implements ApplicationEvents {
|
|
20
|
18
|
|
|
21
|
19
|
private JmsOperations jmsOperations;
|
|
22
|
|
- private Destination cargoHandledQueue;
|
|
23
|
|
- private Destination misdirectedCargoQueue;
|
|
24
|
|
- private Destination deliveredCargoQueue;
|
|
25
|
|
- private Destination cargoDeliveryUpdateQueue;
|
|
26
|
|
-
|
|
27
|
|
- private static final Log logger = LogFactory.getLog(JmsApplicationEventsImpl.class);
|
|
|
20
|
+ private Destination cargoHandledDestination;
|
|
|
21
|
+ private Destination cargoDeliveryUpdateDestination;
|
|
28
|
22
|
|
|
29
|
23
|
@Override
|
|
30
|
24
|
public void cargoWasHandled(final HandlingEvent event) {
|
|
31
|
25
|
final Cargo cargo = event.cargo();
|
|
32
|
|
- logger.info("Cargo was handled " + cargo);
|
|
33
|
|
- jmsOperations.send(cargoHandledQueue, new MessageCreator() {
|
|
|
26
|
+ jmsOperations.send(cargoHandledDestination, new MessageCreator() {
|
|
34
|
27
|
public Message createMessage(final Session session) throws JMSException {
|
|
35
|
|
- return session.createTextMessage(cargo.trackingId().stringValue());
|
|
|
28
|
+ return session.createObjectMessage(cargo.trackingId());
|
|
36
|
29
|
}
|
|
37
|
30
|
});
|
|
38
|
31
|
}
|
|
39
|
32
|
|
|
40
|
33
|
@Override
|
|
41
|
34
|
public void cargoDeliveryWasUpdated(final Cargo cargo) {
|
|
42
|
|
- logger.info("Cargo delivery was updated: " + cargo);
|
|
43
|
|
- jmsOperations.send(cargoDeliveryUpdateQueue, new MessageCreator() {
|
|
44
|
|
- public Message createMessage(Session session) throws JMSException {
|
|
45
|
|
- return session.createTextMessage(cargo.trackingId().stringValue());
|
|
46
|
|
- }
|
|
47
|
|
- });
|
|
48
|
|
- }
|
|
49
|
|
-
|
|
50
|
|
- @Override
|
|
51
|
|
- public void cargoWasMisdirected(final Cargo cargo) {
|
|
52
|
|
- logger.info("Cargo was misdirected " + cargo);
|
|
53
|
|
- jmsOperations.send(misdirectedCargoQueue, new MessageCreator() {
|
|
54
|
|
- public Message createMessage(Session session) throws JMSException {
|
|
55
|
|
- return session.createTextMessage(cargo.trackingId().stringValue());
|
|
56
|
|
- }
|
|
57
|
|
- });
|
|
58
|
|
- }
|
|
59
|
|
-
|
|
60
|
|
- @Override
|
|
61
|
|
- public void cargoHasArrived(final Cargo cargo) {
|
|
62
|
|
- logger.info("Cargo has arrived " + cargo);
|
|
63
|
|
- jmsOperations.send(deliveredCargoQueue, new MessageCreator() {
|
|
|
35
|
+ jmsOperations.send(cargoDeliveryUpdateDestination, new MessageCreator() {
|
|
64
|
36
|
public Message createMessage(Session session) throws JMSException {
|
|
65
|
|
- return session.createTextMessage(cargo.trackingId().stringValue());
|
|
|
37
|
+ return session.createObjectMessage(cargo.trackingId());
|
|
66
|
38
|
}
|
|
67
|
39
|
});
|
|
68
|
40
|
}
|
|
|
@@ -71,19 +43,12 @@ public final class JmsApplicationEventsImpl implements ApplicationEvents {
|
|
71
|
43
|
this.jmsOperations = jmsOperations;
|
|
72
|
44
|
}
|
|
73
|
45
|
|
|
74
|
|
- public void setCargoHandledQueue(Destination destination) {
|
|
75
|
|
- this.cargoHandledQueue = destination;
|
|
76
|
|
- }
|
|
77
|
|
-
|
|
78
|
|
- public void setMisdirectedCargoQueue(Destination destination) {
|
|
79
|
|
- this.misdirectedCargoQueue = destination;
|
|
|
46
|
+ public void setCargoHandledDestination(Destination cargoHandledDestination) {
|
|
|
47
|
+ this.cargoHandledDestination = cargoHandledDestination;
|
|
80
|
48
|
}
|
|
81
|
49
|
|
|
82
|
|
- public void setDeliveredCargoQueue(Destination destination) {
|
|
83
|
|
- this.deliveredCargoQueue = destination;
|
|
|
50
|
+ public void setCargoDeliveryUpdateDestination(Destination cargoDeliveryUpdateDestination) {
|
|
|
51
|
+ this.cargoDeliveryUpdateDestination = cargoDeliveryUpdateDestination;
|
|
84
|
52
|
}
|
|
85
|
53
|
|
|
86
|
|
- public void setCargoDeliveryUpdateQueue(Destination cargoDeliveryUpdateQueue) {
|
|
87
|
|
- this.cargoDeliveryUpdateQueue = cargoDeliveryUpdateQueue;
|
|
88
|
|
- }
|
|
89
|
54
|
}
|