我有两个独立的Amazon SQS队列;队列和ResponseQueue。
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>
通过以下方式从第一个队列(队列)接收消息没有问题:
<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 Server Runtime和2.4.4
Amazon SQS Connector。 我需要保留这些版本。如果我切换到3.5.0 EE
Mule Server Runtime,则有多个sqs:receive-messages
没有问题;它按预期工作。但是,leads to another issue。
答案 0 :(得分:0)
您是否在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