use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class RemotingServiceImpl method connectionDestroyed.
@Override
public void connectionDestroyed(final Object connectionID) {
if (logger.isTraceEnabled()) {
logger.trace("Connection removed " + connectionID + " from server " + this.server, new Exception("trace"));
}
ConnectionEntry conn = connections.get(connectionID);
if (conn != null && !conn.connection.isSupportReconnect()) {
RemotingConnection removedConnection = removeConnection(connectionID);
if (removedConnection != null) {
try {
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterDestroyConnection(removedConnection));
}
} catch (ActiveMQException t) {
logger.warn("Error executing afterDestroyConnection plugin method: {}", t.getMessage(), t);
conn.connection.fail(t);
return;
}
}
conn.connection.fail(new ActiveMQRemoteDisconnectException());
}
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class RemotingServiceImpl method freeze.
@Override
public synchronized void freeze(final String scaleDownNodeID, final CoreRemotingConnection connectionToKeepOpen) {
if (!started)
return;
failureCheckAndFlushThread.close(false);
HashMap<Object, ConnectionEntry> connectionEntries = new HashMap<>(connections);
// complete then send a disconnect packet
for (Entry<Object, ConnectionEntry> entry : connectionEntries.entrySet()) {
RemotingConnection conn = entry.getValue().connection;
if (conn.equals(connectionToKeepOpen))
continue;
if (logger.isTraceEnabled()) {
logger.trace("Sending connection.disconnection packet to " + conn);
}
if (!conn.isClient()) {
conn.disconnect(scaleDownNodeID, false);
removeConnection(entry.getKey());
}
}
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class OpenWireProtocolManager method createConnectionEntry.
@Override
public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection connection) {
OpenWireFormat wf = (OpenWireFormat) wireFactory.createWireFormat();
OpenWireConnection owConn = new OpenWireConnection(connection, server, server.getExecutorFactory().getExecutor(), this, wf);
owConn.sendHandshake();
// first we setup ttl to -1
// then when negotiation, we handle real ttl and delay
ConnectionEntry entry = new ConnectionEntry(owConn, null, System.currentTimeMillis(), -1);
owConn.setConnectionEntry(entry);
return entry;
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class MQTTProtocolManager method createConnectionEntry.
@Override
public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection connection) {
try {
MQTTConnection mqttConnection = new MQTTConnection(connection);
ConnectionEntry entry = new ConnectionEntry(mqttConnection, null, System.currentTimeMillis(), MQTTUtil.DEFAULT_KEEP_ALIVE_FREQUENCY);
NettyServerConnection nettyConnection = ((NettyServerConnection) connection);
MQTTProtocolHandler protocolHandler = nettyConnection.getChannel().pipeline().get(MQTTProtocolHandler.class);
protocolHandler.setConnection(mqttConnection, entry);
return entry;
} catch (Exception e) {
log.error(e);
return null;
}
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class StompProtocolManager method createConnectionEntry.
@Override
public ConnectionEntry createConnectionEntry(final Acceptor acceptorUsed, final Connection connection) {
StompConnection conn = new StompConnection(acceptorUsed, connection, this, server.getScheduledPool(), server.getExecutorFactory());
// Note that STOMP 1.0 has no heartbeat, so if connection ttl is non zero, data must continue to be sent or connection
// will be timed out and closed!
String ttlStr = (String) acceptorUsed.getConfiguration().get(TransportConstants.CONNECTION_TTL);
Long ttl = ttlStr == null ? null : Long.valueOf(ttlStr);
if (ttl != null) {
if (ttl > 0) {
return new ConnectionEntry(conn, null, System.currentTimeMillis(), ttl);
}
throw BUNDLE.negativeConnectionTTL(ttl);
}
ttl = server.getConfiguration().getConnectionTTLOverride();
if (ttl != -1) {
return new ConnectionEntry(conn, null, System.currentTimeMillis(), ttl);
} else {
// Default to 1 minute - which is same as core protocol
return new ConnectionEntry(conn, null, System.currentTimeMillis(), 1 * 60 * 1000);
}
}
Aggregations