protected void send(HCatEventMessage hCatEventMessage, String topicName, int retries) {
    try {
      if (session.get() == null) {
        // Need to reconnect
        throw new JMSException("Invalid JMS session");
      }
      Destination topic = createTopic(topicName);
      Message msg = session.get().createTextMessage(hCatEventMessage.toString());

      msg.setStringProperty(HCatConstants.HCAT_EVENT, hCatEventMessage.getEventType().toString());
      msg.setStringProperty(HCatConstants.HCAT_MESSAGE_VERSION, messageFactory.getVersion());
      msg.setStringProperty(HCatConstants.HCAT_MESSAGE_FORMAT, messageFactory.getMessageFormat());
      MessageProducer producer = createProducer(topic);
      producer.send(msg);
      // Message must be transacted before we return.
      session.get().commit();
    } catch (Exception e) {
      if (retries >= 0) {
        // this may happen if we were able to establish connection once, but its no longer valid
        LOG.error("Seems like connection is lost. Will retry. Retries left : " + retries + ". error was:", e);
        testAndCreateConnection();
        send(hCatEventMessage, topicName, retries - 1);
      } else {
        // Gobble up the exception. Message delivery is best effort.
        LOG.error("Failed to send message on topic: " + topicName +
          " event: " + hCatEventMessage.getEventType() + " after retries: " + NUM_RETRIES, e);
      }
    }
  }
@param hCatEventMessage The HCatEventMessage being sent over JMS, this method is threadsafe
@param topicName is the name on message broker on which message is sent.
@param retries the number of retry attempts
hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/NotificationListener.java