JBoss Fuse Camel Concepts - JBOSS

What is JBoss Fuse Camel Concepts?

In this chapter, we can apprehend the special Camel concepts. let us begin by means of taking a basic example to recognize center concepts to start with.

CamelContext

Each camel application can have at least one CamelContext. that is the place where we add camel routes. it is just like ApplicationContext of Spring.

Camel context can be notion as a field which continues all things together. One camel context may have multiple routes inside it.

Routes

CamelContext may also include one or more routes. Routes are the mixing logic which defines how information will flow in camel context from one endpoint to some other.

Endpoint

Endpoint is give up of channel via which system can send or receive messages. that is what we call as destination or source in communication language.

Components

Components are point of extension in Camel. additives may be an interface to generation, information format, transformers, etc. they may additionally act as a factory for endpoints.

JBoss Fuse Camel Concepts

EIP

EIP stands for organization Integration sample. these are recognized and well-known solutions to a routine trouble. Camel helps most of the organization Integration patterns.

Content Based Router

CBR patterns allow us to route information as according to the content of the input document.

JBoss Fuse Camel Concepts

This sample is used while we need to course values relying on the contents of the body of input.

The following example will read information from D:/data/input listing. After studying, it will check for value tag in the records tag. If the price tag includes value1, it will be sent to D:/value1, If it contains value2, it will be sent to D:/value2 and if none of these each, then it will be sent to others.

Input

D:/data/input/message1.xml

D:/data/input/message2.xml

Output

D:/value1/


D:/value2/

Splitter

A splitter pattern is used to split input data into smaller chunks.

JBoss Fuse Camel Concepts

This sample is used maximum of the times with huge information input which requires to be split in chunks, so it will become method-able. It breaks down enter into smaller fragments based on input token string.

Input

D:/inbox/message.xml

Output

If you check AMQ you will find 3 messages posted.

Recipient List

A recipient listing pattern is used whilst a listing of recipient needs to be retrieved from the message body itself.

JBoss Fuse Camel Concepts

In the following example, a message may be sent to all of the recipients who are listed in the customer tag as comma separated list of strings.

Other EIPs

Camel presents help to almost all of the EIPs recognized. a number of generally used EIP are as referred to below.

  • Log − To log whole message or part of it
  • Message filter − Filtering contents of messages
  • Re-Sequencer − To get all tokens in collection
  • Wiretap − To inspect travelling messages

The entire list of EIP and their usage can be located at Camel’s official documentation http://camel.apache.org/eip.html

Exception Handling in Camel

Using Error Handler − that is the easiest way to handle exceptions in camel.

To use this, we must configure mistakes handler class bean and provide it as reference to CamelContext errorHandlerRef attribute.

Using of Try catch Finally

Camel also helps Java style try catch finally block for error handling.

Similar to Java, it has the following three blocks −

  • DoTry block includes code that may generate exception.
  • DoCatch block includes code that desires to be carried out in case of exception.
  • DoFinally block has code that need to be finished irrespective of exception. it will always be done regardless of if exception was raised or not.

Note − Mock is testing element and not advocated for different functions. it is the factor in camel used for testing just like jMOck aspect in test driven development.

In the above example, we will provide a list of exceptions that need to be treated by the catch block.

Deploying Bundle in Fuse

Start Fuse using Fuse.bat/start.bat.

If you start Fuse using start.bat, use client.bat to connect to Fuse. You need to get the UI as shown inside the following screenshot.

JBoss Fuse Camel Concepts

This is the CLI for accessing Karaf and Fuse commands.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JBOSS Topics