/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
public void encodeHeadersAndProperties(final ByteBuf buffer) { checkProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
public void encodeHeadersAndProperties(final ByteBuf buffer) { final TypedProperties properties = getProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
public void encodeHeadersAndProperties(final ByteBuf buffer) { checkProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
/** * Utility method to set the map on a message body */ public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) { message.resetWriterIndex(); properties.encode(message.byteBuf()); }
public void encodeHeadersAndProperties(final ByteBuf buffer) { final TypedProperties properties = getProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
public void encodeHeadersAndProperties(final ByteBuf buffer) { checkProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
public void encodeHeadersAndProperties(final ByteBuf buffer) { checkProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
private static void writeMapType(final ByteSequence contents, final boolean messageCompressed, final ActiveMQBuffer body) throws IOException { InputStream mis = new ByteArrayInputStream(contents); if (messageCompressed) { mis = new InflaterInputStream(mis); } DataInputStream mdataIn = new DataInputStream(mis); Map<String, Object> map = MarshallingSupport.unmarshalPrimitiveMap(mdataIn); mdataIn.close(); TypedProperties props = new TypedProperties(); loadMapIntoProperties(props, map); props.encode(body.byteBuf()); }
/** Sub classes must add the first short as the protocol-id */ @Override public void encode(ActiveMQBuffer buffer, Message record) { super.encode(buffer, record); TypedProperties properties = ((AMQPMessage)record).getExtraProperties(); if (properties == null) { buffer.writeInt(0); } else { buffer.writeInt(properties.getEncodeSize()); properties.encode(buffer.byteBuf()); } }
/** Sub classes must add the first short as the protocol-id */ @Override public void encode(ActiveMQBuffer buffer, Message record) { super.encode(buffer, record); TypedProperties properties = ((AMQPMessage)record).getExtraProperties(); if (properties == null) { buffer.writeInt(0); } else { buffer.writeInt(properties.getEncodeSize()); properties.encode(buffer.byteBuf()); } }
public void encodeHeadersAndProperties(final ByteBuf buffer) { final TypedProperties properties = getProperties(); messageIDPosition = buffer.writerIndex(); buffer.writeLong(messageID); SimpleString.writeNullableSimpleString(buffer, address); if (userID == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } buffer.writeByte(type); buffer.writeBoolean(durable); buffer.writeLong(expiration); buffer.writeLong(timestamp); buffer.writeByte(priority); properties.encode(buffer); }
@Test public void testEncodeDecodeEmpty() throws Exception { TypedProperties emptyProps = new TypedProperties(); ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024); emptyProps.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); TypedProperties decodedProps = new TypedProperties(); decodedProps.decode(buffer.byteBuf()); TypedPropertiesTest.assertEqualsTypeProperties(emptyProps, decodedProps); }
@Test public void testEncodeDecode() throws Exception { props.putByteProperty(RandomUtil.randomSimpleString(), RandomUtil.randomByte()); props.putBytesProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBytes()); props.putBytesProperty(RandomUtil.randomSimpleString(), null); props.putBooleanProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBoolean()); props.putShortProperty(RandomUtil.randomSimpleString(), RandomUtil.randomShort()); props.putIntProperty(RandomUtil.randomSimpleString(), RandomUtil.randomInt()); props.putLongProperty(RandomUtil.randomSimpleString(), RandomUtil.randomLong()); props.putFloatProperty(RandomUtil.randomSimpleString(), RandomUtil.randomFloat()); props.putDoubleProperty(RandomUtil.randomSimpleString(), RandomUtil.randomDouble()); props.putCharProperty(RandomUtil.randomSimpleString(), RandomUtil.randomChar()); props.putSimpleStringProperty(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString()); props.putSimpleStringProperty(RandomUtil.randomSimpleString(), null); SimpleString keyToRemove = RandomUtil.randomSimpleString(); props.putSimpleStringProperty(keyToRemove, RandomUtil.randomSimpleString()); ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024); props.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); TypedProperties decodedProps = new TypedProperties(); decodedProps.decode(buffer.byteBuf()); TypedPropertiesTest.assertEqualsTypeProperties(props, decodedProps); buffer.clear(); // After removing a property, you should still be able to encode the Property props.removeProperty(keyToRemove); props.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); }