Install this theme

Posts tagged: apache camel

Processing dependent files with Apache Camel

Imagine, you have following scenario:

  1. Some folder has to be polled for files (i will name them “header”-files), that contain only the meta-information (e.g. filesystem location) of the real “data”-file(s), that should be processed.
  2. From the incoming “header”-file you have to read the data"-file(s) filesystem location and process it from there.
  3. Both “header”- and “data”-file(s) should be moved to the particular “done”-folder after processing. Though the “header”-file is only allowed to be moved, if the appropriate “data”-file(s) was/were successfully processed.
  4. In case the appropriate “data”-file does not exist, the “header”-file message should be rollbacked and the “header”-file must be processed once again after the specified timeout.

Keep reading

Creating custom Apache Camel components

Some time ago I wrote an article about Apache Camel and how to send iOS push notifications using it. Now it’s time to demonstrate how one can create Apache Camel custom components.

Before we start, some words about Apache Camel itself. What exactly is Apache Camel? Wikipedia says:

Apache Camel is a rule-based routing and mediation engine which 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.

But it seems that many people still don’t understand the purpose of this framework. For those I would recommend to read the StackOverflow
discussion regarding this: http://stackoverflow.com/questions/8845186/what-exactly-is-apache-camel

One of the fundamental core elements of Apache Camel are components. Camel provides out of the box a rich set of pre-built components for nearly all common tasks enterprise developer may need nowadays while implementing Enterprise Integration Patterns (EIP). However, in rare cases it can happen that you have to develop a custom component, either to implement not yet covered task/usecase or just to encapsulate a complex route definition.

In this blog post i’ll demonstrate, how to create a simple custom component that can repeatedly generate random character sequences.

Keep reading

Sending iOS push notifications using Apache Camel and Boxcar.io

Apache Camel is a rule-based routing and mediation engine providing implementation of Enterprise Integration Patterns. It allows message transfer from different sources to different destinations (see http://camel.apache.org/components.html for further details).

Playing around with Apache Camel i’ve decided to write a simple example sending push notifications to the iOS devices. 

One option is to use original Camel’s Apns Component. This requires however your APNS provider has to be registered by Apple in order to send push notifications using generated certificate.

Another option is to use a free, public available APNS provider. In this example I’ll use Boxcar.IO as an APNS provider.

Boxcar allows you to create your own provider (= boxcar account) and send push notifications through it to the free Boxcar App installed on your iOS device. Alternatively (for testing or development purpose) one of the pre-configured, generic providers can be used (i’ll use generic “Monitoring” provider in this post).

Furthermore Boxcar exposes a very simple REST API containing only 3 RESTful requests: SUBSCRIBE, CREATE and BROADCAST. SUBSCRIBE will add your service for a user. CREATE sends a message to one user, or a subset of your users. BROADCAST sends a single message to all of your users.

Let’s prepare the iOS device for using Boxcar first.

Keep reading