Showing posts with label jms. Show all posts
Showing posts with label jms. Show all posts

June 25, 2012

JMS Configuration in Spring's ApplicationContext


Recently I faced some issue to configure JMS queue in Spring's application context. This queue is exposed on Sonic ESB and I have to connect to it using Apache Camel. First I wrote 
a JMS Producer class which puts message on client's sonic JMS queue. It was something like this:
Hashtable properties = new Hashtable();

properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.test.factory");
properties.put("com.domain", "DevelopmentDomain");
properties.put(Context.PROVIDER_URL, "tcp://10.00.0.00:0506");
properties.put(Context.SECURITY_PRINCIPAL, "aaa");
properties.put(Context.SECURITY_CREDENTIALS, "aaa");

javax.naming.Context context = new javax.naming.InitialContext(properties);
ConnectionFactory factory = (ConnectionFactory) context.lookup("ImpactPocQueueConnectionFactory");

Connection connection = factory.createConnection();

connection.start();

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

Destination queue = session.createQueue("test.producer");
Now above JMS queue setup in applicationContext xml using Camel route.Here I am routing message to sonic queue through a seda queue.

     
          
             com.test.factory
             DevelopmentDomain
             tcp://10.00.0.00:0506
             aaa
             aaa