Search in sources :

Example 1 with ChannelHandler

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;
}
Also used : Executor(java.util.concurrent.Executor) Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConnectionEntry(org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry) CoreRemotingConnection(org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection) Channel(org.apache.activemq.artemis.core.protocol.core.Channel) ChannelHandler(org.apache.activemq.artemis.core.protocol.core.ChannelHandler) ServerPacketDecoder(org.apache.activemq.artemis.core.protocol.ServerPacketDecoder)

Example 2 with ChannelHandler

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);
            }
        }
    };
}
Also used : BackupRequestMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRequestMessage) Packet(org.apache.activemq.artemis.core.protocol.core.Packet) ChannelHandler(org.apache.activemq.artemis.core.protocol.core.ChannelHandler) BackupResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupResponseMessage)

Example 3 with ChannelHandler

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));
                }
            }
        }
    };
}
Also used : BackupRegistrationMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage) Packet(org.apache.activemq.artemis.core.protocol.core.Packet) ClusterConnection(org.apache.activemq.artemis.core.server.cluster.ClusterConnection) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) BackupReplicationStartFailedMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage) ActiveMQAlreadyReplicatingException(org.apache.activemq.artemis.api.core.ActiveMQAlreadyReplicatingException) ChannelHandler(org.apache.activemq.artemis.core.protocol.core.ChannelHandler)

Aggregations

ChannelHandler (org.apache.activemq.artemis.core.protocol.core.ChannelHandler)3 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)2 Executor (java.util.concurrent.Executor)1 ActiveMQAlreadyReplicatingException (org.apache.activemq.artemis.api.core.ActiveMQAlreadyReplicatingException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 ServerPacketDecoder (org.apache.activemq.artemis.core.protocol.ServerPacketDecoder)1 Channel (org.apache.activemq.artemis.core.protocol.core.Channel)1 CoreRemotingConnection (org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection)1 BackupRegistrationMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage)1 BackupReplicationStartFailedMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage)1 BackupRequestMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRequestMessage)1 BackupResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupResponseMessage)1 ClusterConnection (org.apache.activemq.artemis.core.server.cluster.ClusterConnection)1 ConnectionEntry (org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry)1