Friday, November 25, 2011

OSB and JMS message acknowledgement

I am torturing myself over this problem:

I have a JMS message that I want to FTP:

JMSQUEUE -> JMS_PS (validation, tranformation) -> FTP_BS

If FTP_BS fails, I want to retry (redeliver) the message later

If the validation/transformation fail, I don't want to retry the message.

In both cases, I want to fail the transaction, so that the appropriate statistics are shown at monitoring level.

It turns out that you cannot acknowledge a JMS message in OSB independently from the result of the transaction. Here it says: OSB proxies always work in AUTO_ACKNOWLEDGE mode:
Tx rollback - > JMS message NOT ack'ed
Tx commit - > JMS message ack'ed

So, if you want to consume immediately the JMS message without retries, your only option is to "Reply with Success" in the error handler.

If the fault happened in the FTP_BS, at monitoring level (Operations/Service Health) you will find the error reported.
If the fault happened in the JMS_PS and you replied with success, the error will not appear in the Monitoring page.

A possible workaround could be:
never redeliver the JMS message, always acknowledge it, and upon FTP failure send the message to a RedeliveryQueue, from which it will be resubmitted in future (WebLogic supports delivery in future) to the main JMSQUEUE. Obviously this sucks.

Another workaround is to introduce a second JMSQUEUE2:
JMSQUEUE -> JMS_PS (validation, tranformation) -> JMSQUEUE2 -> FTP_BS

so that you separate validation/transformation from the FTPing.
This also sucks.

I cannot think of any other workaround.

Obviously this is not ideal, I hate committing a transaction when in reality we had a validation error, only for the sake of consuming immediately the JMS message.
I wish we had more control on the JMS message.

Redelivery at FTP_BS level (retries) is not an option, because they will keep a transaction open for a long time.

No comments: