Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Part 3

Recap

Lets just recap on the solution we have now:

...

The consumer needs to be consuming from an endpoint so we grab the endpoint from Camel we want to consume. It's file://target/subfolderImage Removed. Don't be fooled this endpoint doesn't have to 100% identical to the producer, i.e. the endpoint we used in the previous part to create and store the files. We could change the URL to include some options, and to make it more clear that it's possible we setup a delay value to 10 seconds, and the first poll starts after 2 seconds. This is done by adding ?consumer.delay=10000&consumer.initialDelay=2000 to the URL.

...

Then we prepare our integration to run with or without the consumer enabled. We do this to separate the route into the two parts:

  • receive the webservice, transform and save mail file and return OK as repose
  • the consumer that listen for mail files and send them as emails

So we change the constructor code a bit:

...

Okay we have reached the end of part 3. For now we have only scratched the surface of what Camel is and what it can do. We have introduced Camel into our integration piece by piece and slowly added more and more along the way. And the most important is: you as the developer never lost control. We hit a sweet spot in the webservice implementation where we could write our java code. Adding Camel to the mix is just to use it as a regular java code, nothing magic. We were in control of the flow, we decided when it was time to translate the input to a mail body, we decided when the content should be written to a file. This is very important to not lose control, that the bigger and heavier frameworks tend to do. No names mentioned, but boy do developers from time to time dislike these elephants. And Camel is no elephant.

I hoped you enjoyed this entry level tutorial how to solve a real life integration problem. In the next part we will change focus and look at the routing feature in Camel, this is really impressive what you can do here. Okay see you in part 4. But I suggest you download these the samples from the first part 1 to 3 parts and try and play with it before you continuethem out. It is great basic knowledge to have in the mind when we look at some of the features where Camel really excel - the routing domain language in Camel - from these parts you know how Camel builds this internally in its frameworks with the .

From part 1 to 3 we touched concepts such as::

Okay enough talk. End of part 3.

#Resources

...