【问题标题】:Read messages from different SQS queues in Mule从 Mule 中的不同 SQS 队列中读取消息
【发布时间】:2014-05-31 00:06:29
【问题描述】:

我有 2 个独立的 Amazon SQS 队列;队列和响应队列。

SQS 配置:

<sqs:config name="Amazon_SQS_Consumer" accessKey="XXX" secretKey="XXX" queueName="Queue" doc:name="Amazon SQS">
    <sqs:connection-pooling-profile maxActive="10" maxIdle="10" exhaustedAction="WHEN_EXHAUSTED_GROW" maxWait="12000" minEvictionMillis="60000" evictionCheckIntervalMillis="30000" initialisationPolicy="INITIALISE_ONE"/>
    <reconnect count="5" frequency="1000"/>
</sqs:config>   
<sqs:config name="Amazon_SQS_Response" accessKey="XXX" secretKey="XXX" queueName="ResponseQueue" doc:name="Amazon SQS">
    <sqs:connection-pooling-profile maxActive="100" maxIdle="10" exhaustedAction="WHEN_EXHAUSTED_GROW" maxWait="12000" minEvictionMillis="60000" evictionCheckIntervalMillis="30000" initialisationPolicy="INITIALISE_ONE"/>
    <reconnect count="5" frequency="1000"/>
</sqs:config> 

我通过以下方式从第一个队列(Queue)接收消息没有问题:

<flow name="consumer" doc:name="consumer">
    <sqs:receive-messages config-ref="Amazon_SQS_Consumer" preserveMessages="true" doc:name="Amazon SQS (Streaming)" visibilityTimeout="300" />
    <logger level="INFO" message="#[payload]" />
</flow>  

我还需要接收来自第二个队列(ResponseQueue)的消息:

<flow name="response" doc:name="response">
    <sqs:receive-messages config-ref="Amazon_SQS_Response" preserveMessages="true" doc:name="Amazon SQS (Streaming)" visibilityTimeout="300" />
    <logger level="INFO" message="#[payload]" />
</flow>

但是,每当添加第二个 sqs:receive-messages 时,我都会收到以下错误:

Exception in thread "Receiving Thread" java.lang.LinkageError: loader (instance of  org/mule/module/launcher/plugin/MulePluginsClassLoader): attempted  duplicate class definition for name: "com/amazonaws/services/sqs/QueueUrlHandler"

是否可以从同一个项目中的 2 个不同队列中读取消息?

我正在使用3.4.0 CE Mule 服务器运行时和2.4.4 Amazon SQS 连接器。 我需要继续使用这些版本。如果我切换到3.5.0 EE Mule Server Runtime,拥有多个sqs:receive-messages是没有问题的;它按预期工作。但是,它leads to another issue

【问题讨论】:

  • 我应该早点问:在 Studio、Mule 或两者上运行应用程序时,您是否遇到此异常?
  • @DavidDossot Just Studio。
  • 好的,人们已经报告了 Eclipse 上普通 Spring 项目的类似问题。清理项目并重建它似乎可以解决问题。
  • @DavidDossot 在使用 Mule Server Runtime 3.5.0 EE 和 SQS 2.5.0 时,我可以接收来自 2 个队列的消息,但不能像我需要的那样在 3.4.0 CE 和 SQS 2.4.4 中接收消息。 .
  • 嗯,是的,SQS 2.5.0 期望 Mule 3.5.0(请参阅:github.com/mulesoft/sqs-connector/blob/mule-module-sqs-2.5.0/…)。我想你必须自己从源代码构建一个3.5.0 CE 分发,这样你才能部署你的应用程序。

标签: mule mule-studio amazon-sqs


【解决方案1】:

您是否在两个 sqs:config 元素中使用相同的凭据?如果是,那么您只需要一个config 元素,然后在sqs:receive-messages 元素上指定队列名称。

<sqs:receive-messages queueName="Queue"
                      preserveMessages="true"
                      visibilityTimeout="300" />

参考用户指南:http://mulesoft.github.io/sqs-connector/2.5.0/mule/sqs-config.html#receive-messages

【讨论】:

  • 是的,凭证是一样的。你能给我一个sqs:receive-messages元素的例子吗?
  • 我尝试了您发布的代码,但它给出了以下消息:Required attribute config-ref is not defined in receive-messages 但是该指南指出config-ref 属性是可选的。
  • 是什么导致了这个错误?初创公司或工作室的骡子?如果后者,不管,Studio 会给出虚假的验证错误。或添加config-ref="Amazon_SQS_Consumer",如果这真的让你烦恼。
  • 工作室。即使使用config-ref,当添加queueName 属性时,我也会收到以下错误:Attribute 'queueName' is not allowed to appear in element 'sqs:receive-messages'。添加同样在指南中显示的queueUrl 属性时也是如此。
  • 完整性检查:您使用的是 SQS 连接器的 2.5.0 版本吗?如果是,那么这可能是一个值得向 MuleSoft 报告的错误...
猜你喜欢
  • 2015-01-18
  • 2016-09-02
  • 2019-11-07
  • 1970-01-01
  • 2021-03-11
  • 2014-10-10
  • 1970-01-01
  • 2018-10-06
  • 1970-01-01
相关资源
最近更新 更多