Aggregator Pattern

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Aggregator Pattern

Randy H
Does the Camel Aggregator pattern currently work? I'm using camel-core-1.3.4.0-fuse.jar. I tried to add an aggregator to a camel route and when the configure method runs it generates an UnsupportedOperationException (see below). The error occurs when the camel route is being built, not when I attempt to send actual data through the route. Since the documentation on the Camel aggregator pattern is so minimal, I could be doing something wrong with the aggregator. Here is my test code (junit test):

    public void testAggregator()
        throws Exception {

        LOG.info( "Starting testAggregator" );

        try {
            CamelContext context = new DefaultCamelContext();

            context.getEndpoint( "mock:test", MockEndpoint.class );
        
            //********************************************************
            // Create a camel route that uses an aggregator
            //********************************************************
            context.addRoutes( new RouteBuilder() {

                public void configure() {

                    streamCaching();
                    LOG.info( "Configuring CAMEL Aggregator rules." );

                    //************************************************
                    // Send any queryRequest nodes from the workflow
                    //  message to a file in the output directory.
                    //************************************************
                    from( "file://samples/input" ).
                        to( "log:theLoggingCategory?level=info" ).
                        aggregator( header( "CheeseWhiz" ) ).
                        to( "mock:test" );

                }
            } );

            // Now everything is set up - lets start the context
            context.start();

            //************************************************************
            // Test - Copy the XML data to the CAMEL input directory. 
            //  Camel should aggregate the two 'queryRequest' nodes
            //  and write them to the output directory.
            //************************************************************
            LOG.info( "Start Test - Aggregator processing with Camel" );
            _doCamelRouteTest( 4, "workFlowNoNS.xml", ALERT_DIR, 3 );

            context.stop();
            context = null;
        }
        catch( Exception e ) {
            e.printStackTrace();
            LOG.error( "Unexpected Camel exception: " + e );
        }
        

        LOG.info( "testAggregator completed!" );
    }
When I execute the test code, an exception is generated. Here is log output including the exception stack trace:
13:43:47.720 INFO  [RouteAlertsTest] - Setting up for Camel test
13:43:53.238 INFO  [RouteAlertsTest] - Starting testAggregator
13:43:58.05 INFO  [RouteAlertsTest] - Configuring CAMEL Aggregator rules.
java.lang.UnsupportedOperationException: Not implemented yet for class: org.apache.camel.model.AggregatorType
	at org.apache.camel.model.ProcessorType.createProcessor(ProcessorType.java:80)
	at org.apache.camel.model.ProcessorType.createOutputsProcessor(ProcessorType.java:1500)
	at org.apache.camel.model.ProcessorType.createOutputsProcessor(ProcessorType.java:85)
	at org.apache.camel.model.InterceptorRef.createProcessor(InterceptorRef.java:59)
	at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1406)
	at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:89)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
	at com.lmco.bais.query.alerts.RouteAlertsTest.testAggregator(RouteAlertsTest.java:341)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
13:44:10.337 ERROR [RouteAlertsTest] - Unexpected Camel exception: java.lang.UnsupportedOperationException: Not implemented yet for class: org.apache.camel.model.AggregatorType
Any insight would be greatly appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Aggregator Pattern

Willem.Jiang
Administrator
Hi Randy,

I just check the AggregatorType code history, the createProcessor method
was added at May 24th.
I think you need to upgrade camel to 1.4.0.0 fuse or latest relesed
1.4.2.0 fuse.

Willem


Randy H wrote:

> Does the Camel Aggregator pattern currently work?  I'm using
> camel-core-1.3.4.0-fuse.jar.  I tried to add an aggregator to a camel route
> and when the configure method runs it generates an
> UnsupportedOperationException (see below).  The error occurs when the camel
> route is being built, not when I attempt to send actual data through the
> route.  Since the documentation on the Camel aggregator pattern is so
> minimal, I could be doing something wrong with the aggregator.  Here is my
> test code (junit test):
>
>
>     public void testAggregator()
>         throws Exception {
>
>         LOG.info( "Starting testAggregator" );
>
>         try {
>             CamelContext context = new DefaultCamelContext();
>
>             context.getEndpoint( "mock:test", MockEndpoint.class );
>        
>             //********************************************************
>             // Create a camel route that uses an aggregator
>             //********************************************************
>             context.addRoutes( new RouteBuilder() {
>
>                 public void configure() {
>
>                     streamCaching();
>                     LOG.info( "Configuring CAMEL Aggregator rules." );
>
>                     //************************************************
>                     // Send any queryRequest nodes from the workflow
>                     //  message to a file in the output directory.
>                     //************************************************
>                     from( "file://samples/input" ).
>                         to( "log:theLoggingCategory?level=info" ).
>                         aggregator( header( "CheeseWhiz" ) ).
>                         to( "mock:test" );
>
>                 }
>             } );
>
>             // Now everything is set up - lets start the context
>             context.start();
>
>             //************************************************************
>             // Test - Copy the XML data to the CAMEL input directory.
>             //  Camel should aggregate the two 'queryRequest' nodes
>             //  and write them to the output directory.
>             //************************************************************
>             LOG.info( "Start Test - Aggregator processing with Camel" );
>             _doCamelRouteTest( 4, "workFlowNoNS.xml", ALERT_DIR, 3 );
>
>             context.stop();
>             context = null;
>         }
>         catch( Exception e ) {
>             e.printStackTrace();
>             LOG.error( "Unexpected Camel exception: " + e );
>         }
>        
>
>         LOG.info( "testAggregator completed!" );
>     }
>
>
> When I execute the test code,  an exception is generated.  Here is log
> output including the exception stack trace:
>
>
> 13:43:47.720 INFO  [RouteAlertsTest] - Setting up for Camel test
> 13:43:53.238 INFO  [RouteAlertsTest] - Starting testAggregator
> 13:43:58.05 INFO  [RouteAlertsTest] - Configuring CAMEL Aggregator rules.
> java.lang.UnsupportedOperationException: Not implemented yet for class:
> org.apache.camel.model.AggregatorType
> at
> org.apache.camel.model.ProcessorType.createProcessor(ProcessorType.java:80)
> at
> org.apache.camel.model.ProcessorType.createOutputsProcessor(ProcessorType.java:1500)
> at
> org.apache.camel.model.ProcessorType.createOutputsProcessor(ProcessorType.java:85)
> at
> org.apache.camel.model.InterceptorRef.createProcessor(InterceptorRef.java:59)
> at
> org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1406)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:89)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at
> com.lmco.bais.query.alerts.RouteAlertsTest.testAggregator(RouteAlertsTest.java:341)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> 13:44:10.337 ERROR [RouteAlertsTest] - Unexpected Camel exception:
> java.lang.UnsupportedOperationException: Not implemented yet for class:
> org.apache.camel.model.AggregatorType
>
>
>
> Any insight would be greatly appreciated.
>  

Reply | Threaded
Open this post in threaded view
|

Re: Aggregator Pattern

Willem.Jiang
Administrator
Sorry, I mass up the modification date.
You need to upgrade camel to 1.4.1.0 fuse or later version to get this
issue fixed.


Willem Jiang wrote:

> Hi Randy,
>
> I just check the AggregatorType code history, the createProcessor
> method was added at May 24th.
> I think you need to upgrade camel to 1.4.0.0 fuse or latest relesed
> 1.4.2.0 fuse.
>
> Willem
>
>
> Randy H wrote:
>> Does the Camel Aggregator pattern currently work?  I'm using
>> camel-core-1.3.4.0-fuse.jar.  I tried to add an aggregator to a camel
>> route
>> and when the configure method runs it generates an
>> UnsupportedOperationException (see below).  The error occurs when the
>> camel
>> route is being built, not when I attempt to send actual data through the
>> route.  Since the documentation on the Camel aggregator pattern is so
>> minimal, I could be doing something wrong with the aggregator.  Here
>> is my
>> test code (junit test):
>>
>>
>>     public void testAggregator()
>>         throws Exception {
>>
>>         LOG.info( "Starting testAggregator" );
>>
>>         try {
>>             CamelContext context = new DefaultCamelContext();
>>
>>             context.getEndpoint( "mock:test", MockEndpoint.class );
>>                    
>> //********************************************************
>>             // Create a camel route that uses an aggregator
>>             //********************************************************
>>             context.addRoutes( new RouteBuilder() {
>>
>>                 public void configure() {
>>
>>                     streamCaching();
>>                     LOG.info( "Configuring CAMEL Aggregator rules." );
>>
>>                     //************************************************
>>                     // Send any queryRequest nodes from the workflow
>>                     //  message to a file in the output directory.
>>                     //************************************************
>>                     from( "file://samples/input" ).
>>                         to( "log:theLoggingCategory?level=info" ).
>>                         aggregator( header( "CheeseWhiz" ) ).
>>                         to( "mock:test" );
>>
>>                 }
>>             } );
>>
>>             // Now everything is set up - lets start the context
>>             context.start();
>>
>>            
>> //************************************************************
>>             // Test - Copy the XML data to the CAMEL input directory.
>>             //  Camel should aggregate the two 'queryRequest' nodes
>>             //  and write them to the output directory.
>>            
>> //************************************************************
>>             LOG.info( "Start Test - Aggregator processing with Camel" );
>>             _doCamelRouteTest( 4, "workFlowNoNS.xml", ALERT_DIR, 3 );
>>
>>             context.stop();
>>             context = null;
>>         }
>>         catch( Exception e ) {
>>             e.printStackTrace();
>>             LOG.error( "Unexpected Camel exception: " + e );
>>         }
>>        
>>         LOG.info( "testAggregator completed!" );
>>     }
>>
>>
>> When I execute the test code,  an exception is generated.  Here is log
>> output including the exception stack trace:
>>
>>
>> 13:43:47.720 INFO  [RouteAlertsTest] - Setting up for Camel test
>> 13:43:53.238 INFO  [RouteAlertsTest] - Starting testAggregator
>> 13:43:58.05 INFO  [RouteAlertsTest] - Configuring CAMEL Aggregator
>> rules.
>> java.lang.UnsupportedOperationException: Not implemented yet for class:
>> org.apache.camel.model.AggregatorType
>>     at
>> org.apache.camel.model.ProcessorType.createProcessor(ProcessorType.java:80)
>>
>>     at
>> org.apache.camel.model.ProcessorType.createOutputsProcessor(ProcessorType.java:1500)
>>
>>     at
>> org.apache.camel.model.ProcessorType.createOutputsProcessor(ProcessorType.java:85)
>>
>>     at
>> org.apache.camel.model.InterceptorRef.createProcessor(InterceptorRef.java:59)
>>
>>     at
>> org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1406)
>>
>>     at
>> org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:89)
>>     at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
>>     at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
>>     at
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
>>
>>     at
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
>>
>>     at
>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
>>     at
>> com.lmco.bais.query.alerts.RouteAlertsTest.testAggregator(RouteAlertsTest.java:341)
>>
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>     at junit.framework.TestCase.runTest(TestCase.java:168)
>>     at junit.framework.TestCase.runBare(TestCase.java:134)
>>     at junit.framework.TestResult$1.protect(TestResult.java:110)
>>     at junit.framework.TestResult.runProtected(TestResult.java:128)
>>     at junit.framework.TestResult.run(TestResult.java:113)
>>     at junit.framework.TestCase.run(TestCase.java:124)
>>     at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>     at junit.framework.TestSuite.run(TestSuite.java:227)
>>     at
>> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
>>
>>     at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>>
>> 13:44:10.337 ERROR [RouteAlertsTest] - Unexpected Camel exception:
>> java.lang.UnsupportedOperationException: Not implemented yet for class:
>> org.apache.camel.model.AggregatorType
>>
>>
>>
>> Any insight would be greatly appreciated.
>>  
>
>