Last active
April 24, 2021 08:03
-
-
Save lburgazzoli/4cefea60b9ecab07651c40c2b5a59b09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//DEPS org.slf4j:slf4j-simple:1.7.30 | |
//DEPS org.apache.camel:camel-kamelet:3.9.0 | |
//DEPS org.apache.camel:camel-main:3.9.0 | |
//DEPS org.apache.camel:camel-direct:3.9.0 | |
//DEPS org.apache.camel:camel-log:3.9.0 | |
//DEPS org.apache.camel:camel-timer:3.9.0 | |
//DEPS org.apache.camel:camel-seda:3.9.0 | |
import org.apache.camel.Exchange; | |
import org.apache.camel.builder.AggregationStrategies; | |
import org.apache.camel.builder.RouteBuilder; | |
import org.apache.camel.impl.DefaultCamelContext; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class k { | |
private static final Logger LOG = LoggerFactory.getLogger(k.class); | |
public static void main(String... args) throws Exception { | |
try(var ctx = new DefaultCamelContext()) { | |
ctx.addRoutes(new RouteBuilder() { | |
@Override | |
public void configure() throws Exception { | |
routeTemplate("ckc") | |
.from("timer:tick") | |
.setBody().exchangeProperty(Exchange.TIMER_COUNTER) | |
.aggregate() | |
.constant(true) | |
.completionSize("{{aggregationSize}}") | |
.aggregationStrategy(AggregationStrategies.string("|")) | |
.to("kamelet:sink") | |
.to("direct:log"); | |
from("kamelet:ckc?aggregationSize=5") | |
.to("log:kamelet"); | |
from("direct:log") | |
.to("log:direct"); | |
} | |
}); | |
ctx.start(); | |
var ct = ctx.createConsumerTemplate(); | |
while(true) { | |
LOG.info(ct.receiveBody("seda:end", String.class)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment