1

I have a JDBC connector as an inbound endpoint fetching the correct result set in my database.
I've noticed that each row is returned as a new message.
My question: How do I combine all rows into one message? Is the aggregator the only option?
using Mule version 3.3.1 CE

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.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/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd "    version="CE-3.3.1">




<context:property-placeholder location="configuration.properties" />
<spring:beans>
    <spring:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <spring:property name="driverClassName" value="mydriver"/>
        <spring:property name="url" value="${jdbc.url}"/>
        <spring:property name="username" value="${jdbc.user}"/>
        <spring:property name="password" value="${jdbc.password}"/>
    </spring:bean>
</spring:beans>

<jdbc:connector name="AS400" dataSource-ref="dataSource"
    validateConnections="true" 
    queryTimeout="-1" 
    pollingFrequency="5000"
    transactionPerMessage="false"
    doc:name="Database">
    <jdbc:query key="selectNums" value="select someColumns from someTable"/>

</jdbc:connector>


<flow name="databaseFlow" doc:name="databaseFlow" processingStrategy="synchronous">


    <jdbc:inbound-endpoint 

        queryKey="selectNums" queryTimeout="-1" connector-ref="AS400"
        doc:name="select-record" pollingFrequency="45000">
    </jdbc:inbound-endpoint>


    <logger message="msg to send:  #[map-payload:col1]" level="INFO" doc:name="Logger" />
    <logger message="phone number: #[map-payload:col2]" level="INFO" doc:name="Logger" />


    <custom-transformer class="myTransformer" doc:name="Java"/>

</flow>

4

1 回答 1

2

要接收包含所有行的单个消息,请执行以下任一操作:

  1. 在 JDBC 入站端点中启动事务,<jdbc:transaction action="ALWAYS_BEGIN"/>并在 JDBC 端点上设置transactionPerMessage="false"

    或者

  2. 在流程开始时轮询 JDBC 出站端点:

    <poll frequency="${polling.frequency}">
        <jdbc:outbound-endpoint queryKey="..."
            exchange-pattern="request-response" queryTimeout="30000" />
    </poll>
    

在这两种情况下,您都会收到一条带有List<Map<String, Object>>有效负载的消息。

于 2013-06-05T16:39:47.990 回答