@Override public void onAuthInit(ProtonHandler handler, Connection connection, boolean sasl) { if (sasl) { // configured mech in decreasing order of preference String[] mechanisms = connectionCallback.getSaslMechanisms(); if (mechanisms == null || mechanisms.length == 0) { mechanisms = AnonymousServerSASL.ANONYMOUS_MECH; } handler.createServerSASL(mechanisms); } else { if (!connectionCallback.isSupportsAnonymous()) { connectionCallback.sendSASLSupported(); connectionCallback.close(); handler.close(null, this); } } }
@Override public RemotingConnection getRemotingConnection() { return connection.connectionCallback.getProtonConnectionDelegate(); } });
public Transaction getTransaction(Binary txid, boolean remove) throws ActiveMQAMQPException { return protonSPI.getTransaction(txid, remove); }
public ActiveMQProtonRemotingConnection createConnection(ProtonProtocolManager protocolManager, Connection connection, Optional<EventHandler> eventHandler, ClientSASLFactory clientSASLFactory) { AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(protocolManager, connection, server.getExecutorFactory().getExecutor(), server); Executor executor = server.getExecutorFactory().getExecutor(); AMQPConnectionContext amqpConnection = new AMQPConnectionContext(protocolManager, connectionCallback, containerId, ttl, protocolManager.getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), false, clientSASLFactory, connectionProperties); eventHandler.ifPresent(amqpConnection::addEventHandler); ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(protocolManager, amqpConnection, connection, executor); delegate.addFailureListener(connectionCallback); delegate.addCloseListener(connectionCallback); connectionCallback.setProtonConnectionDelegate(delegate); return delegate; } }
@Override public void connectionFailed(ActiveMQException exception, boolean failedOver, String scaleDownTargetNodeID) { close(); }
protected AMQPSessionContext newSessionExtension(Session realSession) throws ActiveMQAMQPException { AMQPSessionCallback sessionSPI = connectionCallback.createSessionCallback(this); AMQPSessionContext protonSession = new AMQPSessionContext(sessionSPI, this, realSession); return protonSession; }
@Override public void onSaslRemoteMechanismChosen(ProtonHandler handler, String mech) { handler.setChosenMechanism(connectionCallback.getServerSASL(mech)); }
public Symbol[] getConnectionCapabilitiesOffered() { URI tc = connectionCallback.getFailoverList(); if (tc != null) { Map<Symbol, Object> hostDetails = new HashMap<>(); hostDetails.put(NETWORK_HOST, tc.getHost()); boolean isSSL = tc.getQuery().contains(TransportConstants.SSL_ENABLED_PROP_NAME + "=true"); if (isSSL) { hostDetails.put(SCHEME, "amqps"); } else { hostDetails.put(SCHEME, "amqp"); } hostDetails.put(HOSTNAME, tc.getHost()); hostDetails.put(PORT, tc.getPort()); connectionProperties.put(FAILOVER_SERVER_LIST, Arrays.asList(hostDetails)); } return ExtCapability.getCapabilities(); }
Executor executor = protonSPI.getExeuctor();
public ActiveMQProtonRemotingConnection createConnection(ProtonProtocolManager protocolManager, Connection connection, Optional<EventHandler> eventHandler, ClientSASLFactory clientSASLFactory) { AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(protocolManager, connection, server.getExecutorFactory().getExecutor(), server); Executor executor = server.getExecutorFactory().getExecutor(); AMQPConnectionContext amqpConnection = new AMQPConnectionContext(protocolManager, connectionCallback, containerId, ttl, protocolManager.getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), false, clientSASLFactory, connectionProperties); eventHandler.ifPresent(amqpConnection::addEventHandler); ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(protocolManager, amqpConnection, connection, executor); delegate.addFailureListener(connectionCallback); delegate.addCloseListener(connectionCallback); connectionCallback.setProtonConnectionDelegate(delegate); return delegate; } }
@Override public void connectionFailed(ActiveMQException exception, boolean failedOver) { close(); }
protected AMQPSessionContext newSessionExtension(Session realSession) throws ActiveMQAMQPException { AMQPSessionCallback sessionSPI = connectionCallback.createSessionCallback(this); AMQPSessionContext protonSession = new AMQPSessionContext(sessionSPI, this, realSession); return protonSession; }
@Override public void onSaslRemoteMechanismChosen(ProtonHandler handler, String mech) { handler.setChosenMechanism(connectionCallback.getServerSASL(mech)); }
public Symbol[] getConnectionCapabilitiesOffered() { URI tc = connectionCallback.getFailoverList(); if (tc != null) { Map<Symbol, Object> hostDetails = new HashMap<>(); hostDetails.put(NETWORK_HOST, tc.getHost()); boolean isSSL = tc.getQuery().contains(TransportConstants.SSL_ENABLED_PROP_NAME + "=true"); if (isSSL) { hostDetails.put(SCHEME, "amqps"); } else { hostDetails.put(SCHEME, "amqp"); } hostDetails.put(HOSTNAME, tc.getHost()); hostDetails.put(PORT, tc.getPort()); connectionProperties.put(FAILOVER_SERVER_LIST, Arrays.asList(hostDetails)); } return ExtCapability.getCapabilities(); }
public ActiveMQProtonRemotingConnection createConnection(ProtonProtocolManager protocolManager, Connection connection, Optional<EventHandler> eventHandler, ClientSASLFactory clientSASLFactory) { AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(protocolManager, connection, server.getExecutorFactory().getExecutor(), server); Executor executor = server.getExecutorFactory().getExecutor(); AMQPConnectionContext amqpConnection = new AMQPConnectionContext(protocolManager, connectionCallback, containerId, ttl, protocolManager.getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), false, clientSASLFactory, connectionProperties); eventHandler.ifPresent(amqpConnection::addEventHandler); ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(protocolManager, amqpConnection, connection, executor); delegate.addFailureListener(connectionCallback); delegate.addCloseListener(connectionCallback); connectionCallback.setProtonConnectionDelegate(delegate); return delegate; } }
@Override public void onAuthInit(ProtonHandler handler, Connection connection, boolean sasl) { if (sasl) { // configured mech in decreasing order of preference String[] mechanisms = connectionCallback.getSaslMechanisms(); if (mechanisms == null || mechanisms.length == 0) { mechanisms = AnonymousServerSASL.ANONYMOUS_MECH; } handler.createServerSASL(mechanisms); } else { if (!connectionCallback.isSupportsAnonymous()) { connectionCallback.sendSASLSupported(); connectionCallback.close(); handler.close(null); } } }
@Override public void connectionFailed(ActiveMQException exception, boolean failedOver, String scaleDownTargetNodeID) { close(); }
@Override public RemotingConnection getRemotingConnection() { return connection.connectionCallback.getProtonConnectionDelegate(); } });
public Transaction getTransaction(Binary txid, boolean remove) throws ActiveMQAMQPException { return protonSPI.getTransaction(txid, remove); }
@Override public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection remotingConnection) { AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(this, remotingConnection, server.getExecutorFactory().getExecutor(), server); long ttl = ActiveMQClient.DEFAULT_CONNECTION_TTL; if (server.getConfiguration().getConnectionTTLOverride() != -1) { ttl = server.getConfiguration().getConnectionTTLOverride(); } if (getAmqpIdleTimeout() != null) { ttl = getAmqpIdleTimeout().longValue(); } if (ttl < 0) { ttl = 0; } String id = server.getConfiguration().getName(); boolean useCoreSubscriptionNaming = server.getConfiguration().isAmqpUseCoreSubscriptionNaming(); AMQPConnectionContext amqpConnection = new AMQPConnectionContext(this, connectionCallback, id, (int) ttl, getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), true, null, null); Executor executor = server.getExecutorFactory().getExecutor(); ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(this, amqpConnection, remotingConnection, executor); delegate.addFailureListener(connectionCallback); delegate.addCloseListener(connectionCallback); connectionCallback.setProtonConnectionDelegate(delegate); // connection entry only understands -1 otherwise we would see disconnects for no reason ConnectionEntry entry = new ConnectionEntry(delegate, executor, System.currentTimeMillis(), ttl <= 0 ? -1 : ttl); return entry; }