Search in sources :

Example 21 with Packet

use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.

the class ActiveMQSessionContext method addressQuery.

@Override
public ClientSession.AddressQuery addressQuery(final SimpleString address) throws ActiveMQException {
    if (sessionChannel.supports(PacketImpl.SESS_BINDINGQUERY_RESP_V4, getServerVersion())) {
        Packet packet = sessionChannel.sendBlocking(new SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP_V4);
        SessionBindingQueryResponseMessage_V4 response = (SessionBindingQueryResponseMessage_V4) packet;
        return new AddressQueryImpl(response.isExists(), response.getQueueNames(), response.isAutoCreateQueues(), response.isAutoCreateAddresses(), response.isDefaultPurgeOnNoConsumers(), response.getDefaultMaxConsumers(), response.isDefaultExclusive(), response.isDefaultLastValue());
    } else if (sessionChannel.supports(PacketImpl.SESS_BINDINGQUERY_RESP_V3, getServerVersion())) {
        Packet packet = sessionChannel.sendBlocking(new SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP_V3);
        SessionBindingQueryResponseMessage_V3 response = (SessionBindingQueryResponseMessage_V3) packet;
        return new AddressQueryImpl(response.isExists(), response.getQueueNames(), response.isAutoCreateQueues(), response.isAutoCreateAddresses(), ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), null, null);
    } else if (sessionChannel.supports(PacketImpl.SESS_BINDINGQUERY_RESP_V2, getServerVersion())) {
        Packet packet = sessionChannel.sendBlocking(new SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP_V2);
        SessionBindingQueryResponseMessage_V2 response = (SessionBindingQueryResponseMessage_V2) packet;
        return new AddressQueryImpl(response.isExists(), response.getQueueNames(), response.isAutoCreateQueues(), false, ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), null, null);
    } else {
        Packet packet = sessionChannel.sendBlocking(new SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP);
        SessionBindingQueryResponseMessage response = (SessionBindingQueryResponseMessage) packet;
        return new AddressQueryImpl(response.isExists(), response.getQueueNames(), false, false, ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), null, null);
    }
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) AddressQueryImpl(org.apache.activemq.artemis.core.client.impl.AddressQueryImpl) SessionBindingQueryResponseMessage_V4(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionBindingQueryResponseMessage_V4) SessionBindingQueryResponseMessage_V2(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionBindingQueryResponseMessage_V2) SessionBindingQueryResponseMessage_V3(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionBindingQueryResponseMessage_V3) SessionBindingQueryResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionBindingQueryResponseMessage) SessionBindingQueryMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionBindingQueryMessage)

Example 22 with Packet

use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.

the class ChannelImpl method confirm.

@Override
public void confirm(final Packet packet) {
    if (resendCache != null && packet.isRequiresConfirmations()) {
        lastConfirmedCommandID.incrementAndGet();
        if (logger.isTraceEnabled()) {
            logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::confirming packet " + packet + " last commandID=" + lastConfirmedCommandID);
        }
        receivedBytes += packet.getPacketSize();
        if (receivedBytes >= confWindowSize) {
            receivedBytes = 0;
            final Packet confirmed = new PacketsConfirmedMessage(lastConfirmedCommandID.get());
            confirmed.setChannelID(id);
            doWrite(confirmed);
        }
    }
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) PacketsConfirmedMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.PacketsConfirmedMessage)

Example 23 with Packet

use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.

the class RemotingConnectionImpl method bufferReceived.

// Buffer Handler implementation
// ----------------------------------------------------
@Override
public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
    try {
        final Packet packet = packetDecoder.decode(buffer, this);
        if (logger.isTraceEnabled()) {
            logger.trace("RemotingConnectionID=" + getID() + " handling packet " + packet);
        }
        dataReceived = true;
        doBufferReceived(packet);
        super.bufferReceived(connectionID, buffer);
    } catch (Throwable e) {
        ActiveMQClientLogger.LOGGER.errorDecodingPacket(e);
        throw new IllegalStateException(e);
    }
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet)

Example 24 with Packet

use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.

the class ClientPacketDecoder method decode.

@Override
public Packet decode(final ActiveMQBuffer in, CoreRemotingConnection connection) {
    final byte packetType = in.readByte();
    Packet packet = decode(packetType, connection);
    packet.decode(in);
    return packet;
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet)

Example 25 with Packet

use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.

the class CoreSessionCallback method sendLargeMessage.

@Override
public int sendLargeMessage(MessageReference ref, Message message, ServerConsumer consumer, long bodySize, int deliveryCount) {
    Packet packet = new SessionReceiveLargeMessage(consumer.getID(), message, bodySize, deliveryCount);
    channel.send(packet);
    int size = packet.getPacketSize();
    return size;
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) SessionReceiveLargeMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveLargeMessage)

Aggregations

Packet (org.apache.activemq.artemis.core.protocol.core.Packet)35 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)16 Interceptor (org.apache.activemq.artemis.api.core.Interceptor)11 RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)11 CountDownLatch (java.util.concurrent.CountDownLatch)10 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)10 Test (org.junit.Test)10 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)8 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)7 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)5 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)5 Channel (org.apache.activemq.artemis.core.protocol.core.Channel)5 ArrayList (java.util.ArrayList)3 XAException (javax.transaction.xa.XAException)3 ActiveMQInternalErrorException (org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)3 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)3 CreateSessionResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage)3 SessionProducerCreditsMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionProducerCreditsMessage)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2