@Override public org.apache.activemq.artemis.api.core.Message setPriority(byte priority) { getHeader().setPriority(UnsignedByte.valueOf(priority)); return this; }
private boolean checkMessageProperties(AMQPMessage message, Map<String, Object> expectedProperties) { assertNotNull(message); assertNotNull(server.getNodeID()); assertNotNull(message.getConnectionID()); assertEquals(message.getAddress(), expectedProperties.get(ADDRESS)); assertEquals(message.isDurable(), expectedProperties.get(DURABLE)); Properties props = message.getProperties(); assertEquals(props.getCorrelationId(), expectedProperties.get(CORRELATION_ID)); assertEquals(props.getReplyTo(), expectedProperties.get(REPLY_TO)); assertEquals(props.getMessageId(), expectedProperties.get(MESSAGE_ID)); Header header = message.getHeader(); assertEquals(header.getDurable(), expectedProperties.get(DURABLE)); assertEquals(header.getTtl().toString(), expectedProperties.get(TIME_TO_LIVE).toString()); assertEquals(header.getPriority().toString(), expectedProperties.get(PRIORITY).toString()); return true; }
@Override public void sendBuffer(ByteBuf buffer, int deliveryCount) { checkBuffer(); int amqpDeliveryCount = deliveryCount - 1; // If the re-delivering the message then the header must be re-encoded // otherwise we want to write the original header if present. if (amqpDeliveryCount > 0) { Header header = getHeader(); if (header == null) { header = new Header(); header.setDurable(durable); } synchronized (header) { header.setDeliveryCount(UnsignedInteger.valueOf(amqpDeliveryCount)); TLSEncode.getEncoder().setByteBuffer(new NettyWritable(buffer)); TLSEncode.getEncoder().writeObject(header); TLSEncode.getEncoder().setByteBuffer((WritableBuffer) null); } } else if (headerEnds > 0) { buffer.writeBytes(data.duplicate().limit(headerEnds).byteBuffer()); } data.position(messagePaylodStart); buffer.writeBytes(data.byteBuffer()); data.position(0); }
private ReadableBuffer createCopyWithNewDeliveryCount(int deliveryCount) { assert deliveryCount > 1; final int amqpDeliveryCount = deliveryCount - 1; // If the re-delivering the message then the header must be re-encoded // (or created if not previously present). Any delivery annotations should // be skipped as well in the resulting buffer. final ByteBuf result = PooledByteBufAllocator.DEFAULT.heapBuffer(getEncodeSize()); Header header = getHeader(); if (header == null) { header = new Header(); header.setDurable(durable); } synchronized (header) { // Updates or adds a Header section with the correct delivery count header.setDeliveryCount(UnsignedInteger.valueOf(amqpDeliveryCount)); TLSEncode.getEncoder().setByteBuffer(new NettyWritable(result)); TLSEncode.getEncoder().writeObject(header); TLSEncode.getEncoder().setByteBuffer((WritableBuffer) null); } // This will skip any existing delivery annotations that might have been present // in the original message. data.position(messagePaylodStart); result.writeBytes(data.byteBuffer()); data.position(0); return new NettyReadable(result); }