Search in sources :

Example 1 with DisconnectMessage

use of org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage in project activemq-artemis by apache.

the class RemotingConnectionImpl method disconnect.

@Override
public void disconnect(String scaleDownNodeID, final boolean criticalError) {
    Channel channel0 = getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
    // And we remove all channels from the connection, this ensures no more packets will be processed after this
    // method is
    // complete
    Set<Channel> allChannels = new HashSet<>(channels.values());
    if (!criticalError) {
        removeAllChannels();
    } else {
        // We can't hold a lock if a critical error is happening...
        // as other threads will be holding the lock while hanging on IO
        channels.clear();
    }
    if (!criticalError) {
        for (Channel channel : allChannels) {
            channel.flushConfirmations();
        }
    }
    Packet disconnect;
    if (channel0.supports(PacketImpl.DISCONNECT_V2)) {
        disconnect = new DisconnectMessage_V2(nodeID, scaleDownNodeID);
    } else {
        disconnect = new DisconnectMessage(nodeID);
    }
    channel0.sendAndFlush(disconnect);
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) DisconnectMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage) Channel(org.apache.activemq.artemis.core.protocol.core.Channel) DisconnectMessage_V2(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage_V2) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Channel (org.apache.activemq.artemis.core.protocol.core.Channel)1 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)1 DisconnectMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage)1 DisconnectMessage_V2 (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage_V2)1