SWIFT Processing within Camel and Stardust

This document provides guidance on how to use the SWIFT messages with Apache Camel and the Stardust Process engine.



SWIFT Overview 

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 MT

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:

MT Message types

These are the SWIFT Message Types (MT):
  1. MT0xx System Messages
  2. MT1xx Customer Payments and Cheques
  3. MT2xx Financial Institution Transfers
  4. MT3xx Treasury Markets
  5. MT4xx Collection and Cash Letters
  6. MT5xx Securities Markets
  7. MT6xx Treasury Markets - Metals and Syndications
  8. MT7xx Documentary Credits and Guarantees
  9. MT8xx Travellers Cheques
  10. MT9xx Cash Management and Customer Status

WIFE Java API

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.



SWIFT processing guidelines

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

Requirements

The following jar files, representing the Java WIFE API should be used.

SWIFT Processing

Camel String to SWIFT Converter

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.


Example

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");

Transformation in Camel Route

The SWIFT Converter is a component developed by the enabling Team and it is available in the Maven repository.


Using a bean to transform the messages

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.



Example

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”);
 Transformation in Camel Route with bean

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.


Transforming SWIFT messages in Stardust

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.


SWIFT-Stardust
Figure 2 Swift Processing Application

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.

Swift show data 
Figure 3 Swift Message data