Hi,

I am using servicemix 3.2.2. 
I have created a queue inside it and I want my code which runs outside
servicemix to send message to that queue. This is the code that I have
written.

ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
                        Connection connection = factory.createConnection();
                        
                        javax.jms.Session session = 
connection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
                        Queue queue = session.createQueue("test");
                        MessageProducer producer = 
session.createProducer(queue);
                        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
                        connection.start();
                        TextMessage request = 
session.createTextMessage(message);
                        producer.send(request);
                        
                        
                        //javax.jms.Message m= session.createObjectMessage();
                        connection.stop();
                        connection.close();

Is this a right way to do it. The problem I see is too many times I will
open and close the connection as this code will be called too many times.
Please help me in achieving it in a better way........

Thanks,
Pratibha
-- 
View this message in context: 
http://old.nabble.com/how-to-use-Activemq-connection-pooling-outside-of-servicemix-tp28400874p28400874.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to