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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* Created on Feb 16, 2010
*
* PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
*/
package org.eclipse.osee.framework.messaging.internal.activemq;
import java.util.logging.Level;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeWrappedException;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback;
import org.eclipse.osee.framework.messaging.ReplyConnection;
import org.eclipse.osee.framework.messaging.internal.Activator;
/**
* @author Andrew M. Finkbeiner
*
*/
class ReplyConnectionActiveMqImpl implements ReplyConnection {
private final boolean isReplyRequested;
private MessageProducer producer;
private Destination destReply;
private String correlationId;
private Session session;
private ActiveMqUtil activeMqUtil;
ReplyConnectionActiveMqImpl(ActiveMqUtil activeMqUtil, Session session, MessageProducer producer, Destination destReply, String correlationId) {
isReplyRequested = true;
this.producer = producer;
this.destReply = destReply;
this.correlationId = correlationId;
this.session = session;
this.activeMqUtil = activeMqUtil;
}
ReplyConnectionActiveMqImpl() {
isReplyRequested = false;
}
@Override
public boolean isReplyRequested() {
return isReplyRequested;
}
@Override
public void send(Object body, Class<?> clazz, OseeMessagingStatusCallback statusCallback) throws OseeCoreException {
try {
Message message = activeMqUtil.createMessage(session, clazz, body);
message.setJMSCorrelationID(correlationId);
producer.send(destReply, message);
OseeLog.log(Activator.class, Level.INFO, String.format("Sending Reply Message %s", message.toString()));
} catch (JMSException ex) {
statusCallback.fail(ex);
throw new OseeWrappedException(ex);
}
}
}
|