Question: What Is Camelcontext?
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.
Question: What Are Eips In Apache Camel?
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.
Question: What Is Camel ?
At a very abstract level, camel can be introduced as a routing engine. Camel allows us to define our routing rules to route messages from specified source to destination.
Camel provides inbuilt support for many protocols which makes it easy for us to integrate different systems.
For ex: Camel can easily integrate two different applications working in ftp and jms respectively. Internally Camel performs all the required protocol and datatype conversions for us.
Question: What Are The Dependencies?
Camel 2.6 or older can run on JDK 1.5 or better.
Camel 2.7 onwards requires JDK 1.6 or JDK 1.7.
Camel 2.14 onwards requires JDK 1.7 or better.
Camel 2.18 onwards requires JDK 1.8.
Question: What Are Dsls And Which Dsls Have You Used?
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.
Question: What Is Redelivery Policy In Apache Camel?
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.
Question: What Are Components?
In simple terms, a component refers to an external entity that is communicating with camel. To write a camel route that work with files, file component is to be used. Similarly to work with JMS queue, jms component has to be used.
Ex – A FileComponent is referred to by file in a URI and it creates FileEndpoints.
Question: Have You Use Database With Apache Camel?
Yes. Have integrated Apache Camel MySQL Database using SQL Queries
Question: Is Camel An Esb?
Typically vendors claim practically everything is an ESB these days, so the answer is probably yes (smile)
However our view is that an ESB is more of a container of integration components, so we view Apache ServiceMix to be a true ESB based around OSGi (and optionally JBI) to provide a standards based integration platform of components.
We view Camel as being a rule based routing & mediation engine which can be used inside a full blown ESB, a message broker or a web services smart client. Though if you want to, you could consider that Camel is a small, lightweight embeddable ESB since it can provide many of the common ESB services like smart routing, transformation, mediation, monitoring, orchestration etc.
Question: How Is A Camel Exchange Created?
An exchange is created by the endpoint.
Question: What Is The License?
This software is open source using the Apache 2.0 licence (a liberal BSD style license which is very commercial friendly)
Question: Have You Used Apache Camel With Spring?
Yes. Have integrated Apache Camel with Spring. It helps in utilizing features like Spring Dependency injection, Datasource and Transaction management.
Question: How Did You Integrate Apache Camel With Database?
Using Apache Camel SQL component.
Apache Camel + SQL component(MySQL DB)
Question: What Is An Uri?
URI is a naming scheme used in camel to refer to an endpoint. An URI tells camel, the component being used, the context path and the options applied against the component. URI contains 3 parts:
- Context path
Example of a file URI working as a consumer :
Here the scheme points to file, the context path is “src/data” and the options are “fileName and fileExist” are options that can be used with file component or file endpoint.
Question: What Is An Esb? Have You Deployed Camel On Any 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. Have deployed JBoss Fuse ESB for Apache Camel Deployement.
Question: What Is A Producer And A Consumer Endpoint?
A camel route is similar to a channel though which data flows. Producer and consumer are two endpoints that are present at each end of the channel.
A consumer endpoint is the starting point of the route. A definition of a camel route starts by writing a camel consumer endpoint.
A producer endpoint appears (not always) at the end of the route. It consumes the data that is passed through the route.
Question: What Is An Endpoint?
A camel endpoint is similar to an entity that is capable of sending or receiving messages. For e.g., a JMS queue can be treated as an endpoint.
Question: What Are Routes In Apache Camel?
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.
Question: Have You Exposed A Webservice Endpoint Using Apache Camel?
Yes. Using Apache CXF exposed a webservice to be consumed. Used Contract first approach to generate the classes from wsdl.
Question: Can We Call Camel An Esb (enterprise Service Bus)?
Although camel supports many features similar to ESB like routing, transformation etc., we cannot call camel as ESB because it does not have a container like ESBs. However, we can deploy camel on to some ESB container like service mix.
Question: What Type Of Object(s) Can The Exchange Hold?
A camel Exchange can hold any sub type of java.lang.Object including primitive data types.
Question: What Platforms Are Supported?
Any platform supporting JDK 6.
We regularly test Camel on Linux, Windows and OS X.
Question: Why You Selected Camel For Your Application Or Why You Use Camel?
Camel is very lightweight routing engine that allows us to integrate different applications with minimal configuration. Inbuilt support for different protocols allows a developer to focus on business problem than on integration problem. Camel routing is not restricted to xml payload but it can route any type of message. Camel test kit further helps to test the solution.
Question: What Is A Router?
We often talk about that Camel is a mediation and routing framework; so what exactly is a router and what does it do?
Basically a router just consumes Message exchanges from some Endpoint, then sends them on to some other Endpoint using some kind of Enterprise Integration Patterns.
For example a router could implement the Content Based Router pattern, to route from an endpoint to one or more destination endpoints using a Predicate based on the message content.
Typically a route or router consists of one or more consumers; either an Event Driven Consumer or a Polling Consumer or possibly a Transactional Client. Then there are one or more Processor instances which could send the message to one or more endpoints.
Question: Have You Used Apache Camel With Spring Boot?
Have integrated Apache Camel with Spring Boot. Made use of Apache Camel Spring Boot starter dependency. Apache Camel + Spring Boot
Question: What Are Different Message Exchange Patterns In Camel, Which One Of These Is Synchronous?
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.
Question: How Did You Execute Junit Test Cases For Apache Camel?
Using CamelSpringTestSupport – Apache Camel Unit Testing
Question: What Are Various Components In Apache Camel? Which Ones Have You Used?
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.
Question: How Are Exception Handled Using Apache Camel?
Exception can be handled using the <try> <catch> block, <OnException> block or the <errorHandler> 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.
Question: What Jars Do I Need?
Camel is designed to be small lightweight and extremely modular so that you only pay for what you use. The core of camel, camel-core.jar is small and has minimal dependencies.
On Java 6 camel-core.jar only depends on
commons-management.jar (for Camel 2.8 or older)
commons-logging.jar (for Camel 2.6 or older)
slf4j-api.jar (from Camel 2.7 onwards)
On Java 5 camel-core.jar depends also on activation.jar and a JAXB2 implementation which typically involves jaxb-api.jar, jaxb-impl.jar and a StAX API which may be stax-api.jar and *woodstox.jar
Question: What Are Endpoints In Apache Camel?
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.
Question: What Is Camel Exchange? Explain Its Structure?
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.
Question: What Is An Exchange In Apache Camel?
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.
Question: How Is Data Passed Between The Routes?
The data is passed in the routes as an object of the class org.apache.camel.Exchange.
Question: What Is Routercontext?
It is now possible to define routes outside <camelContext/> which you do in a new <routeContext/> tag. The routes defined in <routeContext/> can be reused by multiple <camelContext/>. However its only the definition which is reused. At runtime each CamelContext will create its own instance of the route based on the definition.
Apache Camel Questions and Answers for Interview
Preparing for Apache Camel job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Camel interview, then go through the above 50+ Top Apache Camel Interview Questions and Answers to crack your job interview.