use of org.springframework.jms.core.JmsTemplate in project camel by apache.
the class JmsJMSReplyToEndpointUsingInOutTest method testCustomJMSReplyToInOut.
@Test
public void testCustomJMSReplyToInOut() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("My name is Arnio");
// do not use Camel to send and receive to simulate a non Camel client
// use another thread to listen and send the reply
ExecutorService executor = Executors.newFixedThreadPool(1);
executor.submit(new Callable<Object>() {
public Object call() throws Exception {
JmsTemplate jms = new JmsTemplate(amq.getConfiguration().getConnectionFactory());
final TextMessage msg = (TextMessage) jms.receive("nameRequestor");
assertEquals("What's your name", msg.getText());
// there should be a JMSReplyTo so we know where to send the reply
final Destination replyTo = msg.getJMSReplyTo();
// send reply
jms.send(replyTo, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
TextMessage replyMsg = session.createTextMessage();
replyMsg.setText("My name is Arnio");
replyMsg.setJMSCorrelationID(msg.getJMSCorrelationID());
return replyMsg;
}
});
return null;
}
});
// now get started and send the first message that gets the ball rolling
JmsTemplate jms = new JmsTemplate(amq.getConfiguration().getConnectionFactory());
jms.send("hello", new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
TextMessage msg = session.createTextMessage();
msg.setText("Hello, I'm here");
return msg;
}
});
assertMockEndpointsSatisfied();
executor.shutdownNow();
}
use of org.springframework.jms.core.JmsTemplate in project camel by apache.
the class JmsAnotherCustomJMSReplyToTest method testCustomJMSReplyToInOnly.
@Test
public void testCustomJMSReplyToInOnly() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("My name is Arnio");
// start a inOnly route
template.sendBody("activemq:queue:hello", "Hello, I'm here");
// now consume using something that is not Camel
Thread.sleep(1000);
JmsTemplate jms = new JmsTemplate(amq.getConfiguration().getConnectionFactory());
TextMessage msg = (TextMessage) jms.receive("nameRequestor");
assertEquals("What's your name", msg.getText());
// there should be a JMSReplyTo so we know where to send the reply
Destination replyTo = msg.getJMSReplyTo();
assertEquals("queue://nameReplyQueue", replyTo.toString());
// send reply
template.sendBody("activemq:" + replyTo.toString(), "My name is Arnio");
Thread.sleep(2000);
assertMockEndpointsSatisfied();
}
use of org.springframework.jms.core.JmsTemplate in project av-service by dvoraka.
the class JmsServerConfig method fileServerJmsTemplate.
@Bean
public JmsTemplate fileServerJmsTemplate(ConnectionFactory serverConnectionFactory, MessageConverter fileServerMessageConverter) {
JmsTemplate template = new JmsTemplate(serverConnectionFactory);
template.setReceiveTimeout(receiveTimeout);
template.setMessageConverter(fileServerMessageConverter);
return template;
}
use of org.springframework.jms.core.JmsTemplate in project av-service by dvoraka.
the class JmsBridgeOutputConfig method outJmsTemplate.
@Bean
public JmsTemplate outJmsTemplate(ConnectionFactory outConnectionFactory, MessageConverter outMessageConverter) {
JmsTemplate template = new JmsTemplate(outConnectionFactory);
template.setReceiveTimeout(receiveTimeout);
template.setMessageConverter(outMessageConverter);
return template;
}
use of org.springframework.jms.core.JmsTemplate in project opennms by OpenNMS.
the class JmsNorthBounderTest method startBroker.
/**
* Start broker.
*
* @throws InterruptedException the interrupted exception
*/
@Before
public void startBroker() throws InterruptedException {
MockLogAppender.setupLogging();
// this spawns an embedded broker
m_template = new JmsTemplate(m_jmsNorthbounderConnectionFactory);
m_template.setReceiveTimeout(100L);
}
Aggregations