Apache Camel new and noteworthy

This page lists some interesting new features in Apache Camel

Since Decision Insight 20160215

In Decision Insight 20160215 we upgraded Apache Camel to 2.16.2.

Core

New operator for testing string equality with ignored case

There is a new =~ operator in simple language, it tests if 2 String are equals without the case. For instance you can write:

<choice>
    <when>
        <simple>${body[status]} =~ 'ERROR'</simple>
        <log message="There is an error"/>
    </when>
</choice>

In that case, the log message will work no matter the case of the status: "ERROR", "error", "Error" or even "ErRoR"

New dynamic router

Thanks to the <toD /> XML tag it's now easier to route messages to a dynamic endpoint. For instance you can write:

<toD uri="direct:process${body[type]}" />

In that case you can call direct:processStep or direct:processAccount dependending whether ${body[type]} is equals to Step or Account.

exchangeProperty replaces property

In order to avoid ambiguity, confusion and clash with properties, the metadata properties of the exchange are now named "exchangeProperty".

FTP

Configure buffer size for faster download

It's now possible to configure the buffer size for faster FTP downloads. For instance you can write

<from uri="ftp://user@service?receiveBufferSize=1048576"/>

That will provide a 1Mb buffer size for downloading file content. Obviously you can download files that are larger than the buffer, configuring a big buffer produces fewer roundtrips to the FTP server but consumes more memory. By default it's a buffer of 32kb.

JDBC

New StreamList option

There is a new option in the JDBC (Databases) component that allows to stream the result of the database result. For instance you can write:

<setBody>
    <constant>SELECT * FROM PAYMENTS</constant>
</setBody>
<to uri="jdbc:oracle?outputType=StreamList"/>
<split>
    <simple>${body}</simple>
    <log message="Process each database row as a stream" />
</split>

JMS

Faster shutdown of routes that consumes JMS messages

In previous versions of Apache Camel there were an issue that prevented to properly stop a route consuming JMS messages with a heavy load. This issue is now fixed.

Since Decision Insight 20170417

In Decision Insight 20170417 we upgraded Apache Camel to 2.18.3.

Core

Dynamic header and exchange property keys

It's now possible to compute dynamically the name of a header or an exchange property. For instance you can write

<setHeader headerName="${body[headerName]}">
    <constant>Value</constant>
</setHeader>
<setProperty propertyName="${body[propertyName]}">
    <constant>Value</constant>
</setProperty>

Split a big list into smaller ones

Imagine that you have a huge list, containing thousands items and you want to process them by "chunk" then you can use the collate function in Simple. For instance you can write

<setBody>
    <!-- A "big" list -->
    <groovy>["a","b","c","d","e","f","g","h","i","j","k","l"]</groovy>
</setBody>
<split>
    <simple>${collate(3)}</simple>
    <log message="Small chunk: ${body}" />
</split>

This example produces the following logs:

2017-03-21 16:14:00,352 [Camel (integration.test) thread #8 - timer://foo] INFO route1 - Small chunk: [a, b, c]
2017-03-21 16:14:00,353 [Camel (integration.test) thread #8 - timer://foo] INFO route1 - Small chunk: [d, e, f]
2017-03-21 16:14:00,354 [Camel (integration.test) thread #8 - timer://foo] INFO route1 - Small chunk: [g, h, i]
2017-03-21 16:14:00,354 [Camel (integration.test) thread #8 - timer://foo] INFO route1 - Small chunk: [j, k, l]

New string operators

There are 2 new string operators: "starts with" and "ends with". For instance you can write:

<choice>
    <when>
        <simple>${body} starts with 'ERROR'</simple>
        <log message="This is an error: ${body}"/>
    </when>
    <when>
        <simple>${body} ends with '!'</simple>
        <log message="This is important: ${body}"/>
    </when>
</choice>

Easier file filters

You can now use simple predicate expression to filter the file. For instance you can write:

<from uri="file:/path/to/folder/?filterFile=${file:name} ends with '0.txt'"/>

That will only read the files where the name ends with 0.txt.

"As fast as possible" timer

You can now set the delay to -1 in order to make the timercomponent as fast as possible. For instance you can write

 

<from uri="timer:fast?delay=-1"/>
<to uri="log:fast?groupInterval=10000"/>

This produces an average of 180k messages per second.

FTP

Improved stability with SFTP

There was an issue with FTP / FTPS / SFTP where the SFTP connection took lots of time to establish the connection. This issue is now fixed.

JSON

Gson can now unmarshal to any JSON type (map, array).

If you have a JSON array for instance you can deserialize it with

<unmarshal>
    <json library="Gson"/>
</unmarshal>

Tar

Tar is now recognized as a standard data format.

Previously it was complicated to invoke the tar data format, you can now directly write

<unmarshal>
    <tarfile/>
</unmarshal>

Related Links