Apache Camel some tips and tricks

/
0 Comments
Camel Book in one page

  Camel books Camel in action


 It enables easy integration of different applications which use several protocols and technologies.Synchronous remote procedure calls or asynchronous messaging is used to communicate via several technologies such as RMI, SOAP Web Services, REST or JMS. A lot of software silos exists. Nevertheless, all applications and products of these decades have to communicate with each other to work together perfectly.

What is Apache Camel?
Apache Camel is a lightweight integration framework which implements all EIPs. Thus, you can easily integrate different applications using the required patterns. You can use Java, Spring XML, Scala or Groovy. Almost every technology you can imagine is available, for example HTTP, FTP, JMS, EJB, JPA, RMI, JMS, JMX, LDAP, Netty, and many, many more (of course most ESBs also offer support for them). Besides, own custom components can be created very easily.
You can deploy Apache Camel as standalone application, in a web container (e.g. Tomcat or Jetty), in a JEE application Server (e.g. JBoss AS or WebSphere AS), in an OSGi environment or in combination with a Spring container.
If you need more information about Apache Camel, please go to its web site as starting point: http://camel.apache.org. This article is no technical introduction J
When to use Apache Camel?
Apache Camel is awesome if you want to integrate several applications with different protocols and technologies. Why? There is one feature (besides supporting so many technologies and besides supporting different programming languages)  Every integration uses the same concepts! No matter which protocol you use. No matter which technology you use. No matter which domain specific language (DSL) you use – it can be Java, Scala, Groovy or Spring XML. You do it the same way. Always! There is a producer, there is a consumer, there are endpoints, there are EIPs, there are custom processors / beans (e.g. for custom transformation) and there are parameters (e.g. for credentials).

 What is the difference between enrich() and pollEnrich()?

  Content enricher here  ( Link)

 Content enrichment using the enrich DSL element Camel comes with two flavors of content enricher in the DSL enrich pollEnrich enrich uses a Producer to obtain the additional data. It is usually used for Request Reply messaging, for instance to invoke an external web service. pollEnrich on the other hand uses a Polling Consumer to obtain the additional data. It is usually used for Event Message messaging, for instance to read a file or download a FTP file.

  • enrich assumes you want to use an incoming Exchange as a parameter to an another service request. for example, your incoming Exchange could be a userID, but you really need the entire User object, so you could enrich it by passing the userID to a REST service that returns the User object which becomes the Exchange, etc.
  • pollEnrich assumes the incoming Exchange is a simple trigger that tell a PollingConsumer to look for data and create an Exchange (ignoring the contents of the incoming Exchange). For example, you could have a timer or other business process event that requires picking up a file for processing, etc. that said, the incoming Exchange data is NOT used to dynamically configure the PollingConsumer...only the URI is used for this.
What are different message exchange patterns in Camel, which one of these is synchronous?
A: There are two types of message exchange patterns in Camel:
  • In Only: In this exchange pattern, consumer creates a exchange which only contains an In message.
  • In Out: In this exchange pattern, consumer creates a exchange which also contains reply message for the caller.
Out of above two, InOut pattern is synchronous because caller expects for an acknowledgement or reply for each exchange sent.

What is camel exchange? Explain its structure?
A: A Camel Exchange can be called as an holder for holding message during routing. A exchange supports various message exchange patterns, like InOnly and InOut.
Following are the contents of camel exchange:
  • ExchangeId: A unique identifier for each exchange
  • Message Exchange Pattern: This field denotes whether you are using InOnly or InOut exchange pattern.
  • Exception: If any exception occurs during routing, it will be available in this field.
  • Properties: These are the properties that are available for entire duration of exchange.
  • In Message: This is mandatory field which contains the input message.
  • Out Message: This is optional message which exists only if MEP is InOut.


You may also like

No comments: