@Override
  public void onAddPartition(AddPartitionEvent partitionEvent)
    throws MetaException {
    // Subscriber can get notification of newly add partition in a
    // particular table by listening on a topic named "dbName.tableName"
    // and message selector string as "HCAT_EVENT = HCAT_ADD_PARTITION"
    if (partitionEvent.getStatus()) {
      Table table = partitionEvent.getTable();
      String topicName = getTopicName(table);
      if (topicName != null && !topicName.equals("")) {
        send(messageFactory.buildAddPartitionMessage(table, partitionEvent.getPartitionIterator()), topicName);
      } else {
        LOG.info("Topic name not found in metastore. Suppressing HCatalog notification for "
            + partitionEvent.getTable().getDbName()
            + "."
            + partitionEvent.getTable().getTableName()
            + " To enable notifications for this table, please do alter table set properties ("
            + HCatConstants.HCAT_MSGBUS_TOPIC_NAME
            + "=<dbname>.<tablename>) or whatever you want topic name to be.");
      }
    }
  }
Create message bus connection and session in constructor.
hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/NotificationListener.java