Hi I want to implement the function like sending sqs messages with a specific delivery delay using java and JmsTemplate. Actually, I finished the implementation of sending messages without delay. like this:
@Override
public boolean sendMessage(String queueName, String message) throws EventBrokerException {
final String messageWithTransactionGuid = addTransactionGuidToMessage(message);
jmsTemplate.convertAndSend(queueName, messageWithTransactionGuid);
return isSuccess;
}
I read some articles, Maybe I need to do somthing like this???
jmsTemplate.convertAndSend(queueName, messageWithTransactionGuid, new MessagePostProcessor() {
@Override
public Message postProcessMessage(Message message) throws JMSException {
message.setIntProperty(/*specify field name and delay seconds*/);
return message;
}
});
But I didn't see any examples, I read the sourcecode and didn't find out what to specify, can anybody help?
So what I did is a simple way:
private Boolean doSendMessage(String queueName, String message, long deliveryDelay){
jmsTemplate.setDeliveryDelay(deliveryDelay);
jmsTemplate.convertAndSend(queueName, message);
jmsTemplate.setDeliveryDelay(DEFAULT_MESSAGE_DELIVERY_DELAY);
return isSuccess;
}
Here DEFAULT_MESSAGE_DELIVERY_DELAY
is -1.
I injected jsmTemplate, and setDeliveryDelay and resetDeliveryDelay