Example usage for javax.jms TemporaryTopic toString

List of usage examples for javax.jms TemporaryTopic toString

Introduction

In this page you can find the example usage for javax.jms TemporaryTopic toString.

Prototype


String toString();

Source Link

Document

Returns a string representation of this object.

Usage

From source file:org.openanzo.combus.bayeux.BridgeConnectionManager.java

/**
 * Destroy all state including the JMS connection and Bayeux client state.
 * //  w  w  w . j av a 2  s.co  m
 * @param bundleStopping
 *            bundle stopping
 * @throws AnzoException
 */
protected void destroy(boolean bundleStopping) throws AnzoException {
    closed = true;

    topicDeletionTimeoutTimer.cancel();
    topicDeletionTimeoutTimer = null;

    if (conn != null) {
        try {
            Collection<MessageConsumer> consumersToClose = null;
            Collection<TemporaryTopic> topicsToDelete = null;
            mapLock.lock();
            try {
                if (bundleStopping) {
                    Collection<MessageConsumer> graphTopicConsumersToClose = removeAllTopicSubscriptions();
                    consumersToClose = new ArrayList<MessageConsumer>(
                            graphTopicConsumersToClose.size() + clientIdToClientState.size());
                    consumersToClose.addAll(graphTopicConsumersToClose);
                    topicsToDelete = new ArrayList<TemporaryTopic>(clientIdToClientState.size());
                    for (Map.Entry<String, ClientState> entry : clientIdToClientState.entrySet()) {
                        ClientState state = entry.getValue();
                        if (state != null) {
                            consumersToClose.add(state.consumer);
                            topicsToDelete.add(state.topic);
                        }
                    }
                }
                clientIdToClientState.clear();
            } finally {
                mapLock.unlock();
            }
            if (bundleStopping) {
                if (consumersToClose != null) {
                    for (MessageConsumer consumer : consumersToClose) {
                        if (consumer != null) {
                            closeMessageConsumer(consumer);
                        }
                    }
                }
                if (topicsToDelete != null) {
                    for (TemporaryTopic topic : topicsToDelete) {
                        if (topic != null) {
                            try {
                                topic.delete();
                            } catch (JMSException jmsex) {
                                log.warn(LogUtils.COMBUS_MARKER,
                                        "Error deleting bayuex connection manager temporary topic:"
                                                + topic.toString(),
                                        jmsex);
                            }
                        }
                    }
                }
                if (session != null) {
                    try {
                        session.close();
                    } catch (JMSException jmsex) {
                        log.warn(LogUtils.COMBUS_MARKER, "Error closing bayuex connection manager session",
                                jmsex);
                    } finally {
                        session = null;
                    }
                }
            }
        } finally {
            try {
                conn.close();
            } catch (JMSException jmsex) {
                log.warn(LogUtils.COMBUS_MARKER, "Error closing bayuex connection manager  connection", jmsex);
            } finally {
                conn = null;
            }
        }
    }
}