Java Code Examples for org.apache.qpid.proton.message.impl.MessageImpl#encode()

The following examples show how to use org.apache.qpid.proton.message.impl.MessageImpl#encode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageJournalTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPStandardMessage encodeAndCreateAMQPMessage(MessageImpl message) {
   NettyWritable encoded = new NettyWritable(Unpooled.buffer(1024));
   message.encode(encoded);

   NettyReadable readable = new NettyReadable(encoded.getByteBuf());

   return new AMQPStandardMessage(AMQPStandardMessage.DEFAULT_MESSAGE_FORMAT, readable, null, null);
}
 
Example 2
Source File: AmqpTestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public static AMQPStandardMessage encodeAndDecodeMessage(int messageFormat, MessageImpl message, int expectedSize) {
   ByteBuf nettyBuffer = Unpooled.buffer(expectedSize);

   message.encode(new NettyWritable(nettyBuffer));
   byte[] bytes = new byte[nettyBuffer.writerIndex()];
   nettyBuffer.readBytes(bytes);

   return new AMQPStandardMessage(messageFormat, bytes, null);
}
 
Example 3
Source File: MessageTransformationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPMessage encodeAndCreateAMQPMessage(MessageImpl message) {
   NettyWritable encoded = new NettyWritable(Unpooled.buffer(1024));
   message.encode(encoded);

   NettyReadable readable = new NettyReadable(encoded.getByteBuf());

   return new AMQPStandardMessage(AMQPMessage.DEFAULT_MESSAGE_FORMAT, readable, null, null);
}
 
Example 4
Source File: JMSTransformationSpeedComparisonTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPStandardMessage encodeAndCreateAMQPMessage(MessageImpl message) {
   NettyWritable encoded = new NettyWritable(Unpooled.buffer(1024));
   message.encode(encoded);

   NettyReadable readable = new NettyReadable(encoded.getByteBuf());

   return new AMQPStandardMessage(AMQPMessage.DEFAULT_MESSAGE_FORMAT, readable, null, null);
}
 
Example 5
Source File: JMSMappingInboundTransformerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPStandardMessage encodeAndCreateAMQPMessage(MessageImpl message) {
   NettyWritable encoded = new NettyWritable(Unpooled.buffer(1024));
   message.encode(encoded);

   NettyReadable readable = new NettyReadable(encoded.getByteBuf());

   return new AMQPStandardMessage(AMQPMessage.DEFAULT_MESSAGE_FORMAT, readable, null, null);
}
 
Example 6
Source File: TestConversions.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPMessage encodeAndCreateAMQPMessage(MessageImpl message) {
   NettyWritable encoded = new NettyWritable(Unpooled.buffer(1024));
   message.encode(encoded);

   NettyReadable readable = new NettyReadable(encoded.getByteBuf());

   return new AMQPStandardMessage(AMQPMessage.DEFAULT_MESSAGE_FORMAT, readable, null, null);
}
 
Example 7
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private byte[] encodeMessage(MessageImpl message) {
   ByteBuf nettyBuffer = Unpooled.buffer(1500);

   message.encode(new NettyWritable(nettyBuffer));
   byte[] bytes = new byte[nettyBuffer.writerIndex()];
   nettyBuffer.readBytes(bytes);

   return bytes;
}
 
Example 8
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPStandardMessage encodeAndDecodeMessage(MessageImpl message) {
   ByteBuf nettyBuffer = Unpooled.buffer(1500);

   message.encode(new NettyWritable(nettyBuffer));
   byte[] bytes = new byte[nettyBuffer.writerIndex()];
   nettyBuffer.readBytes(bytes);

   return new AMQPStandardMessage(0, bytes, null);
}
 
Example 9
Source File: AMQPPersisterTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private AMQPStandardMessage encodeAndDecodeMessage(MessageImpl message, int expectedSize) {
   ByteBuf nettyBuffer = Unpooled.buffer(expectedSize);

   message.encode(new NettyWritable(nettyBuffer));
   byte[] bytes = new byte[nettyBuffer.writerIndex()];
   nettyBuffer.readBytes(bytes);

   return new AMQPStandardMessage(0, bytes, null);
}
 
Example 10
Source File: ProtonSenderImpl.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
@Override
public ProtonDelivery send(byte[] tag, Message message, Handler<ProtonDelivery> onUpdated) {
  if (anonymousSender && message.getAddress() == null) {
    throw new IllegalArgumentException("Message must have an address when using anonymous sender.");
  }
  // TODO: prevent odd combination of onRecieved callback + SenderSettleMode.SETTLED, or just allow it?

  Delivery delivery = sender().delivery(tag); // start a new delivery..
  ProtonWritableBufferImpl buffer = new ProtonWritableBufferImpl();
  MessageImpl msg = (MessageImpl) message;
  msg.encode(buffer);
  ReadableBuffer encoded = new ProtonReadableBufferImpl(buffer.getBuffer());

  sender().sendNoCopy(encoded);

  if (link.getSenderSettleMode() == SenderSettleMode.SETTLED) {
    delivery.settle();
  }
  sender().advance(); // ends the delivery.

  ProtonDeliveryImpl protonDeliveryImpl = new ProtonDeliveryImpl(delivery);
  if (onUpdated != null) {
    protonDeliveryImpl.setAutoSettle(autoSettle);
    protonDeliveryImpl.handler(onUpdated);
  } else {
    protonDeliveryImpl.setAutoSettle(true);
  }

  getSession().getConnectionImpl().flush();

  return protonDeliveryImpl;
}