• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS Sender class as an EJB ?

 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a class to send messages to a JBoss queue. It works well but there is a lot of overhead with each send method call (roughly 60% from what I can tell) since each time I'm doing JNDI lookups of the QueueConnectionFactory and Queue, and then establishing the QueueConnection, QueueSession, and QueueSender. I'm thinking that if I convert the class to a stateless session EJB then I could persist the QueueConnection, QueueSession, and QueueSender as instance variables and avoid this overhead with each call. My idea is to perform the lookups and initializations in my ejbCreate() method, use the QueueSender and QueueSession instance variables to do the send and commit in my send method, and then close the connection and session in my ejbRemove() method. Is this the right way to go about this ? If so then are there any further considerations for a clustered application ?

Thanks in advance for any suggestions.


--James
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done something similar, but I limited what I did in the ejbCreate to only the lookups and getting the QueueConnection. In other words, lookup the QueueConnectionFactory, lookup the Queue, call createQueueConnection on the QueueConnectionFactory. That eliminates the majority of the speed issues.

The main reason I didn't keep the session around was because I was concerned that keeping a session open for a long period of time could cause problems. I really don't know if that is true or not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!