简体   繁体   English

Spring Integration JDBC 入站适配器

[英]Spring Integration JDBC inbound adapter

I have to read the rows from database and pass on the rows to service activator我必须从数据库中读取行并将行传递给服务激活器
with the help of rowmapper send mails with our own framework which we are able to achieve, The problem is we need to update the respective row's column with dynamic status and errorstackstrace depending success or failure in service activator method.在 rowmapper 的帮助下,我们能够实现自己的框架发送邮件,问题是我们需要根据服务激活器方法的成功或失败,使用动态状态和 errorstackstrace 更新相应行的列。

<int-jdbc:inbound-channel-adapter id="emailReqestChannel"
        query="select * from email_requests where email_request_status = 'NEW'"
        update="update email_requests set email_request_status = 'SUCCESS' where email_request_id in (:email)"
        max-rows-per-poll="10"
        data-source="dataSource" row-mapper="emailRequestRowMapper">
    <int:poller fixed-rate="1000">
        <int:transactional />
    </int:poller>
</int-jdbc:inbound-channel-adapter>
<int:service-activator input-channel="emailReqestChannel" ref="emailRequestMessageHandler" />
<bean id="jdbcMessageHandler"
        class="com.company.selfservice.jdbc.handler.JdbcMessageHandler" />
<bean id="emailRequestMessageHandler"
        class="com.company.selfservice.jdbc.handler.EmailRequestMessageHandler" />
<bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>
<int:poller default="true" fixed-rate="10000"/>
<int:channel id="dataChannel">
    <int:queue />
</int:channel>
<int:channel id="emailReqestChannel">
    <int:queue />
</int:channel>
<bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.gjt.mm.mysql.Driver" />
    <property name="url" value="${database.connection_url}" />
    <property name="username" value="${database.user}" />
    <property name="password" value="${database.password}" />
</bean>
<bean id="emailRequestRowMapper"
        class="com.company.selfservice.jdbc.handler.EmailRequestRowMapper" />

如果故事是关于dynamic status and errorstackstrace depending success or failure ,那么您不应该在<int-jdbc:inbound-channel-adapter>使用update ,而应该真正考虑使用<int-jdbc:outpbund-channel-adapter> ,您可以在那里解决针对请求消息的查询参数: https : <int-jdbc:outpbund-channel-adapter> -适配器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM