This content has been marked as final. Show 1 reply
Basically, the answer is yes: a WebLogic app server will 'secretly' pool JMS resources. That said, it's a good idea for apps to cache CF and dest references as it is expensive to repeatedly look them up in JNDI - regardless of whether the JNDI context is local or remote. (It is a common practice to use remote contexts, the links below detail best practices for wiring them into WebLogic.) I think it's also a good idea to refresh CF and dest references on an error. Also, in your sample code, there's no need to call "connection.start()" - as it has no effect on message production.
Here's the related WebLogic documentation:
Enhanced Support for Using WebLogic JMS with EJBs and Servlets
There's a nice EJB 3.0 sample at the very end of this chapter. I recommend doing two things slightly differently than the sample: (1) Do not rethrow the exception to cause redelivery as this expensively forces the bean to be destroyed and recreated, instead force a transaction rollback using the EJB context - that said, rethrowing is unavoidable with non-transactional MDBs as there's no equivalent to a rollback request in the non-transactional case, and (2) Set targetDest and targetCF to null in the exception handler to force them to be refreshed on an error.
Integrating Remote JMS Providers
Programming Message-Driven Beans