use of org.apache.activemq.artemis.core.protocol.core.ChannelHandler in project activemq-artemis by apache.
the class CoreProtocolManager method createConnectionEntry.
@Override
public ConnectionEntry createConnectionEntry(final Acceptor acceptorUsed, final Connection connection) {
final Configuration config = server.getConfiguration();
Executor connectionExecutor = server.getExecutorFactory().getExecutor();
final CoreRemotingConnection rc = new RemotingConnectionImpl(new ServerPacketDecoder(), connection, incomingInterceptors, outgoingInterceptors, config.isAsyncConnectionExecutionEnabled() ? connectionExecutor : null, server.getNodeID());
Channel channel1 = rc.getChannel(CHANNEL_ID.SESSION.id, -1);
ChannelHandler handler = new ActiveMQPacketHandler(this, server, channel1, rc);
channel1.setHandler(handler);
long ttl = ActiveMQClient.DEFAULT_CONNECTION_TTL;
if (config.getConnectionTTLOverride() != -1) {
ttl = config.getConnectionTTLOverride();
}
final ConnectionEntry entry = new ConnectionEntry(rc, connectionExecutor, System.currentTimeMillis(), ttl);
final Channel channel0 = rc.getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
channel0.setHandler(new LocalChannelHandler(config, entry, channel0, acceptorUsed, rc));
server.getClusterManager().addClusterChannelHandler(rc.getChannel(CHANNEL_ID.CLUSTER.id, -1), acceptorUsed, rc, server.getActivation());
return entry;
}
use of org.apache.activemq.artemis.core.protocol.core.ChannelHandler in project activemq-artemis by apache.
the class ColocatedActivation method getActivationChannelHandler.
@Override
public ChannelHandler getActivationChannelHandler(final Channel channel, final Acceptor acceptorUsed) {
final ChannelHandler activationChannelHandler = liveActivation.getActivationChannelHandler(channel, acceptorUsed);
return new ChannelHandler() {
@Override
public void handlePacket(Packet packet) {
if (packet.getType() == PacketImpl.BACKUP_REQUEST) {
BackupRequestMessage backupRequestMessage = (BackupRequestMessage) packet;
boolean started = false;
try {
started = colocatedHAManager.activateBackup(backupRequestMessage.getBackupSize(), backupRequestMessage.getJournalDirectory(), backupRequestMessage.getBindingsDirectory(), backupRequestMessage.getLargeMessagesDirectory(), backupRequestMessage.getPagingDirectory(), backupRequestMessage.getNodeID());
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.failedToActivateBackup(e);
}
channel.send(new BackupResponseMessage(started));
} else if (activationChannelHandler != null) {
activationChannelHandler.handlePacket(packet);
}
}
};
}
use of org.apache.activemq.artemis.core.protocol.core.ChannelHandler in project activemq-artemis by apache.
the class SharedNothingLiveActivation method getActivationChannelHandler.
@Override
public ChannelHandler getActivationChannelHandler(final Channel channel, final Acceptor acceptorUsed) {
return new ChannelHandler() {
@Override
public void handlePacket(Packet packet) {
if (packet.getType() == PacketImpl.BACKUP_REGISTRATION) {
BackupRegistrationMessage msg = (BackupRegistrationMessage) packet;
ClusterConnection clusterConnection = acceptorUsed.getClusterConnection();
try {
startReplication(channel.getConnection(), clusterConnection, getPair(msg.getConnector(), true), msg.isFailBackRequest());
} catch (ActiveMQAlreadyReplicatingException are) {
channel.send(new BackupReplicationStartFailedMessage(BackupReplicationStartFailedMessage.BackupRegistrationProblem.ALREADY_REPLICATING));
} catch (ActiveMQException e) {
logger.debug("Failed to process backup registration packet", e);
channel.send(new BackupReplicationStartFailedMessage(BackupReplicationStartFailedMessage.BackupRegistrationProblem.EXCEPTION));
}
}
}
};
}
Aggregations