m.setConnectionID(connectionID);
jbm.setConnectionID(connectionID);
   protected void sendMessage(JBossMessage m, Transaction tx) throws JMSException   {      // The JMSDestination header must already have been set for each message      JBossDestination jbDest = (JBossDestination)m.getJMSDestination();      if (jbDest == null)      {         throw new IllegalStateException("JMSDestination header not set!");      }      CoreDestination coreDestination = channelMapper.getCoreDestination(jbDest);            if (coreDestination == null)      {         throw new JMSException("Destination " + jbDest.getName() + " does not exist");      }            // This allows the no-local consumers to filter out the messages that come from the same      //  connection      // TODO Do we want to set this for ALL messages. Optimisation is possible here.      m.setConnectionID(connectionID);            Routable r = (Routable)m;          if (trace) { log.trace("sending " + m + (tx == null ? " non-transactionally" : " transactionally on " + tx + " to the core destination " + jbDest.getName())); }            //If we are sending to a topic, then we *always* do the send in the context of a transaction,      //in order to ensure that the message is delivered to all durable subscriptions (if any)      //attached to the topic. Otherwise if the server crashed in mid send, we may end up with the      //message in some, but not all of the durable subscriptions, which would be in      //contravention of the spec.      //When there are many durable subs for the topic, this actually should give us a performance gain      //since all the inserts can be done in the same JDBC tx too.            boolean internalTx = false;      if (r.isReliable() && tx == null && !coreDestination.isQueue())      {         try         {            tx = tr.createTransaction();         }         catch (Exception e)         {            throw new JBossJMSException("Failed to create internal transaction", e);         }         internalTx = true;      }            try      {                  Delivery d = coreDestination.handle(null, r, tx);                  if (internalTx)         {            tx.commit();         }                  // The core destination is supposed to acknowledge immediately. If not, there's a problem.         if (d == null || !d.isDone())         {            String msg = "The message was not acknowledged by destination " + coreDestination;            log.error(msg);            throw new JBossJMSException(msg);         }      }      catch (Throwable t)      {         if (internalTx)         {            try            {                              tx.rollback();            }            catch (Exception e)            {               log.error("Failed to rollback internal transaction", e);            }         }         throw new JBossJMSException("Failed to send message", t);      }   }