2014-05-22 67 views
0

我有2個獨立的Amazon SQS隊列;隊列和響應隊列。從Mule中的不同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> 

我沒有問題通過從所述第一隊列(隊列)接收消息:

<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,I ge t出現以下錯誤:

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服務器運行時,多個sqs:receive-messages;沒有問題;它正如預期的那樣工作。但是,它leads to another issue

+0

我應該問前面:您在運行您的Studio應用程序的時候,就得到騾此異常,兩個? –

+0

@DavidDossot Just Studio。 – EmPak5

+0

好的,人們已經在Eclipse上報告了與純Spring項目相似的問題。清理項目並重建它似乎解決了這個問題。 –

回答

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

+0

是的,憑證是一樣的。你能給我一個'sqs:receive-messages'元素的例子嗎? – EmPak5

+0

當然,更新了我的答案。 –

+0

我嘗試了您發佈的代碼,但它提供了以下消息: '必需的屬性config-ref未在接收消息中定義 但是,該指南指出'config-ref'屬性是可選的。 – EmPak5