Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel producers and consumers

I have difficulties wrapping my head around the concept.

I am trying to implement an endpoint that listens on a tcp port for incoming messages in a proprietary format, which would then transform the message and have camel take over the forwarding and routing.

Did I understand correctly that that the Producer is responsible for sending messages into the Endpoint and the Consumer receives them from that endpoint?

When studying the interfaces I couldn't figure out the message flow between those objects, especially on the consumer part. Consumer only defines start() and stop() methods...

When setting up a test on a skeleton implementation, Camel invoked createProducer() on the endpoint and process() on the producer object. After that it returned, swithout doing anything with the consumer or the processor associated with it.

Could someone point me in the right direction?

like image 288
Arnelism Avatar asked Jan 22 '10 17:01

Arnelism


People also ask

What is producer and consumer in Apache Camel?

The Producer does the work of taking the Exchange from the end of a route and converting it into something specific (like a JMS message). I find the Fuse ESB documentation to be better (in general) than the Apache Camel website. From the Fuse ESB Component page: Consumer endpoints consume requests.

What is Consumer template in Apache Camel?

The ConsumerTemplate interface allows you to receive message exchanges from endpoints in a variety of different ways to make it easy to work with Camel Endpoint instances from Java code.

Is a camel producer consumer or decomposer?

Camels are an iconic example of a desert-based primary consumer, feeding on grasses and low lying shrubs. They store water in their humps, for use in dry conditions. The slender-horned gazelle is another primary consumer.


1 Answers

It's important to remember that an Endpoint, created by a Component (i.e. Endpoint Factory), can sit at either end of a Camel Route. If you put the Component at the start of a route then there must be an implementation of the Consumer part of the Component. This does the work of converting the specific input/request (like an HTTP request) into something generic - a Camel Exchange - that can travel down a Route. Whereas if you put the Component at end of a route then you must have an implementation of a Producer. The Producer does the work of taking the Exchange from the end of a route and converting it into something specific (like a JMS message).

I find the Fuse ESB documentation to be better (in general) than the Apache Camel website. From the Fuse ESB Component page:

Consumer endpoints consume requests. They always appear at the start of a route and they encapsulate the code responsible for receiving incoming requests and dispatching outgoing replies.

Producer endpoints produce requests. They always appears at the end of a route and they encapsulate the code responsible for dispatching outgoing requests and receiving incoming replies.


enter image description here

like image 135
chrisjleu Avatar answered Oct 01 '22 21:10

chrisjleu