Question

I am using Jboss MQ in my application.

I am trying to handle redelivered message to the JMS Queue. Is there a way I can set some values in the original message I received in the consumer(First time I received the message) So that whenever the message is redelivered I can read the value and make some decisions.

Please let me know if the question is not clear, I can try to explain in detail.

Était-ce utile?

La solution

No, JMS does not work that way.

You interact with queues as a consumer (receives), producer (sends), or browser (peeks). There is no operation for putting back a changed message. If the consumer works in a transaction that gets rolled back, the message will appear to be "put back", but only so because it was waiting in the queue for the transaction's commit.

You could, in theory, create a producer for the same queue you obtained the message, modify it and send it "to yourself" (a message-drive bean?), but that would be a different message, only with similar contents. And it would get to the end of the queue. And it is certainly not recommended to do so.

It is better to persist message data (at least the parts that interest you) in a database and so detect if it's new or redelivered.

Autres conseils

The enterprise integration pattern Content Enricher (1) (2) might help you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top