简体   繁体   English

JMS 消息重新传递到队列

[英]JMS message to redelivery to queue

I am using Jboss MQ in my application.我在我的应用程序中使用 Jboss MQ。

I am trying to handle redelivered message to the JMS Queue.我正在尝试处理重新传递到 JMS 队列的消息。 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.如果问题不清楚,请告诉我,我可以尝试详细解释。

No, JMS does not work that way.不,JMS 不能那样工作。

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.理论上,您可以为获取消息的同一个队列创建一个生产者,对其进行修改并将其“发送给您自己”(消息驱动 bean?),但这将是一个不同的消息,仅具有相似的内容。 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.最好将消息数据(至少是您感兴趣的部分)保存在数据库中,以便检测它是新的还是重新传递的。

The enterprise integration pattern Content Enricher ( 1 ) ( 2 ) might help you.企业集成模式 Content Enricher ( 1 ) ( 2 ) 可能会对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM