• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best practice to efficiently implement a JMS producer in a Web Application  RSS feed

 
Miguel Portugal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm planning to create a JMS producer that will send messages to my ActiveMQ queue. I'm planning to plug in this producer as a singleton in my web application. This producer of mine will most probably send out around at least 1 message per second. Since web applications are multi-threaded, I'm very particular about thread safety. According to research, it is not wise to keep on creating new Connection, Session, and MessageProducer objects since it would just be a waste... especially in my case (60 connection/session/producer objects per minute!).

As of now, my web application only has one Connection, Session, and MessageProducer. The Connection is created in another class (on startup) using an ActiveMQConnectionFactory.



What I'm thinking about is only using one Connection object, created by a PooledConnectionFactory, and creating multiple sessions and producers to fix the thread-safety problem.

What do you guys think? What's the best practice for this scenario?
 
Santhosh Muralidharan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can create single JMS connection and ensure it to call it once. If you want to avoid writing java code for JMS i suggest you to go for Spring Integration http://projects.spring.io/spring-integration/. All the JMS configuration will be in XML. No java code is required.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!