we are having some problems with publishing to a topic from an mdb under load.
Basically the mdb acts as a proxy between two JMS topics, it reads from one and publishes to another.
What happens is that TopicSession is trying to get a TopicConnection and that the getInstance of this class returs null, most probably because the application context is null.
The strange thing is that the code works fine when the mdb receives few messages, but if several messages are sent in rapid sequence, then we get the failure.
Moreover, if before trying to publish the message we explicitly access the application context (via Contexts.getApplicationContext) or perform any other delaying operation (like a simple system out with lot of text), then everything works fine even under load.
As Contexts uses ThreadLocal variables to store a reference to the various contexts, it looks like the application context variable in the new thread the MDB is using to serve the message is not
fully initialized when we get there, and if we give it a little time than everything works fine.