Example usage for javax.jms Connection getClientID

List of usage examples for javax.jms Connection getClientID

Introduction

In this page you can find the example usage for javax.jms Connection getClientID.

Prototype

String getClientID() throws JMSException;

Source Link

Document

Gets the client identifier for this connection.

Usage

From source file:org.carewebframework.jms.JMSUtil.java

/**
 * Returns the client id from the connection.
 * //from   w ww  .  j  a v a  2 s.c o  m
 * @param connection JMS connection (may be null).
 * @return The client id (may be null).
 */
public static String getClientId(Connection connection) {
    String clientId = null;

    try {
        clientId = connection == null ? null : connection.getClientID();
    } catch (JMSException e) {
    }

    return clientId;
}

From source file:com.fusesource.forge.jmstest.executor.BenchmarkConsumer.java

@Override
public Connection getConnection() throws Exception {
    Connection connection = super.getConnection();
    assert connection != null;

    // should have this usually, but definitely for durable subscriber
    if (connection.getClientID() == null || connection.getClientID().isEmpty()) {
        log().info("Setting client ID!! yip yip");
        connection.setClientID(getClientId());
    }//from  w w  w .  ja  v  a  2  s . com
    return connection;
}

From source file:org.sakaiproject.kernel.messaging.email.EmailMessagingService.java

private void startConnections() {
    for (Connection conn : connections) {
        try {//from   w  w  w  .ja va  2s  .  c  o  m
            conn.start();
        } catch (JMSException e) {
            try {
                LOG.error("Fail to start connection: " + conn.getClientID());
            } catch (JMSException e1) {
                // TMI
            }
            e.printStackTrace();
        }
    }

}

From source file:org.sakaiproject.kernel.messaging.email.EmailMessagingService.java

private void createSessions() {
    int sessionsPerConnection = 1;
    Session sess = null;//from w ww.j av a  2s  . c o  m
    for (Connection conn : connections) {
        for (int i = 0; i < sessionsPerConnection; ++i) {
            sess = null;
            try {
                sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
                sessions.put(conn.getClientID(), sess);
            } catch (JMSException e) {
                try {
                    LOG.error("Fail to create connection[" + i + "]: " + conn.getClientID());
                } catch (JMSException e1) {
                    // TMI
                }
                e.printStackTrace();
            }
        }
    }

}