首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过jms将消息传递给生产者。

通过jms将消息传递给生产者。
EN

Stack Overflow用户
提问于 2018-05-28 10:59:53
回答 1查看 64关注 0票数 0

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

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-28 14:48:17

使用一个<publish-subscribe-channel/>并订阅它的两个端点。默认情况下,它们将被串行执行,如果将task-executor添加到通道中,则它们将并行执行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50564860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档