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;
}
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;
}
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());
}
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;
}
Aggregations