Search in sources :

Example 1 with SessionReceiveMessage

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

the class DummyInterceptor method intercept.

@Override
public boolean intercept(final Packet packet, final RemotingConnection conn) throws ActiveMQException {
    log.debug("DummyFilter packet = " + packet.getClass().getName());
    syncCounter.addAndGet(1);
    if (sendException) {
        throw new ActiveMQInternalErrorException();
    }
    if (changeMessage) {
        if (packet instanceof SessionReceiveMessage) {
            SessionReceiveMessage deliver = (SessionReceiveMessage) packet;
            log.debug("msg = " + deliver.getMessage().getClass().getName());
            deliver.getMessage().putStringProperty(new SimpleString("DummyInterceptor"), new SimpleString("was here"));
        }
    }
    return true;
}
Also used : ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SessionReceiveMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage)

Example 2 with SessionReceiveMessage

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

the class CoreSessionCallback method sendMessage.

@Override
public int sendMessage(MessageReference ref, Message message, ServerConsumer consumer, int deliveryCount) {
    Packet packet;
    if (channel.getConnection().isVersionBeforeAddressChange()) {
        packet = new SessionReceiveMessage_1X(consumer.getID(), message.toCore(coreMessageObjectPools), deliveryCount);
    } else {
        packet = new SessionReceiveMessage(consumer.getID(), message.toCore(coreMessageObjectPools), deliveryCount);
    }
    int size = 0;
    if (channel.sendBatched(packet)) {
        size = packet.getPacketSize();
    }
    return size;
}
Also used : Packet(org.apache.activemq.artemis.core.protocol.core.Packet) SessionReceiveMessage_1X(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage_1X) SessionReceiveMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage)

Example 3 with SessionReceiveMessage

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

the class CoreMessageTest method sendThroughPacketsClient.

/**
 * The message is received, then sent to the other side untouched
 */
@Test
public void sendThroughPacketsClient() {
    CoreMessage decodedMessage = decodeMessage();
    int encodeSize = decodedMessage.getEncodeSize();
    Assert.assertEquals(BYTE_ENCODE.capacity(), encodeSize);
    SessionReceiveMessage sendMessage = new SessionReceiveMessage(33, decodedMessage, 7);
    sendMessage.setChannelID(777);
    ActiveMQBuffer buffer = sendMessage.encode(null);
    buffer.readerIndex(5);
    SessionReceiveMessage sendMessageReceivedSent = new SessionReceiveMessage(new CoreMessage());
    sendMessageReceivedSent.decode(buffer);
    Assert.assertEquals(33, sendMessageReceivedSent.getConsumerID());
    Assert.assertEquals(7, sendMessageReceivedSent.getDeliveryCount());
    Assert.assertEquals(encodeSize, sendMessageReceivedSent.getMessage().getEncodeSize());
    Assert.assertEquals(TEXT, TextMessageUtil.readBodyText(sendMessageReceivedSent.getMessage().getReadOnlyBodyBuffer()).toString());
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) SessionReceiveMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 4 with SessionReceiveMessage

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

the class Incoming method intercept.

@Override
public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException {
    System.out.println("Incoming:Packet : " + packet);
    if (packet.getType() == PacketImpl.SESS_RECEIVE_MSG) {
        SessionReceiveMessage p = (SessionReceiveMessage) packet;
        p.getMessage().putStringProperty("Incoming", "was here");
    }
    return true;
}
Also used : SessionReceiveMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage)

Aggregations

SessionReceiveMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage)4 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)1 ActiveMQInternalErrorException (org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)1 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)1 SessionReceiveMessage_1X (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage_1X)1 Test (org.junit.Test)1