messageProperties); messageProperties.setReplyTo(null);
public MessageBuilderSupport<T> setReplyTo(String replyTo) { this.properties.setReplyTo(replyTo); return this; }
amqpMessageProperties.setReplyTo(replyTo);
amqpProperties.setContentEncoding("test.contentEncoding"); amqpProperties.setContentLength(99L); amqpProperties.setReplyTo("oleg"); amqpProperties.setContentType("test.contentType"); amqpProperties.setHeader("foo", "foo");
amqpProperties.setReceivedRoutingKey("test.receivedRoutingKey"); amqpProperties.setRedelivered(true); amqpProperties.setReplyTo("test.replyTo"); Date testTimestamp = new Date(); amqpProperties.setTimestamp(testTimestamp);
public MessageBuilderSupport<T> setReplyToIfAbsent(String replyTo) { if (this.properties.getReplyTo() == null) { this.properties.setReplyTo(replyTo); } return this; }
public MessageBuilderSupport<T> copyProperties(MessageProperties properties) { BeanUtils.copyProperties(properties, this.properties); // Special handling of replyTo needed because the format depends on how it was set this.properties.setReplyTo(properties.getReplyTo()); this.properties.getHeaders().putAll(properties.getHeaders()); return this; }
private String getOrSetCorrelationIdAndSetReplyTo(Message message) { String correlationId; MessageProperties messageProperties = message.getMessageProperties(); Assert.notNull(messageProperties, "the message properties cannot be null"); String currentCorrelationId = messageProperties.getCorrelationId(); if (!StringUtils.hasText(currentCorrelationId)) { correlationId = UUID.randomUUID().toString(); messageProperties.setCorrelationId(correlationId); Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null"); } else { correlationId = currentCorrelationId; } messageProperties.setReplyTo(this.replyAddress); return correlationId; }
private String getOrSetCorrelationIdAndSetReplyTo(Message message) { String correlationId; MessageProperties messageProperties = message.getMessageProperties(); Assert.notNull(messageProperties, "the message properties cannot be null"); String currentCorrelationId = messageProperties.getCorrelationId(); if (!StringUtils.hasText(currentCorrelationId)) { correlationId = UUID.randomUUID().toString(); messageProperties.setCorrelationId(correlationId); Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null"); } else { correlationId = currentCorrelationId; } messageProperties.setReplyTo(this.replyAddress); return correlationId; }
/** * This makes a <code>MessageProperties</code> with the specified properties. * * @param timestamp The timestamp. * @param correlationId The correlation identifier. * @param replyTo The reply to destination. * @since 1.0 */ public static MessageProperties makeMessageProperties(final Date timestamp, final String correlationId, final String replyTo) { final MessageProperties messageProperties = new MessageProperties(); messageProperties.setTimestamp(timestamp); messageProperties.setCorrelationIdString(correlationId); if (correlationId != null) { try { messageProperties.setCorrelationId(correlationId.getBytes("UTF-8")); } catch (UnsupportedEncodingException exception) { } } messageProperties.setReplyTo(replyTo); return messageProperties; }
private void sendDirect(Channel channel, String exchange, String routingKey, Message message, CorrelationData correlationData) { message.getMessageProperties().setReplyTo(Address.AMQ_RABBITMQ_REPLY_TO); try { if (channel instanceof PublisherCallbackChannel) { this.template.addListener(channel); } this.template.doSend(channel, exchange, routingKey, message, this.template.isMandatoryFor(message), correlationData); } catch (Exception e) { throw new AmqpException("Failed to send request", e); } }
private void sendDirect(Channel channel, String exchange, String routingKey, Message message, CorrelationData correlationData) { message.getMessageProperties().setReplyTo(Address.AMQ_RABBITMQ_REPLY_TO); try { if (channel instanceof PublisherCallbackChannel) { this.template.addListener(channel); } this.template.doSend(channel, exchange, routingKey, message, this.template.isMandatoryFor(message), correlationData); } catch (Exception e) { throw new AmqpException("Failed to send request", e); } }
private void restoreProperties(Message message, PendingReply pendingReply) { if (!this.userCorrelationId) { // Restore the inbound correlation data String savedCorrelation = pendingReply.getSavedCorrelation(); if (this.correlationKey == null) { message.getMessageProperties().setCorrelationId(savedCorrelation); } else { if (savedCorrelation != null) { message.getMessageProperties().setHeader(this.correlationKey, savedCorrelation); } else { message.getMessageProperties().getHeaders().remove(this.correlationKey); } } } // Restore any inbound replyTo String savedReplyTo = pendingReply.getSavedReplyTo(); message.getMessageProperties().setReplyTo(savedReplyTo); if (logger.isDebugEnabled() && savedReplyTo != null) { logger.debug("Restored replyTo to " + savedReplyTo); } }
private void restoreProperties(Message message, PendingReply pendingReply) { if (!this.userCorrelationId) { // Restore the inbound correlation data String savedCorrelation = pendingReply.getSavedCorrelation(); if (this.correlationKey == null) { message.getMessageProperties().setCorrelationId(savedCorrelation); } else { if (savedCorrelation != null) { message.getMessageProperties().setHeader(this.correlationKey, savedCorrelation); } else { message.getMessageProperties().getHeaders().remove(this.correlationKey); } } } // Restore any inbound replyTo String savedReplyTo = pendingReply.getSavedReplyTo(); message.getMessageProperties().setReplyTo(savedReplyTo); if (logger.isDebugEnabled() && savedReplyTo != null) { logger.debug("Restored replyTo to " + savedReplyTo); } }
private Message getFooMessage() { this.fooMessage.getMessageProperties().setCorrelationId(null); this.fooMessage.getMessageProperties().setReplyTo(null); return this.fooMessage; }
return null; }); this.messageProperties.setReplyTo("foo/bar"); Channel channel = mock(Channel.class); RuntimeException ex = new RuntimeException();
@Test public void testReplyTo() throws Exception { MessageProperties properties = new MessageProperties(); properties.setReplyTo("foo/bar"); assertEquals("bar", properties.getReplyToAddress().getRoutingKey()); }
/** * {@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; } }
@Test public void testDirectReplyTo() { String replyTo = Address.AMQ_RABBITMQ_REPLY_TO + ".ab/cd/ef"; MessageProperties props = new MessageProperties(); props.setReplyTo(replyTo); Message message = new Message("foo".getBytes(), props); Address address = message.getMessageProperties().getReplyToAddress(); assertEquals("", address.getExchangeName()); assertEquals(replyTo, address.getRoutingKey()); address = props.getReplyToAddress(); assertEquals("", address.getExchangeName()); assertEquals(replyTo, address.getRoutingKey()); }