Sunday, October 29, 2017

Apache Camel Interview Questions

Q: What is Apache Camel ?

A: In an enterprise, a number of systems of different types exist. Some of these may be legacy systems while some may be new. These systems often interact with each other,and need to be integrated. This interaction or integration is not easy as the implementations of the systems, their message formats may differ. One way to achieve this is to implement code which bridges these differences. However this will be point to point integration. If tomorrow again if there is change in a system the other might also have to be changed which is not good. Instead of this point to point integration which causes tight coupling we can implement an additional layer to mediate the differences between the systems. This results in loose coupling and not affect much our existing systems. Apache Camel is a rule-based routing and mediation engine that provides a Java object- based implementation of the Enterprise Integration Patterns using an API (or declarative Java Domain Specific Language) to configure routing and mediation rules.

Q: What are routes in Apache Camel? 
A:
The core functionality of Apache Camel is its routing engine. It allocates messages based on the related routes. A route contains flow and integration logic. It is implemented using EIPs and a specific DSL.

Q: What are DSLs and which DSLs have you used? 
A:
 Routes in a variety of domain-specific languages (DSL).The most popular ones are Java DSL - A Java based DSL using the fluent builder style. Spring XML - A XML based DSL in Spring XML files

Q: What is an ESB? Have you deployed camel on any ESB?
A:
 ESB stands for Enterprise Service Bus. It can be defined as a tool designed to help implement an application using SOA principles Not for all projects projects is the use of ESB an optimum solution ESB should be used when projects involve integrating a number of Endpoints like Webservices, JMS, FTP etc. Have deployed JBoss Fuse ESB for Apache Camel Deployement.

Q: What are EIPs in Apache Camel?
A:
 EIPs stand for Enterprise Integration Pattern. These are Design patterns for the use of enterprise application integration and message-oriented middleware in the form of a pattern. Various EIPs are used in Apache Camel. Some of them are- Splitter Pattern
 Split the data on the basis of some token and then process it. Content Based Router-The Content-Based Router inspects the content of a message and routes it to another channel based on the content of the message. Using such a router enables the message producer to send messages to a single channel and leave it to the Content-Based Router to inspect messages and route them to the proper destination. This alleviates the sending application from this task and avoids coupling the message producer to specific destination channels. Message Filter-A Message Filter is a special form of a Content-Based Router. It examines the message content and passes the message to another channel if the message content matches certain criteria. Otherwise, it discards the message. Recipient List-A Content-Based Router allows us to route a message to the correct system based on message content. This process is transparent to the original sender in the sense that the originator simply sends the message to a channel, where the router picks it up and takes care of everything. Wire Tap-Wire Tap allows you to route messages to a separate location while they are being forwarded to the ultimate destination.
Q: What is an exchange in Apache camel?
A:
 The message to be routed in Camel route is present in the Exchange. It is the message holder. Apache camel uses Message Exchange Patterns(MEP). Apache camel exchange can hold any kind of message. It supports a variety of formats like xml, JSON etc. 

Q: What are endpoints in apache camel?
A:
 Camel supports the Message Endpoint pattern using the Endpoint interface. Endpoints are usually created by a Component and Endpoints are usually referred to in the DSL via their URIs. 

Q: What are various components in apache camel? Which ones have you used?
A:
 Apache camel provides us with a number of components. These components make interacting create endpoints with which a system can interact with other external systems. For example using an ActiveMQ component we expose an ActiveMQ endpoint for interaction with external system. There are more than 100 components provided by Apache Camel. Some of them are FTP,JMX, Webservices, HTTP. Apache camel also allows users to create custom components. 
Here are examples of FileComponent, JMSComponent, CXF Component. 

Q: Have you use Database with Apache Camel?
A:
 Yes. Have integrated Apache Camel MySQL Database using SQL Queries 
Apache Camel Tutorial- Integrate with MySQL DB using SQL query 
Q: Have you used Apache Camel with Spring?
A:
 Yes. Have integrated Apache Camel with Spring. It helps in utilizing features like Spring Dependency injection, Datasource and Transaction management. 
Apache Camel Java DSL + Spring Integration Example 

Q: Have you exposed a SOAP webservice endpoint using Apache Camel?
A:
 Yes. Using Apache CXF exposed a webservice to be consumed. Used Contract first approach to generate the classes from wsdl. 
Apache Camel + Apache CXF SOAP Webservices 

Q: Have you exposed a REST webservice endpoint using Apache Camel?
A:
 Yes. Using Apache CXF exposed a REST Endpoint. This can be done using either JAX-RS or CXFRS 
Apache Camel + JAX-RS REST Webservice
Apache Camel + CXFRS REST Webservice 

Q: How did you integrate Apache Camel with Database?
A:
Using Apache Camel SQL component. 
Apache Camel + SQL component(MySQL DB) 

Q: How did you execute JUnit test cases for Apache camel?
A:
 Using CamelSpringTestSupport - 
Apache Camel Unit Testing

Q: How are exception handled using Apache Camel?
A:
 Exception can be handled using the block, block or the block.
The errorHandler is used to handle any uncaught Exception that gets thrown during the routing and processing of a message. Conversely, onException is used to handle specific Exception types when they are thrown.
Understanding Apache Camel Exception Handling Using Simple Example 

Q: What is Redelivery policy in Apache Camel?
A:
 A redelivery policy defines rules when Camel Error Handler perform redelivery attempts. For example you can setup rules that state how many times to try redelivery, and the delay in between attempts, and so forth.
Understanding Apache Camel Redelivery policy using simple example  
Q: What is CamelContext?
A:
 The CamelContext represents a single Camel routing rulebase. We use the CamelContext in a similar way to the Spring ApplicationContext. public interface CamelContext extends SuspendableService, RuntimeConfiguration. Interface used to represent the context used to configure routes and the policies to use during message exchanges between endpoints. 

Q: What is RouterContext?
A:
 It is now possible to define routes outside which you do in a new tag. The routes defined in can be reused by multiple . However its only the definition which is reused. At runtime each CamelContext will create its own instance of the route based on the definition. 

Q: Have you used Quartz with Apache Camel?
A:
 Yes. Apache camel was used to trigger certain jobs everyday at a particular time of the day.
Apache Camel + Spring + Quartz Example 

Q: Have you used Apache Camel with Spring Boot?
A:
 Have integrated Apache Camel with Spring Boot. Made use of Apache Camel Spring Boot starter dependency.
Apache Camel + Spring Boot

Apache Camel and JBoss Fuse ESB

What is ESB
ESB stands for Enterprise Service Bus. It can be defined as a tool designed to help implement an application using SOA principles Not for all projects projects is the use of ESB an optimum solution ESB should be used when projects involve integrating a number of Endpoints like Webservices, JMS, FTP etc

Working of ESB
When application is implemented using ESB, the different modules interact with each other through the BUS. The individual modules are deployed on the bus and exposed as endpoints. This approach increased reusibility of a module, as the module exposed can be used by number of other modules. This also helps create loose coupling For example a single module having DataBase connection and pooling properties can be exposed as endpoint on the bus. All other modules requiring DataBase Connection can then make use of this exposed module

Different ESB in the market
There are various ESB's available in the market. Some are opensource, some licenced
1. Talend
2. Mule ESB
3. JBoss Fuse ESB


No comments:

Post a Comment