You can use the Camel connector to send data to almost any type of
system.
To keep this document focused on the Camel connector, we use the Camel
File component. However, the connector can be used with any Camel
component.
Example
Let’s imagine you want to write generated prices into files. Configure
your application to write the messages from the prices channel into a
files as follows:
packagecamel.outbound;importjava.time.Duration;importjava.util.Random;importjavax.enterprise.context.ApplicationScoped;importorg.eclipse.microprofile.reactive.messaging.Outgoing;importio.smallrye.mutiny.Multi;@ApplicationScopedpublicclassCamelPriceProducer{privateRandomrandom=newRandom();@Outgoing("prices")publicMulti<String>generate(){// Build an infinite stream of random pricesreturnMulti.createFrom().ticks().every(Duration.ofSeconds(1)).onOverflow().drop().map(x->random.nextDouble()).map(p->Double.toString(p));}}
packagecamel.outbound;importjava.time.Duration;importjava.util.Random;importjavax.enterprise.context.ApplicationScoped;importorg.eclipse.microprofile.reactive.messaging.Message;importorg.eclipse.microprofile.reactive.messaging.Outgoing;importio.smallrye.mutiny.Multi;@ApplicationScopedpublicclassCamelPriceMessageProducer{privateRandomrandom=newRandom();@Outgoing("prices")publicMulti<Message<String>>generate(){// Build an infinite stream of random pricesreturnMulti.createFrom().ticks().every(Duration.ofSeconds(1)).map(x->random.nextDouble()).map(p->Double.toString(p)).map(Message::of);}}
Serialization
The serialization is handled by the Camel component. Refer to the Camel
documentation to check which payload type is supported by the component.
Outbound Metadata
When sending Messages, you can add an instance
of OutgoingExchangeMetadata
to the message metadata. You can then influence how the outbound Camel
Exchange is created, for example by adding properties: