This document provides guidance on how to use the SWIFT messages with Apache Camel and the Stardust Process engine.
SWIFT or Society for Worldwide Interbank Financial Telecommunication provides a network to allow financial and non-financial institutions (e.g. corporates) to transfer financial transactions through a 'financial message'. Currently SWIFT's network can support the following message standards.
SWIFT messages, developed by SWIFT Standards, consist of five blocks of
data including three headers, message content, and a trailer. Message
types are crucial to identifying content. All SWIFT messages include
the literal "MT" (Message Type). This is followed by a 3-digit number
that denotes the message type, category, and group. Consider the
following example, which is an order to buy or sell via a third party:
WIFE community is an open source Java library for SWIFT messages parsing, writing and processing. The component is heavily tested and running in production environments since 2006.
Its main features are:
All SWIFT message categories (MT0xx to MT9xx) are supported, including System and Service message. The current version is compliant with ISO 15022.
This document describes only the case where SWIFT messages are received as strings. The following table provides more details.
| Case | Options | Comments |
| SWIFT Format (string messages received from jms, file, etc.) | Camel String to SWIFT converter | Converter built by ISB team to transform SWIFT string into WIFE objects |
| Spring bean for transformation from String to WIFE.Message objects. | Bean used to transform SWIFT String to WIFE Message objects. Custom transformation could be done here too | |
| Java/Spring application in Stardust model | SWIFT String are passed to Stardust where transformation occurs. Table 3 Swift procession guidelines details |
This section describes the “String to SWIFT Converter” that transforms a SWIFT String message to a WIFE Message object. The converter is suited for cases where a message received by an endpoint, that needs to be transformed to a SWIFT object message without declaring a bean.
The example below shows how to transform SWIFT String messages into
WIFE Java Objects using the parser. In this case, the messages are sent
to the start endpoint in a String format. Each message will be parsed
using the converter. If a message is not valid, an error will be thrown.
| onException(InvalidMessage.class).handled(true).to("mock:result");
from("direct:start").convertBodyTo(net.sourceforge.wife.swift.model.SwiftMessage.class).to("mock:result"); |
The SWIFT Converter is a component developed by the enabling Team and it is available in the Maven repository.
Using Camel Bean Integration, way to transform data in Camel is to use Spring beans. When a message is received, you need to transform it to SWIFT message using a Spring bean that contains the logic needed to parse the message.
Apache Camel provides several ways for data transformation. The example
below shows how to transform data using beans.
| errorHandler(deadLetterChannel(DLQ_QUEUE));
onException(SwiftTransformationException.class).handled(true).to(FAILURE_QUEUE); from(“activemq:in-queue”).beanRef("SwiftStringTransformer","doTransform") .to(“activemq:out-queue”); |
When the route is started SWIFT messages are consumed from a JMS queue.
Each message is parsed by the SwiftStringTransformer bean using the
Java WIFE API.
If the message is not valid, an exception will be thrown and the
message will be rejected.
If you are not using Apache Camel in you project, you can create a Java
application within you model to transform messages in a String format
to SWIFT Objects.

When running the example, Every Swift Message received by the JMS
trigger will be parsed by the Spring bean which contains the business
logic to process Swift messages. If the processing of the received
message fails, the process instance created will be aborted.