Take the 2-minute tour ×  I'm working on an older application
and upgrade it's JMS system from JBoss Messaging to HornetQ, in
the process I've run into a few gotchas that seem to be related
to how this application uses and manages JMS connections. This
is my first large scale exposure to JMS (besides simple toy
usage) so I'm wondering if the current idiom is... correct,
silly, or dead wrong?  Here is how the current system works.
static QueueConnection connection; static boolean isConnected;
static void sendSomeMessage(Object sendMe) {    if(!isConnected)
connect();   static void connect() {     // jndi lookup for
connection factory     connection =
factory.createQueueConnection();      // lambdas in java pseudo
code, woot!     connection.onException => disconnect();
isConnected = true;  static void disconnect() {     isConnected
= false;  The gist of this is that the connection is used over
and over for every single message that is sent until an error
occurs, when an error occurs the connection finally