Suppose I have a message driven bean (MDB) in a Java application server. The MDB receives a message from a JMS queue and passes it to a message processor. In my case, a message processor is an extremely heavy weight object that requires extensive initialization so I don't want to create a new one to handle each message. Instead I would like to create a pool of message processors ahead of time and use them to handle messages.
So, my question is: what is the 'correct' way to build this pool in a J2EE app server? Do any servers have built-in support for defining custom (non-connection) object pools? I would like to leverage whatever built-in support there is for this pattern before I just cram the pool into a singleton and hope for the best. In particular:
- How do I define/instantiate the pool?
- How do I access the pool? JNDI?
- What management capabilities are provided by the app server?
I know how to implement an object pool in general. My question is mostly about creating a pool in a J2EE app server.
I'm planning on using Glassfish, but I"m flexible if JBoss or something else will make this easier.
Thanks!