【问题标题】:Can we Use Idempotent Receiver against Jms message with ActiveMq我们可以对带有 ActiveMq 的 Jms 消息使用幂等接收器吗
【发布时间】:2013-08-20 20:47:33
【问题描述】:

我正在使用 WSO2Esb 和 WSO2DSS 在数据库中插入读数我的插入工作正常 当我从移动端获取请求读取时,我需要 200 和唯一值的响应 插入后有时连接失败意味着插入结束但客户端在这种情况下没有得到响应移动端客户端再次发送请求所以我的代理再次将此请求发送到数据库。所以我的数据库为每 2 或 3 个读数存储重复值这对客户完全不公平,因为我找到了一个小解决方案 使用幂等服务我们可以找到解决方案吗

<!-- The example shows WSO2 ESB acting as an Idempotent Receiver -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <proxy name="IdempotencyReceivingProxy">
        <target>
            <inSequence>
                <log level="full"/>
                <!-- Store all messages in an Jmsmemory message store -->
                <store messageStore="MyStore"/>
            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>           
    </proxy>
    <!-- Further mediation of messages are done in this sequence -->
    <sequence name="next_seq">
        <send>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
        </send>
    </sequence>
    <messageStore name="MyStore"/>
    <!-- Resequencing Processor takes the next sequence number and hand over to "next_seq" and preserve Idempotency -->
    <messageProcessor
            class="org.apache.synapse.message.processors.resequence.ResequencingProcessor"
            name="ResequencingProcessor" messageStore="MyStore"> 
        <parameter name="interval">2000</parameter>
        <!-- Takes the sequence number using Xpath -->
        <parameter name="seqNumXpath" xmlns:m0="http://services.samples" expression="substring-after(//m0:placeOrder/m0:order/m0:symbol,'-')"/>
        <parameter name="nextEsbSequence">next_seq</parameter>
        <parameter name="deleteDuplicateMessages">true</parameter> 
    </messageProcessor>
</definitions>

为此,我点击了此链接http://docs.wso2.org/wiki/display/IntegrationPatterns/Idempotent+Receiver 是否适合我的要求

【问题讨论】:

    标签: wso2 wso2esb wso2dss


    【解决方案1】:

    我认为这不符合您的要求。重排序处理器所做的是,根据seqNumXpath 属性中的数字对消息进行排序。因此消息应该包含一个数字,并且您应该使用 xpath 表达式获取这个数字。当deleteDuplicateMessages参数设置为true时,会删除与seqNumXpath参数获得的序列号相同的重复消息。

    在您的情况下,您可以使用store and forward 方案来防止客户端必须发送多个请求。在您的代理服务中将 FORCE_SC_ACCEPTED 属性设置为 true 以始终向客户端返回 202 响应。然后消息将存储在 msg 存储中,并使用消息处理器进行转发。

    http://docs.wso2.org/wiki/display/ESB470/Store+and+Forward+Using+JMS+Message+Stores http://wso2.com/library/articles/2011/10/implementing-store-forward-messaging-patterns-wso2esb-part-1

    【讨论】:

    • 但是在处理完每条消息后,如果再有一条消息到达此消息进程,消息处理器将自动停用,它将如何处理
    • 只有在消息发送失败时消息处理器才会停用。即即使在最大数量之后。重试尝试,它无法将消息发送到后端。如果 msg 处理器被停用,您将不得不重新激活它。
    • 如果所有消息都已成功传递,则不会停用。它将保持活动状态,并定期查看消息存储以查看是否有任何消息可用。
    • 感谢重播我会实际做的,然后回复你
    【解决方案2】:

    Apache Camel 有一个幂等消费者http://camel.apache.org/idempotent-consumer.html,它使用一个 IdempotentRepository 来查看它之前是否见过;如果有,则使用该消息;如果不是,则处理消息并将 ID 添加到存储库。看看http://camel.apache.org/sql-component.html,尤其是“使用基于 JDBC 的幂等存储库”部分。这正是我们所需要的。因为在我们的例子中,重复消息甚至可以在几天后到达(离线客户端,例如移动设备),但每条消息都有一个 UUID 字段,可用于检测重复消息。

    在 wso2esb 中是否有类似的实现?如果是,任何指向文档的指针?如果没有,我们在使用 wso2esb 时有什么替代方法来获得这种行为?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-16
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      • 1970-01-01
      • 2010-09-19
      • 2014-01-29
      • 1970-01-01
      相关资源
      最近更新 更多