Uploaded image for project: 'Mule'
  1. Mule
  2. MULE-5860

Inserting <collection-splitter /><collection-aggregator /> into a flow produces unexpected results

    Details

    • User impact:
      High
    • Configuration:
      Hide

      <?xml version="1.0" encoding="UTF-8"?>
      <mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
      xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
      xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
      xsi:schemaLocation="
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.2/mule-stdio.xsd
      http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd
      http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
      ">

      <quartz:connector name="quartzConnector">
      <quartz:factory-property key="org.quartz.scheduler.instanceName"
      value="quartzInstance" />
      <quartz:factory-property key="org.quartz.threadPool.class"
      value="org.quartz.simpl.SimpleThreadPool" />
      <quartz:factory-property key="org.quartz.threadPool.threadCount"
      value="3" />
      <quartz:factory-property key="org.quartz.scheduler.rmi.proxy"
      value="false" />
      <quartz:factory-property key="org.quartz.scheduler.rmi.export"
      value="false" />
      <quartz:factory-property key="org.quartz.jobStore.class"
      value="org.quartz.simpl.RAMJobStore" />
      </quartz:connector>

      <flow name="test">
      <quartz:inbound-endpoint name="timeTrigger"
      jobName="myJob" repeatInterval="6000" connector-ref="quartzConnector">
      <quartz:event-generator-job />
      </quartz:inbound-endpoint>

      <scripting:transformer>
      <scripting:script engine="groovy">
      <scripting:text>
      def foo = [1, 2, 3, 4, 5]
      message.setPayload(foo)
      return message
      </scripting:text>
      </scripting:script>
      </scripting:transformer>

      <collection-splitter />

      <collection-aggregator />

      <scripting:transformer>
      <scripting:script engine="groovy">
      <scripting:text>
      def foo = []
      for (def i = 0; i < payload.size(); i++)

      { def element = payload.get(i) foo.add(element * element) }

      println "\ntransformed: " + foo
      return foo
      </scripting:text>
      </scripting:script>
      </scripting:transformer>

      <stdio:outbound-endpoint system="OUT" />
      </flow>
      </mule>

      Show
      <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.2/mule-stdio.xsd http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd "> <quartz:connector name="quartzConnector"> <quartz:factory-property key="org.quartz.scheduler.instanceName" value="quartzInstance" /> <quartz:factory-property key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool" /> <quartz:factory-property key="org.quartz.threadPool.threadCount" value="3" /> <quartz:factory-property key="org.quartz.scheduler.rmi.proxy" value="false" /> <quartz:factory-property key="org.quartz.scheduler.rmi.export" value="false" /> <quartz:factory-property key="org.quartz.jobStore.class" value="org.quartz.simpl.RAMJobStore" /> </quartz:connector> <flow name="test"> <quartz:inbound-endpoint name="timeTrigger" jobName="myJob" repeatInterval="6000" connector-ref="quartzConnector"> <quartz:event-generator-job /> </quartz:inbound-endpoint> <scripting:transformer> <scripting:script engine="groovy"> <scripting:text> def foo = [1, 2, 3, 4, 5] message.setPayload(foo) return message </scripting:text> </scripting:script> </scripting:transformer> <collection-splitter /> <collection-aggregator /> <scripting:transformer> <scripting:script engine="groovy"> <scripting:text> def foo = [] for (def i = 0; i < payload.size(); i++) { def element = payload.get(i) foo.add(element * element) } println "\ntransformed: " + foo return foo </scripting:text> </scripting:script> </scripting:transformer> <stdio:outbound-endpoint system="OUT" /> </flow> </mule>
    • Log Output:
      Hide
      INFO 2011-10-31 14:42:12,070 [main] org.mule.DefaultMuleContext:
      **********************************************************************
      * Mule ESB and Integration Platform *
      * Version: 3.2.0 Build: 22917 *
      * MuleSoft, Inc. *
      * For more information go to http://www.mulesoft.org *
      * *
      * Server started: 10/31/11 2:42 PM *
      * Server ID: 215609bd-03c6-11e1-b1a3-3d96c762086b *
      * JDK: 1.6.0_26 (mixed mode) *
      * OS encoding: UTF-8, Mule encoding: UTF-8 *
      * OS: Mac OS X (10.6.8, x86_64) *
      * Host: myhost (x.x.x.x) *
      * *
      * Agents Running: *
      * JMX Agent *
      **********************************************************************

      [9, 4, 1, 16, 25]
      INFO 2011-10-31 14:42:12,589 [connector.stdio.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.stdio.mule.default.dispatcher.1619081930'. Object is: StdioMessageDispatcher
      INFO 2011-10-31 14:42:12,589 [connector.stdio.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.stdio.mule.default.dispatcher.1619081930'. Object is: StdioMessageDispatcher
      [3, 2, 1, 4, 5]
      [9, 25, 16, 1, 4]
      [3, 5, 4, 1, 2]
      [1, 4, 16, 9, 25]
      [1, 2, 4, 3, 5]
      Show
      INFO 2011-10-31 14:42:12,070 [main] org.mule.DefaultMuleContext: ********************************************************************** * Mule ESB and Integration Platform * * Version: 3.2.0 Build: 22917 * * MuleSoft, Inc. * * For more information go to http://www.mulesoft.org * * * * Server started: 10/31/11 2:42 PM * * Server ID: 215609bd-03c6-11e1-b1a3-3d96c762086b * * JDK: 1.6.0_26 (mixed mode) * * OS encoding: UTF-8, Mule encoding: UTF-8 * * OS: Mac OS X (10.6.8, x86_64) * * Host: myhost (x.x.x.x) * * * * Agents Running: * * JMX Agent * ********************************************************************** [9, 4, 1, 16, 25] INFO 2011-10-31 14:42:12,589 [connector.stdio.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.stdio.mule.default.dispatcher.1619081930'. Object is: StdioMessageDispatcher INFO 2011-10-31 14:42:12,589 [connector.stdio.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.stdio.mule.default.dispatcher.1619081930'. Object is: StdioMessageDispatcher [3, 2, 1, 4, 5] [9, 25, 16, 1, 4] [3, 5, 4, 1, 2] [1, 4, 16, 9, 25] [1, 2, 4, 3, 5]
    • Similar Issues:
    • Sprint:
      Sprint 4, Studio Sprint 1

      Description

      The default behaviour of collection-aggregator seems strange in Mule 3.2.0 and 3.1.2;
      intuitively, this is a bug (or class of bugs).
      If the following is correct or partially correct then there is probably room for improvement in the docs.

      Take the following structure:

      <flow ...
      ...
      <collection-splitter />
      ...
      <collection-aggregator />

      <transformer ...

      <outbound-endpoint ...
      </flow>

      • The above flow will afaics output what is emitted by the collection-aggregator, ignoring any latter transfomer before the outbound-endpoint.
      • If the collection-splitter emits sequence ids for the correlation group (e.g. if it's fed a list) the collection-aggregator doesn't seem to make use of it by default. Of course, a collection splitter might also be fed other payload types with no inherent ordering such as sets, where ordered output should not be expected.
        There seems to have been related issues in the past as well, e.g. MULE-5844

      In the attached config, the output of the outbound-endpoint and the return value of the last transformer are different. And, as per the second point above, the order of elements in the payload is different between the same constant flow input.
      If the splitter and aggregator are commeted out, they will show the same message payloads, and the ordering is constant when the input is constant.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pablo.kraan Pablo Kraan
                Reporter:
                tobbe Tobias Stjernefeldt
              • Votes:
                11 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  4/Sep/12