headers.put(AmqpHeaders.DELIVERY_TAG, deliveryTag); String expiration = amqpMessageProperties.getExpiration(); if (StringUtils.hasText(expiration)) { headers.put(AmqpHeaders.EXPIRATION, expiration);
assertEquals(MessageDeliveryMode.NON_PERSISTENT, amqpProperties.getDeliveryMode()); assertEquals(1234L, amqpProperties.getDeliveryTag()); assertEquals("test.expiration", amqpProperties.getExpiration()); assertEquals(new Integer(42), amqpProperties.getMessageCount()); assertEquals("test.messageId", amqpProperties.getMessageId());
public MessageBuilderSupport<T> setExpirationIfAbsent(String expiration) { if (this.properties.getExpiration() == null) { this.properties.setExpiration(expiration); } return this; }
headers.put(AmqpHeaders.DELIVERY_TAG, deliveryTag); String expiration = amqpMessageProperties.getExpiration(); if (StringUtils.hasText(expiration)) { headers.put(AmqpHeaders.EXPIRATION, expiration);
headers.put(AmqpHeaders.DELIVERY_TAG, deliveryTag); String expiration = amqpMessageProperties.getExpiration(); if (StringUtils.hasText(expiration)) { headers.put(AmqpHeaders.EXPIRATION, expiration);
public static SpringAMQPMessage setBasicPropertiesToHeaders(SpringAMQPMessage msg, Message amqpMessage) { msg.getHeaders().put(MESSAGE_ID, amqpMessage.getMessageProperties().getMessageId()); byte[] correlationId = amqpMessage.getMessageProperties().getCorrelationId(); msg.getHeaders().put(CORRELATION_ID, correlationId == null ? null : new String(correlationId)); msg.getHeaders().put(CONTENT_ENCODING, amqpMessage.getMessageProperties().getContentEncoding()); msg.getHeaders().put(CONTENT_TYPE, amqpMessage.getMessageProperties().getContentType()); msg.getHeaders().put(EXPIRATION, amqpMessage.getMessageProperties().getExpiration()); msg.getHeaders().put(PRIORITY, amqpMessage.getMessageProperties().getPriority()); msg.getHeaders().put(REPLY_TO, amqpMessage.getMessageProperties().getReplyTo()); msg.getHeaders().put(DELIVERY_MODE, MessageDeliveryMode.toInt(amqpMessage.getMessageProperties().getDeliveryMode())); msg.getHeaders().put(TYPE, amqpMessage.getMessageProperties().getType()); return msg; }
public static SpringAMQPMessage setBasicPropertiesToHeaders(SpringAMQPMessage msg, Message amqpMessage) { msg.getHeaders().put(MESSAGE_ID, amqpMessage.getMessageProperties().getMessageId()); byte[] correlationId = amqpMessage.getMessageProperties().getCorrelationId(); msg.getHeaders().put(CORRELATION_ID, correlationId == null ? null : new String(correlationId)); msg.getHeaders().put(CONTENT_ENCODING, amqpMessage.getMessageProperties().getContentEncoding()); msg.getHeaders().put(CONTENT_TYPE, amqpMessage.getMessageProperties().getContentType()); msg.getHeaders().put(EXPIRATION, amqpMessage.getMessageProperties().getExpiration()); msg.getHeaders().put(PRIORITY, amqpMessage.getMessageProperties().getPriority()); msg.getHeaders().put(REPLY_TO, amqpMessage.getMessageProperties().getReplyTo()); msg.getHeaders().put(DELIVERY_MODE, MessageDeliveryMode.toInt(amqpMessage.getMessageProperties().getDeliveryMode())); msg.getHeaders().put(TYPE, amqpMessage.getMessageProperties().getType()); return msg; }
/** * {@inheritDoc} */ @Override public Message postProcessMessage(final Message message) throws AmqpException { if (message == null) { return message; } final MessageProperties messageProperties = message.getMessageProperties(); messageProperties.setTimestamp(this.properties.getTimestamp()); final byte[] correlationId = this.properties.getCorrelationId(); messageProperties.setCorrelationId(correlationId); messageProperties.setCorrelationIdString(this.properties.getCorrelationIdString()); messageProperties.setReplyTo(this.properties.getReplyTo()); messageProperties.setExpiration(this.properties.getExpiration()); return message; } }
/** * {@inheritDoc} */ @Override public Message postProcessMessage(final Message message) throws AmqpException { if (message == null) { return message; } final MessageProperties messageProperties = message.getMessageProperties(); messageProperties.setTimestamp(this.properties.getTimestamp()); final byte[] correlationId = this.properties.getCorrelationId(); messageProperties.setCorrelationId(correlationId); messageProperties.setCorrelationIdString(this.properties.getCorrelationIdString()); messageProperties.setReplyTo(this.properties.getReplyTo()); messageProperties.setExpiration(this.properties.getExpiration()); return message; } }
assertEquals(MessageDeliveryMode.NON_PERSISTENT, amqpProperties.getDeliveryMode()); assertEquals(1234L, amqpProperties.getDeliveryTag()); assertEquals("test.expiration", amqpProperties.getExpiration()); assertEquals(Integer.valueOf(42), amqpProperties.getMessageCount()); assertEquals("test.messageId", amqpProperties.getMessageId());
private void assertLower(MessageProperties properties) { assertEquals("appId", properties.getAppId()); assertEquals("clusterId", properties.getClusterId()); assertEquals("contentEncoding", properties.getContentEncoding()); assertEquals(MessageProperties.CONTENT_TYPE_TEXT_PLAIN, properties.getContentType()); assertEquals(1, properties.getContentLength()); assertEquals("correlationId", properties.getCorrelationId()); assertEquals(MessageDeliveryMode.NON_PERSISTENT, properties.getDeliveryMode()); assertEquals(2, properties.getDeliveryTag()); assertEquals("expiration", properties.getExpiration()); assertEquals("bar", properties.getHeaders().get("foo")); assertEquals("fiz", properties.getHeaders().get("qux")); assertEquals("fuz", properties.getHeaders().get("baz")); assertEquals(Integer.valueOf(3), properties.getMessageCount()); assertEquals("messageId", properties.getMessageId()); assertEquals(Integer.valueOf(4), properties.getPriority()); assertEquals("receivedExchange", properties.getReceivedExchange()); assertEquals("receivedRoutingKey", properties.getReceivedRoutingKey()); assertTrue(properties.getRedelivered()); assertTrue(properties.getTimestamp().getTime() > 0); assertEquals("type", properties.getType()); assertEquals("userId", properties.getUserId()); }
@Override public BasicProperties fromMessageProperties(final MessageProperties source, final String charset) { BasicProperties.Builder target = new BasicProperties.Builder(); target.headers(this.convertHeadersIfNecessary(source.getHeaders())) .timestamp(source.getTimestamp()) .messageId(source.getMessageId()) .userId(source.getUserId()) .appId(source.getAppId()) .clusterId(source.getClusterId()) .type(source.getType()); MessageDeliveryMode deliveryMode = source.getDeliveryMode(); if (deliveryMode != null) { target.deliveryMode(MessageDeliveryMode.toInt(deliveryMode)); } target.expiration(source.getExpiration()) .priority(source.getPriority()) .contentType(source.getContentType()) .contentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (StringUtils.hasText(correlationId)) { target.correlationId(correlationId); } String replyTo = source.getReplyTo(); if (replyTo != null) { target.replyTo(replyTo); } return target.build(); }
@Override public BasicProperties fromMessageProperties(final MessageProperties source, final String charset) { BasicProperties.Builder target = new BasicProperties.Builder(); target.headers(this.convertHeadersIfNecessary(source.getHeaders())) .timestamp(source.getTimestamp()) .messageId(source.getMessageId()) .userId(source.getUserId()) .appId(source.getAppId()) .clusterId(source.getClusterId()) .type(source.getType()); MessageDeliveryMode deliveryMode = source.getDeliveryMode(); if (deliveryMode != null) { target.deliveryMode(MessageDeliveryMode.toInt(deliveryMode)); } target.expiration(source.getExpiration()) .priority(source.getPriority()) .contentType(source.getContentType()) .contentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (StringUtils.hasText(correlationId)) { target.correlationId(correlationId); } String replyTo = source.getReplyTo(); if (replyTo != null) { target.replyTo(replyTo); } return target.build(); }
private void assertUpper(MessageProperties properties) { assertEquals("APPID", properties.getAppId()); assertEquals("CLUSTERID", properties.getClusterId()); assertEquals("CONTENTENCODING", properties.getContentEncoding()); assertEquals(MessageProperties.CONTENT_TYPE_BYTES, properties.getContentType()); assertEquals(10, properties.getContentLength()); assertEquals("CORRELATIONID", properties.getCorrelationId()); assertEquals(MessageDeliveryMode.PERSISTENT, properties.getDeliveryMode()); assertEquals(20, properties.getDeliveryTag()); assertEquals("EXPIRATION", properties.getExpiration()); assertEquals("BAR", properties.getHeaders().get("foo")); assertEquals("FIZ", properties.getHeaders().get("qux")); assertEquals("FUZ", properties.getHeaders().get("baz")); assertEquals(Integer.valueOf(30), properties.getMessageCount()); assertEquals("MESSAGEID", properties.getMessageId()); assertEquals(Integer.valueOf(40), properties.getPriority()); assertEquals("RECEIVEDEXCHANGE", properties.getReceivedExchange()); assertEquals("RECEIVEDROUTINGKEY", properties.getReceivedRoutingKey()); assertFalse(properties.getRedelivered()); assertTrue(properties.getTimestamp().getTime() == 0); assertEquals("TYPE", properties.getType()); assertEquals("USERID", properties.getUserId()); }