3
votes

The following is the definition about a producer and a consumer given in Camel in Action book.

The consumer could be receiving the message from an external service, polling for the message on some system, or even creating the message itself. This message then flows through a processing component, which could be an enterprise integration pattern (EIP), a processor, an interceptor, or some other custom creation. The message is finally sent to a target endpoint that’s in the role of a producer. A route may have many processing components that modify the message or send it to another location, or it may have none, in which case it would be a simple pipeline.

My doubts:

  1. What is an External Service?
  2. How consumer comes into play before producer produces the message.My understanding is that A producer produces and transforms a message in exchange so that the message is compatible to consumer's endpoint.
  3. Why does a consumer has to do a producer's work (that is transforming a message and sending it to producer again?) Shouldn't it be the viceversa?

Thanks!

1

1 Answers

3
votes

An external service could be, for example, an external web service, an external REST service, an EJB, and so on.

A Consumer could be consuming from any of those services, or it could be listening for a file (or files) to be created in a specific place on the file system, it could be consuming from a message queue (JMS), etc, etc - there are endless possibilities limited only by the components and endpoints available.

Basically, with apache camel, you are designing a message bus (ESB), right? You can think like this - the "consumer" takes stuff from the outside world and puts it on the bus.

Then, your message will go through various routes (most probably being translated and modified along the way, via EIPs) and then eventually it has to go some place else "out there" in the real world - that's when the producer does it's job.

Consumer consumes on to the bus / Producer produces off of the bus.

Usually, you don't need to think too much about whether an endpoint is operating as a producer as a consumer - just use .from and .to as you need and everything should work fine from there.

Also have a read of this answer: Apache Camel producers and consumers

I hope this helps!