I've a service-activator
bean which has a method that gets a List of SI messages as input.
The method iterates through the list, gets each SI message from it, gets the payload from SI message and then sends the payload to a MQ (I'm not using any outbound channel adapters to send message to MQ; I'm just using plain vanilla JMS APIs).
I've configured a <request-handler-advice-chain>
onto this service-activator with class as RequestHandlerRetryAdvice
and mapped it to a retryTemplate
that is configured for SimpleRetry
policy.
In the service-activator
method I've put in a logic to add a header (say MESSAGE_SENT_STATUS
) with a value "SUCCESS" to each SI message if the payload is sent successfully to MQ.
EDIT1 [[ This is how my logic looks like:
public void doSendMessage(List<Message<?> inputMsgs) {
for(Message<?> msg : inputMsgs) {
if(msg.getHeaders().get("MESSAGE_SENT_STATUS") != null)
continue;
Object payload = msg.getPayload();
//some code logic to send 'payload' to a MQ goes here
msg.getHeaders().put("MESSAGE_SENT_STATUS","SUCCESS");
return;
}
}
//I've just typed in the code logic; so pls ignore any typos for syntax errors.
]]
I would like to know if this header will be retained on the message in case there is an exception and the service-activator
method is retried ?
So, as an example, say my List contains 3 SI messages.
The first and second SI message were deposited successfully on MQ (which in-turn means that those messages were enriched with a header MESSAGE_SENT_STATUS
with value as "SUCCESS") but there was an exception while trying to deposit the 3rd SI message.
IF I add a code in the iteration of List to check for the header MESSAGE_SENT_STATUS
and if its value is "SUCCESS" then skip that iteration (basically by placing a continue
) THEN will it ensure that only the 3rd message will be retired on MQ ?
OR this is a case of Stateless retry and all the messages will be pushed to MQ (since MESSAGE_SENT_STATUS
is not present on them) ?
I was also referring the manual to see if I can leverage ExpressionEvaluatingRequestHandlerAdvice
for my above use case but couldn't get a hold of it. Is it possible to leverage this advice for my use case ? If yes, can you pls suggest how ?
Appreciate a response !
Many thanks and Best Regards