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.
You should store the QCFactory locally in ejbCreate(). Also, use the java:/JmsXA factory, as it is pooling.
Don't create the connection, session in the ejbCreate(), do it when you need to. Otherwise, JBoss can't enlist the JMS session in the transaction.
For clusters, I'm not sure on the details however.