Skip to content

Instantly share code, notes, and snippets.

@diogodanielsoaresferreira
Created June 11, 2021 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogodanielsoaresferreira/a68c674081b169fc5f575a81f846fd19 to your computer and use it in GitHub Desktop.
Save diogodanielsoaresferreira/a68c674081b169fc5f575a81f846fd19 to your computer and use it in GitHub Desktop.
Camel Routes - Step 7
//...
from("kafka:input_topic?brokers=localhost:9092&groupId=group1")
.unmarshal().json(UserMessage.class)
.filter(simple("${body.type} == 'chat'"))
.log("${body}")
.split(simple("${body.devices}"))
.log("${body}")
.end()
.marshal().json()
.to("kafka:output_topic?brokers=localhost:9092")
.to("direct:store_in_file");
from("direct:store_in_file")
.unmarshal().json(UserMessage.class)
.choice()
.when(simple("${body.emitter} == 'John Doe'"))
.marshal().json().to("file:///home/diogoferreira/Desktop/Apache Camel Demo/getting-started/user-message?filename=events.json&fileExist=Append&appendChars=\\n")
.otherwise()
.marshal().json().to("file:///home/diogoferreira/Desktop/Apache Camel Demo/getting-started/john-doe-message?filename=events.json&fileExist=Append&appendChars=\\n")
.end();
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment