【问题标题】:pass message to producer through jms通过 jms 向生产者传递消息
【发布时间】:2018-11-06 22:59:54
【问题描述】:

如何通过spring集成将消息传递给生产者(定义为向activemq发送消息的方法)。 实际要求是,我需要将数据插入数据库,并将数据移动到 activemq 中的队列,这两个操作都需要并行发生。我该怎么做。

 <jms:message-driven-channel-adapter id="helloWorldJMSAdapater" destination="helloWorldJMSQueue" connection-factory="jmsConnectionFactory"
    channel="postChannel"  />  


<int:channel id="requestChannel" />
<int:channel id="outputChannel" />

<int-http:inbound-gateway request-channel="requestChannel"
reply-channel="outputChannel" supported-methods="GET" path="/register"
view-name="register">
<int-http:request-mapping />
</int-http:inbound-gateway>
<int-http:inbound-gateway request-channel="postChannel"
reply-channel="outputChannel" supported-methods="POST" path="/registerNew"
error-channel="errorChannel" view-name="login">
</int-http:inbound-gateway>

<int-jdbc:outbound-channel-adapter 
    query="insert into user_registration (USER_FSTNAME,USER_ADDRESS,USER_STATE,USER_CITY,USER_OCCUPATION,USER_EMAIL,USER_CONTACT,USER_PASSWORD) 
values (:fstName,:addrss,:state,:city,:occupation,:email,:contact,:password)"
    channel="postChannel" data-source="dataSource" id="sample" sql-parameter-source-factory="spelSource"  />


<int:service-activator  ref="userService" input-channel="requestChannel"
                             output-channel="outputChannel"  method="message"/>

<bean id="spelSource"
    class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
    <property name="parameterExpressions">
        <map>                                                                                                                           
            <entry key="fstName" value="payload[firstName]" />
            <entry key="lstName" value="payload[lastName]" />
            <entry key="addrss" value="payload[address]" />
            <entry key="state" value="payload[state]" />                
            <entry key="city" value="payload[city]" />
            <entry key="occupation" value="payload[occupation]" />
            <entry key="email" value="payload[email]"/>
            <entry key="contact" value="payload[contact]"/>
            <entry key="password" value="payload[password]"/>
        </map>
    </property>
</bean>

【问题讨论】:

    标签: jms spring-integration activemq


    【解决方案1】:

    使用&lt;publish-subscribe-channel/&gt; 并为两个端点订阅它。它们将默认串行执行,如果您将task-executor 添加到通道,则它们将并行执行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 2021-11-07
      • 2012-05-18
      相关资源
      最近更新 更多