如何获得Mule作为单个事务从JDBC查询返回多行? [英] How do I get a Mule to return multiple rows from a JDBC query as a single transaction?

查看:46
本文介绍了如何获得Mule作为单个事务从JDBC查询返回多行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Oracle表中有100行,我想接收一封电子邮件,其中正文为100行,而是接收100封电子邮件,每行一封...我以为transactionPerMessage可以做到(工具提示说,如果为false,则整个结果集将只有一个事务"),但是无论我将其设置为true还是false都没关系.

If I have 100 rows in an Oracle table I'd like to receive one email with 100 rows in the body, instead I receive 100 emails, one for each row... I thought the transactionPerMessage would do it (tooltip says, "if false, there will be a single transaction for the entire resultset") but it doesn't make a difference whether I set it to true or false.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd 
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd ">
    <jdbc:oracle-data-source name="Oracle_Data_Source" user="test" password="test" url="jdbc:oracle:thin:@//ora:1530/TEST.EXAMPLE.COM" transactionIsolation="UNSPECIFIED" doc:name="Oracle Data Source"/>
    <jdbc:connector name="Database" dataSource-ref="Oracle_Data_Source" validateConnections="true" transactionPerMessage="false" queryTimeout="-1" pollingFrequency="5000" doc:name="Database"/>
    <flow name="Ross_invoice_Workflow2Flow1" doc:name="Ross_invoice_Workflow2Flow1">
        <jdbc:inbound-endpoint queryKey="GetUnprocessedInvoices" queryTimeout="-1" pollingFrequency="1000" connector-ref="Database" doc:name="Database">
            <jdbc:query key="GetUnprocessedInvoices" value="SELECT        INVOICE_NUMBER FROM            FIN.LHF_INVOICE_WORKFLOW&#13;&#10;WHERE        (STATUS_FLAG = 'N')"/>
        </jdbc:inbound-endpoint>
        <echo-component doc:name="Echo"/>
        <smtp:outbound-endpoint host="mail.example.com" to="test@example.com" from="mule@example.com" subject="invoice test" responseTimeout="10000" doc:name="SMTP"/>
    </flow>
</mule>

推荐答案

让Mule每行创建一条消息,如其当前所做的那样,然后使用聚合器将消息按100分组.您还必须配置超时时间最后一个组的聚合器可能不会达到100(除非您的记录数始终是100的倍数).

Let Mule create one message per row as it currently does, then use an aggregator to group messages by 100. You will also have to configure the time-out on the aggregator for the last group that will probably not reach 100 (unless your number of records is always a multiple of 100).

这篇关于如何获得Mule作为单个事务从JDBC查询返回多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆