-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
HandlingEventRegistrationAttemptConsumer.java
43 lines (37 loc) · 1.44 KB
/
HandlingEventRegistrationAttemptConsumer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package se.citerus.dddsample.infrastructure.messaging.jms;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.citerus.dddsample.application.HandlingEventService;
import se.citerus.dddsample.interfaces.handling.HandlingEventRegistrationAttempt;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import java.lang.invoke.MethodHandles;
/**
* Consumes handling event registration attempt messages and delegates to
* proper registration.
*
*/
public class HandlingEventRegistrationAttemptConsumer implements MessageListener {
private final HandlingEventService handlingEventService;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public HandlingEventRegistrationAttemptConsumer(HandlingEventService handlingEventService) {
this.handlingEventService = handlingEventService;
}
@Override
public void onMessage(final Message message) {
try {
final ObjectMessage om = (ObjectMessage) message;
HandlingEventRegistrationAttempt attempt = (HandlingEventRegistrationAttempt) om.getObject();
handlingEventService.registerHandlingEvent(
attempt.getCompletionTime(),
attempt.getTrackingId(),
attempt.getVoyageNumber(),
attempt.getUnLocode(),
attempt.getType()
);
} catch (Exception e) {
logger.error("Error consuming HandlingEventRegistrationAttempt message", e);
}
}
}