DEV Community

Cover image for Apache Camel #4 - Processors
Djordje Bajic
Djordje Bajic

Posted on • Edited on

1 2

Apache Camel #4 - Processors

Hello Devs!

Long time no new article!

Guess i have to fix that.

Today we are talking about processors in Apache Camel routes.

Processors are a part of camel which enables us to write our custom components and business logic and implement it in the routes.

There are two ways of using processors.

  1. Creating a class and implementing Processor with process method. This way we can easily write a test and separate processor logic from route itself. It looks something like this in the route.

.process(new CustomProcessor())

Processor itself will look something like this:

public class CustomProcessor implements Processor {

    @Override
    public void process(Exchange exchange) {
         exchange.getIn().setBody("test");
    }
}
Enter fullscreen mode Exit fullscreen mode
  1. Functional way.

.process(exchange -> exchange.getIn().setBody("test"))

Even though this way is easier that first, it couples processor logic to route and you could only test it if you test whole route.

My YT: https://www.youtube.com/channel/UC0Ws7Fn3fTjZ9eKH87R_rKA

That would be all for today!
Stay safe,stay cool!

George / Djordje

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up