JMSEndpoint endpoint = new JMSEndpoint();
endpoint.setJndiInitialContextFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
endpoint.setJndiURL(broker.getBrokerURL());
endpoint.setJndiConnectionFactoryName("ConnectionFactory");
final JMSConfiguration jmsConfig = new JMSConfiguration();
JndiTemplate jt = new JndiTemplate();
jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(endpoint));
JNDIConfiguration jndiConfig = new JNDIConfiguration();
jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
jmsConfig.setJndiTemplate(jt);
jmsConfig.setJndiConfig(jndiConfig);
jmsConfig.setTargetDestination("dynamicQueues/SoapService7.replyto.queue");
jmsConfig.setReplyDestination("dynamicQueues/SoapService7.reply.queue");
final JmsTemplate jmsTemplate = JMSFactory.createJmsTemplate(jmsConfig, null);
Thread t = new Thread() {
public void run() {
@SuppressWarnings("unchecked")
Destination destination = (Destination)jmsTemplate.execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
DestinationResolver resolv = jmsTemplate.getDestinationResolver();
return resolv.resolveDestinationName(session, jmsConfig.getTargetDestination(),
false);
}
});
final Message message = jmsTemplate.receive(destination);
MessageCreator messageCreator = new MessageCreator() {
public Message createMessage(Session session) {
return message;
}
};
@SuppressWarnings("unchecked")
Destination destination2 = (Destination)jmsTemplate.execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
DestinationResolver resolv = jmsTemplate.getDestinationResolver();
return resolv.resolveDestinationName(session,
jmsConfig.getReplyDestination(),
false);
}
});
jmsTemplate.send(destination2, messageCreator);
}