This method will create a listener to the specified destination

@param connection The connection to an ME
540063
private void createSingleListener(final SibRaMessagingEngineConnection connection) throws ResourceException
    {
        final String methodName = "createSingleListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName, connection);
        }

        final SIDestinationAddress destination = _endpointConfiguration.getDestination();

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
        {
            SibTr.debug(TRACE, "Creating a consumer to consume from destination "
                               + destination + " on ME " + connection.getConnection().getMeName());
        }

        try
        {
            connection.createListener(destination, _messageEndpointFactory);
            SibTr.info(TRACE, "CONNECTED_CWSIV0777", new Object[] {
                                                                   connection.getConnection().getMeName(),
                                                                   _endpointConfiguration.getDestination()
                                                                                   .getDestinationName(),
                                                                   _endpointConfiguration.getBusName() });
        } catch (final IllegalStateException exception)
        {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
            {
                SibTr.debug(TRACE, "Failed to create a session - blowing away the connection - rethrow the exception");
            }

            _connections.remove(connection.getConnection().getMeUuid());
            connection.close();
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
            {
                SibTr.exit(this, TRACE, methodName);
            }
            throw exception;
        } catch (final ResourceException exception)
        {
            // No FFDC code needed

            // Failed to create a consumer so blow away the connection and try
            // again
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
            {
                SibTr.debug(TRACE, "Failed to create a session - blowing away the connection - a retry should occur");
                SibTr.debug(TRACE, "Exception cause was " + exception.getCause());
            }

            _connections.remove(connection.getConnection().getMeUuid());
            connection.close();
            throw exception;
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }
    }
888334
private void onConnectionClose(final Connection closed) {
        synchronized (this) {
            if(connection == closed) {
                connection = null;
                if(shutdown) {
                    connectTask = DISCONNECTED;
                    return;
                }
                final ConnectTask previous = connectTask;
                connectTask = previous.connectionClosed();
            }
        }
    }
43651
protected void purgeClosedConnection(OutboundConnection connection)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "purgeClosedConnection", connection);
        purge(connection, false, false);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "purgeClosedConnection");
    }
797457
synchronized void connectionError(
            final SibRaMessagingEngineConnection connection,
            final SIException exception) {

        final String methodName = "connectionError";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, new Object[] { connection,
                    exception });
        }

        if (_remoteMessagingEngine) {

            if (connection.equals(_remoteConnection)) {

                /*
                 * We have lost our remote connection, output a warning to the
                 * admin console, close the connection and schedule an attempt
                 * to create a new one
                 */

                SibTr.warning(TRACE, "CONNECTION_ERROR_CWSIV0776",
                        new Object[] { connection.getConnection().getMeName(),
                                _endpointConfiguration.getBusName(), this,
                                exception });

                _remoteConnection.close();
                _remoteConnection = null;

                scheduleCreateRemoteListener();

            } else {

                /*
                 * We have already closed the remote connection
                 */
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE, "Connection " + connection
                            + " not equal to current remote connection "
                            + _remoteConnection);
                }

            }

        } else {

            /*
             * Output a message to the admin console and deactivate the endpoint
             */

            SibTr.error(TRACE, "CONNECTION_ERROR_CWSIV0767", new Object[] {
                    exception, connection.getConnection().getMeName(), this });
            deactivate();
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }
    }
1049035
protected SQLListenerContextImpl startContext(Connection connection, QueryMetadata metadata) {
        SQLListenerContextImpl context = new SQLListenerContextImpl(metadata, connection);
        if (parentContext != null) {
            context.setData(PARENT_CONTEXT, parentContext);
        }
        listeners.start(context);
        return context;
    }
1117749
public void registerConnection(Connection connection, ConnectionDefinition connectionDefinition) {
        checkNotNull(connection);
        checkNotNull(connectionDefinition);

        if (this.connectionDefinitions.putIfAbsent(connectionDefinition.getName(), connectionDefinition) != null) {
            throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
        }

        if (this.connections.putIfAbsent(connectionDefinition.getName(), connection) != null) {
            throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
        }

        if (shouldStartConnections.get()) {
            try {
                connection.start();
            } catch (JMSException e) {
                throw SeedException.wrap(e, JmsErrorCode.UNABLE_TO_START_JMS_CONNECTION).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
            }
        }
    }
1080869
public void endConnection(SuroConnection connection) {
        if (connection != null && shouldChangeConnection(connection)) {
            connection.initStat();
            connectionPool.put(connection.getServer(), connection);
            connection = chooseFromPool();
        }

        if (connection != null) {
            connectionQueue.offer(connection);
        }
    }
999817
public static void setConnectionLocal(IConnection connection) {
        if (log.isDebugEnabled()) {
            log.debug("Set connection: {} with thread: {}", (connection != null ? connection.getSessionId() : null), Thread.currentThread().getName());
            try {
                StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
                StackTraceElement stackTraceElement = stackTraceElements[2];
                log.debug("Caller: {}.{} #{}", stackTraceElement.getClassName(), stackTraceElement.getMethodName(), stackTraceElement.getLineNumber());
            } catch (Exception e) {
            }
        }
        if (connection != null) {
            connThreadLocal.set(new WeakReference<IConnection>(connection));
            IScope scope = connection.getScope();
            if (scope != null) {
                Thread.currentThread().setContextClassLoader(scope.getClassLoader());
            }
        } else {
            // use null to clear the value
            connThreadLocal.remove();
        }
    }
310867
function ReconnectingConnection(id, connection) {
  this.id = id;
  this.connection = null;
  this.closed = false;
  this.queue = [];

  this.setConnection(connection);
}
694101
public function listen($connection, $queue, ListenerOptions $options)
    {
        $process = $this->makeProcess($connection, $queue, $options);

        while (true) {
            $this->runProcess($process, $options->memory);
        }
    }
874187
private void setConnectTimeout(HttpURLConnection connection) {
        try {
            Map<String, String> endpointProperties = this.api.getEndpointProperties();
            if (endpointProperties.containsKey("timeouts.connect")) { //$NON-NLS-1$
                int connectTimeoutMs = new Integer(endpointProperties.get("timeouts.connect")); //$NON-NLS-1$
                connection.setConnectTimeout(connectTimeoutMs);
            }
        } catch (Throwable t) {
        }
    }
127077
public void addListener(ForwardingClientListener listener) {
		if (listener != null) {
			clientlisteners.addElement(listener);

			SocketListener s;
			Enumeration<SocketListener> en = socketlisteners.elements();
			while (en.hasMoreElements()) {
				s = (SocketListener) en.nextElement();
				if (s.isListening()) {
					listener.forwardingStarted(
							ForwardingClientListener.LOCAL_FORWARDING,
							generateKey(s.addressToBind, s.portToBind),
							s.hostToConnect, s.portToConnect);

				}
			}
			if (Log.isDebugEnabled()) {
				Log.debug(this, "enumerated socketlisteners");
			}

			Enumeration<String> en2 = incomingtunnels.keys();
			String key;
			String destination;
			String hostToConnect;
			int portToConnect;
			while (en2.hasMoreElements()) {
				key = en2.nextElement();
				if (key.equals(X11_KEY)
						|| ssh.getContext().getX11Display() != null
						&& ssh.getContext().getX11Display().equals(key))
					continue;
				destination = (String) remoteforwardings.get(key);
				hostToConnect = destination.substring(0,
						destination.indexOf(':'));
				portToConnect = Integer.parseInt(destination
						.substring(destination.indexOf(':') + 1));

				listener.forwardingStarted(
						ForwardingClientListener.REMOTE_FORWARDING, key,
						hostToConnect, portToConnect);

			}
			if (Log.isDebugEnabled()) {
				Log.debug(this, "enumerated incomingtunnels");
			}

			String display = ssh.getContext().getX11Display();

			if (Log.isDebugEnabled()) {
				Log.debug(this, "display is " + display);
			}

			if (display != null && isXForwarding) {
				String hostname = "localhost";
				int screen;
				int idx = display.indexOf(':');
				if (idx != -1) {
					hostname = display.substring(0, idx);
					screen = Integer.parseInt(display.substring(idx + 1));
				} else {
					screen = Integer.parseInt(display);
				}

				listener.forwardingStarted(
						ForwardingClientListener.X11_FORWARDING, X11_KEY,
						hostname, screen);
			}
		}
	}
64288
public void onConnect(RespokeSignalingChannel sender, String endpointID, String connectionID) {
        connectionInProgress = false;
        reconnectCount = 0;
        localEndpointID = endpointID;
        localConnectionID = connectionID;

        Respoke.sharedInstance().clientConnected(this);

        // Try to set the presence to the initial or last set state
        setPresence(presence, new Respoke.TaskCompletionListener() {
            @Override
            public void onSuccess() {
                // do nothing
            }

            @Override
            public void onError(String errorMessage) {
                // do nothing
            }
        });

        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                Listener listener = listenerReference.get();
                if (null != listener) {
                    listener.onConnect(RespokeClient.this);
                }
            }
        });
    }
601356
@Override
    public void addConnectionEventListener( ConnectionEventListener listener ) {
        if (listener == null) {
            throw new IllegalArgumentException("Listener is null");
        }
        listeners.add(listener);
    }
358044
public Closeable onConnectionStateChange(final Consumer<BitfinexConnectionStateEnum> listener) {
        connectionStateConsumers.offer(listener);
        return () -> connectionStateConsumers.remove(listener);
    }
1071751
void messagingEngineTerminated(
            final SibRaMessagingEngineConnection connection) {

        final String methodName = "messagingEngineTerminated";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, connection);
        }

        /*
         * Close the connection - any future work will attempt to create a new
         * connection
         */

        closeConnection(connection.getConnection().getMeUuid(), true);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
1275257
private void notifyListeners(TLSClientConnection client) {
    for (INetworkConnectionListener listener : this.listeners) {
      try {
        listener.newNetworkConnection(client);
      }
      catch (Exception e) {
        logger.debug("Connection listener threw exception!", e);
      }
    }
  }