public Message postProcessMessage(Message message) throws AmqpException { message.getMessageProperties().setDelay((int) delay); return message; } });
protected void addDelayProperty(Message<?> message, org.springframework.amqp.core.Message amqpMessage) { if (this.delayGenerator != null) { amqpMessage.getMessageProperties().setDelay(this.delayGenerator.processMessage(message)); } }
amqpMessageProperties.setDelay(delay);
protected void addDelayProperty(Message<?> message, org.springframework.amqp.core.Message amqpMessage) { if (this.delayGenerator != null) { amqpMessage.getMessageProperties().setDelay(this.delayGenerator.processMessage(message)); } }
@Test public void testDelayHeader() { MessageProperties properties = new MessageProperties(); Integer delay = 100; properties.setDelay(delay); assertEquals(delay, properties.getHeaders().get(MessageProperties.X_DELAY)); properties.setDelay(null); assertFalse(properties.getHeaders().containsKey(MessageProperties.X_DELAY)); }
@Override public void send (String aRoutingKey, Object aMessage) { Assert.notNull(aRoutingKey,"routing key can't be null"); amqpTemplate.convertAndSend(determineExchange(aRoutingKey),determineRoutingKey(aRoutingKey),aMessage, (m) -> { if(aMessage instanceof Retryable) { Retryable r = (Retryable) aMessage; m.getMessageProperties().setDelay((int)r.getRetryDelayMillis()); } if(aMessage instanceof Prioritizable) { Prioritizable p = (Prioritizable) aMessage; m.getMessageProperties().setPriority(p.getPriority()); } return m; }); }
amqpMessageProperties.setDelay(delay);
amqpMessageProperties.setDelay(delay);
template.setReceiveTimeout(10000); template.convertAndSend(exchangeName, queue.getName(), "foo", message -> { message.getMessageProperties().setDelay(1000); return message; }); MessageProperties properties = new MessageProperties(); properties.setDelay(500); template.send(exchangeName, queue.getName(), MessageBuilder.withBody("foo".getBytes()).andProperties(properties).build());