code: public static String getClientId(Connection connection) {
          String clientId = null;
          
          try {
              clientId = connection == null ? null : connection.getClientID();
          } catch (JMSException e) {}
          
          return clientId;
      }
docs: Returns the client id from the connection.
  
  @param connection JMS connection (may be null).
  @return The client id (may be null).