How to hook up a list of message driven adapters without actually writing each one out?

♀尐吖头ヾ 提交于 2019-11-28 12:16:35

问题


Hey so i need to listen in on like a dozen queues and more or less put all the incoming messages through the same processing flow. I have message driven channel adapters hooked up to each of these queues :

<jms:message-driven-channel-adapter id="101InstructionQueue1In" 
                                  channel="xmedInitiation1PrimaryChannel"                                    
                                  auto-startup="true"
                                  connection-factory="${XMED.1.PRIMARY}Factory"
                                  destination-name="${XMED.1.INITIATION}"/>

<jms:message-driven-channel-adapter id="101InstructionQueue2In" 
                                  channel="xmedInitiation2PrimaryChannel"                                    
                                  auto-startup="true"
                                  connection-factory="${XMED.2.PRIMARY}Factory"
                                  destination-name="${XMED.2.INITIATION}"/>


<jms:message-driven-channel-adapter id="201InstructionQueue1In" 
                                  channel="xmedInitiation1SecondaryChannel" 
                                  connection-factory="${XMED.1.SECONDARY}Factory"
                                  destination-name="${XMED.1.INITIATION}" 
                                  auto-startup="true"/>                                   

<jms:message-driven-channel-adapter id="201InstructionQueue2In" 
                                  channel="xmedInitiation2SecondaryChannel" 
                                  connection-factory="${XMED.2.SECONDARY}Factory"
                                  destination-name="${XMED.2.INITIATION}" 
                                  auto-startup="true"/>

... and so forth.

Once the message is received, i'm routing them all into the same channel. But i'll still need to know where the message came from, so before i actually route them, i'm kinda using a header enricher to add the queue name to the message.

<channel id="xmedInitiation1PrimaryChannel"  />

<header-enricher input-channel="xmedInitiation1PrimaryChannel" output-channel="initiationPreprocessingChannel" >
    <header name="INITIATOR" value="PRIMARY" />
    <header name="INITIATOR_NAME" value="${XMED.1.INITIATION}" />
</header-enricher>

<channel id="xmedInitiation1SecondaryChannel"  />

<header-enricher input-channel="xmedInitiation1SecondaryChannel" output-channel="initiationPreprocessingChannel" >
    <header name="INITIATOR" value="SECONDARY" />
    <header name="INITIATOR_NAME" value="${XMED.1.INITIATION}" />
</header-enricher>

Is there any way for me to like iterate over a list of queue names and create these adapters on the fly? Perhaps using the java config? Thanks in advance.

来源:https://stackoverflow.com/questions/33507361/how-to-hook-up-a-list-of-message-driven-adapters-without-actually-writing-each-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!