1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.jbi.component;
9
10 import it.imolinfo.jbi4ejb.Logger;
11 import it.imolinfo.jbi4ejb.LoggerFactory;
12 import it.imolinfo.jbi4ejb.jbi.Messages;
13 import it.imolinfo.jbi4ejb.jbi.component.runtime.AbstractMessageExchangeHandler;
14 import it.imolinfo.jbi4ejb.jbi.component.runtime.RuntimeHelper;
15 import it.imolinfo.jbi4ejb.jbi.endpoint.Jbi4EjbEndpoint;
16 import it.imolinfo.jbi4ejb.processor.ExchangeProcessor;
17
18 import javax.jbi.messaging.Fault;
19 import javax.jbi.messaging.InOut;
20 import javax.jbi.messaging.MessageExchange;
21 import javax.jbi.messaging.MessagingException;
22
23
24
25
26
27
28 public class Jbi4EjbMessageExchangeHandler extends AbstractMessageExchangeHandler {
29
30
31 public static final long SEND_SYNC_TIMEOUT = 60000;
32
33
34 private static final Logger LOG =
35 LoggerFactory.getLogger(Jbi4EjbMessageExchangeHandler.class);
36 private static final Messages MESSAGES =
37 Messages.getMessages(Jbi4EjbMessageExchangeHandler.class);
38
39
40 private Jbi4EjbSUManager suManager = null;
41
42
43
44
45
46
47
48 public Jbi4EjbMessageExchangeHandler(Jbi4EjbSUManager suManager) {
49 super();
50 this.suManager = suManager;
51 }
52
53
54
55
56 protected final void processMessage() {
57
58 InOut inOutMX = (InOut) this.getMessageExchange();
59
60 Jbi4EjbEndpoint ejbEndpoint =
61 suManager.getStartedEndpoint(inOutMX.getEndpoint());
62
63 LOG.info("EJB000102_Received_message_invocation_for_endpoint",
64 new Object[]{ejbEndpoint.getEndpointName()});
65 ExchangeProcessor processor = ejbEndpoint.getExchangeProcessor();
66
67
68 processor.process(inOutMX);
69 }
70
71
72
73
74
75
76
77 protected void validateMessageExchange() throws MessagingException {
78
79 MessageExchange msgExchange = this.getMessageExchange();
80
81 if ( this.getMessageExchange() == null ) {
82 String msg=
83 MESSAGES.getString("EJB000103_MessageExchange_Object_null_in_MessageExchageHandler");
84 LOG.error(msg);
85 throw new MessagingException(msg);
86 }
87
88 if ( MessageExchange.Role.CONSUMER.equals(msgExchange.getRole()) ) {
89 String msg=
90 MESSAGES.getString("EJB000104_Provider_Message_Exchange_Handler_can_not_have_MessageExchange_with_ONSUMER_Role");
91 LOG.error(msg);
92 throw new MessagingException(msg);
93 }
94 if (!(msgExchange instanceof InOut) ) {
95 String msg=
96 MESSAGES.getString("EJB000105_InOut_Message_Exchange_Handler_MessageExchange_object_should_be_instance_of_javax.jbi.messaging.InOut");
97 LOG.error(msg);
98 throw new MessagingException(msg);
99 }
100 }
101
102
103
104
105
106
107
108 protected void processFault(Fault fault) {
109 LOG.error("EJB000106_InOut_Message_Exchange_Provider_received_FAULT");
110 }
111
112
113
114
115 protected void processDone() {
116 RuntimeHelper.logVerbose("InOut Message Exchange Provider handler received DONE : END of service invocation");
117 }
118
119
120
121
122
123
124
125 protected void processError(Exception ex) {
126 LOG.error("EJB000107_InOut_Message_Exchange_Provider_received_error");
127 LOG.error("EJB000108_Error_during_Process", ex);
128 }
129
130 }