use of javax.jms.TopicRequestor in project activemq-artemis by apache.
the class TopicBridgeSpringTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
context = createApplicationContext();
ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory");
localConnection = fac.createTopicConnection();
localConnection.start();
requestServerSession = localConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic theTopic = requestServerSession.createTopic(getClass().getName());
requestServerConsumer = requestServerSession.createConsumer(theTopic);
requestServerConsumer.setMessageListener(this);
requestServerProducer = requestServerSession.createProducer(null);
fac = (ActiveMQConnectionFactory) context.getBean("remoteFactory");
remoteConnection = fac.createTopicConnection();
remoteConnection.start();
TopicSession session = remoteConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
requestor = new TopicRequestor(session, theTopic);
}
use of javax.jms.TopicRequestor in project activemq-artemis by apache.
the class SimpleNetworkTest method testRequestReply.
@Test(timeout = 60 * 1000)
public void testRequestReply() throws Exception {
final MessageProducer remoteProducer = remoteSession.createProducer(null);
MessageConsumer remoteConsumer = remoteSession.createConsumer(included);
remoteConsumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message msg) {
try {
TextMessage textMsg = (TextMessage) msg;
String payload = "REPLY: " + textMsg.getText();
Destination replyTo;
replyTo = msg.getJMSReplyTo();
textMsg.clearBody();
textMsg.setText(payload);
remoteProducer.send(replyTo, textMsg);
} catch (JMSException e) {
e.printStackTrace();
}
}
});
TopicRequestor requestor = new TopicRequestor((TopicSession) localSession, included);
// allow for consumer infos to perculate around
Thread.sleep(5000);
for (int i = 0; i < MESSAGE_COUNT; i++) {
TextMessage msg = localSession.createTextMessage("test msg: " + i);
TextMessage result = (TextMessage) requestor.request(msg);
assertNotNull(result);
LOG.info(result.getText());
}
}
use of javax.jms.TopicRequestor in project activemq by apache.
the class SimpleNetworkTest method testRequestReply.
@Test(timeout = 60 * 1000)
public void testRequestReply() throws Exception {
final MessageProducer remoteProducer = remoteSession.createProducer(null);
MessageConsumer remoteConsumer = remoteSession.createConsumer(included);
remoteConsumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message msg) {
try {
TextMessage textMsg = (TextMessage) msg;
String payload = "REPLY: " + textMsg.getText();
Destination replyTo;
replyTo = msg.getJMSReplyTo();
textMsg.clearBody();
textMsg.setText(payload);
remoteProducer.send(replyTo, textMsg);
} catch (JMSException e) {
e.printStackTrace();
}
}
});
TopicRequestor requestor = new TopicRequestor((TopicSession) localSession, included);
// allow for consumer infos to perculate arround
Thread.sleep(5000);
for (int i = 0; i < MESSAGE_COUNT; i++) {
TextMessage msg = localSession.createTextMessage("test msg: " + i);
TextMessage result = (TextMessage) requestor.request(msg);
assertNotNull(result);
LOG.info(result.getText());
}
assertNetworkBridgeStatistics(MESSAGE_COUNT, MESSAGE_COUNT);
}
use of javax.jms.TopicRequestor in project activemq by apache.
the class TopicBridgeSpringTest method setUp.
protected void setUp() throws Exception {
super.setUp();
context = createApplicationContext();
ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory");
localConnection = fac.createTopicConnection();
localConnection.start();
requestServerSession = localConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic theTopic = requestServerSession.createTopic(getClass().getName());
requestServerConsumer = requestServerSession.createConsumer(theTopic);
requestServerConsumer.setMessageListener(this);
requestServerProducer = requestServerSession.createProducer(null);
fac = (ActiveMQConnectionFactory) context.getBean("remoteFactory");
remoteConnection = fac.createTopicConnection();
remoteConnection.start();
TopicSession session = remoteConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
requestor = new TopicRequestor(session, theTopic);
}
Aggregations