Skip to content

Instantly share code, notes, and snippets.

@lburgazzoli
Last active July 22, 2016 11:27
Show Gist options
  • Save lburgazzoli/79b8b4a33858cea3370b3d705e5d0a35 to your computer and use it in GitHub Desktop.
Save lburgazzoli/79b8b4a33858cea3370b3d705e5d0a35 to your computer and use it in GitHub Desktop.
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.14')
@Grab(group='org.apache.camel', module='camel-core', version='2.17.0')

import org.apache.camel.impl.*
import org.apache.camel.builder.RouteBuilder

def ctx = new DefaultCamelContext()
ctx.addRoutes(new RouteBuilder() {
    void configure() {
        from('timer://foo1?fixedRate=true&period=1000')
            .toD('log:${routeId}?level=INFO&groupSize=10');
        from('timer://foo2?fixedRate=true&period=500')
            .toD('log:${routeId}?level=INFO&groupSize=10');
    }
})

ctx.start()

while(true) {
    Thread.sleep(1000)
}

ctx.stop()

Would print:

[Camel (camel-1) thread #1 - timer://foo2] INFO route2 - Received: 10 messages so far. Last group took: 4481 millis which is: 2.232 messages per second. average: 2.232
[Camel (camel-1) thread #0 - timer://foo1] INFO route1 - Received: 10 messages so far. Last group took: 8979 millis which is: 1.114 messages per second. average: 1.114
[Camel (camel-1) thread #1 - timer://foo2] INFO route2 - Received: 20 messages so far. Last group took: 5000 millis which is: 2 messages per second. average: 2.109
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment