在JMS / ActiveMQ上避免重复的消息 [英] Avoiding duplicated messages on JMS/ActiveMQ

查看:2700
本文介绍了在JMS / ActiveMQ上避免重复的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图手动定义JMSMessageID(message.setJMSMessageID(uniqueid)) ,但服务器忽略此修改,并传递内置生成的JMSMessageID的消息。



根据规范,我没有找到关于如何重复数据消除消息的引用。 p>

在HornetQ中,为了处理这个问题,我们需要在邮件定义上声明HQ特定的属性org.hornetq.core.message.impl.HDR_DUPLICATE_DETECTION_ID。



ie:

 消息jmsMessage = session.createMessage(); 
String myUniqueID =这是我唯一的id; //可以使用UUID这个
message.setStringProperty(HDR_DUPLICATE_DETECTION_ID.toString(),myUniqueID);

有人知道ActiveMQ是否有类似的解决方案?

解决方案

您应该看看Apache Camel,它提供了一个能够与任何JMS提供程序配合使用的Idempotent消费者组件,请参阅: http://camel.apache.org/idempotent-consumer.html



使用结合ActiveMQ组件使得使用JMS非常简单,请参阅:
http:// camel .apache.org / activemq.html


There's a way to suppress duplicated messages on a queue defined on ActiveMQ server?

I tried to define manually JMSMessageID, (message.setJMSMessageID("uniqueid")), but server ignores this modification and deliver a message with built-in generated JMSMessageID.

By specification, I didn't found a reference about how to deduplicate messages.

In HornetQ, to deal with this problem, we need to declare the HQ specific property org.hornetq.core.message.impl.HDR_DUPLICATE_DETECTION_ID on message definition.

i.e.:

Message jmsMessage = session.createMessage();
String myUniqueID = "This is my unique id"; // Could use a UUID for this
message.setStringProperty(HDR_DUPLICATE_DETECTION_ID.toString(), myUniqueID);

Somebody knows if there's a similar solution for ActiveMQ?

解决方案

You should look at Apache Camel, it provides an Idempotent consumer component that would work with any JMS provider, see: http://camel.apache.org/idempotent-consumer.html

Using that in combination with the ActiveMQ component makes using JMS quite simple, see: http://camel.apache.org/activemq.html

这篇关于在JMS / ActiveMQ上避免重复的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆