Java Reference
In-Depth Information
If you decide that you'd rather not let the Message pass and want to arrest processing, you can return
null instead of a String .
8-10. Adapting External Systems to the Bus
Problem
You want to receive messages from an external system and process them using Spring Integration. The
external system doesn't expose any messaging functionality.
Solution
The answer is a channel adapter that comes straight from the EIP book. Spring Integration makes it
trivially easy to build one.
How It Works
You use a channel adapter to access an application's API or data. Typically this is done by publishing
data from the application on a channel or receiving messages and invoking functionality on the
application's API. Channels can also be used to broadcast events from an application to interested,
external systems.
Adapters are opaque in nature. Your external system interfaces with the adapter. What functionality
or scope of access the application provides to the adapter varies based on the requirements.
Some systems are insurmountable “walled gardens,” and sometimes the worst solution is the only
solution. Imagine, for example, a legacy terminal application based on curses that surfaces application
functionality and data only via the user interface. In this case, a user interface adapter is required. This
situation also presents itself often with web sites, which become data silos. These applications require an
adapter to parse the emitted HTML for data or “screen-scrape” them.
Sometimes functionality is made available from within the application via a cohesive, stable API,
but in a component model or form that isn't directly accessible to the bus. This type of adapter is called a
business logic adapter . An application built in C++ that provides CORBA endpoints but needs to support
SOAP endpoints is a good candidate for this approach.
A third type of adapter, which sits on the database and adapts an external system by way of the
schema, is also an option. This is essentially an implementation of the shared database integration
pattern.
An Inbound Twitter Adapter
Spring Integration already provides many useful implementations of channel adapters, as you have seen
in previous exercises. You will build an example to receive messages from an external system for which
there is no existing support (yet): Twitter. In Spring Integration, you use a MessageSource
implementation to model components that can produce messages for consumption on the bus.
Most of you are familiar with Twitter, so indulge me in a quick overview and introduction, just to be
thorough. Twitter is a social networking site founded in 2006. It allows users to broadcast a message (a
status or a tweet ) to all people who have subscribed to these status updates. The updates are limited to
140 characters. Subscribing to a person's status updates is called following that person.
Support for inspecting other peoples' updates and updating your own status is provided by the web
site itself. Additionally, support is offered by a telephone integration that takes messages sent via a
mobile phone (SMS) and correlates the phone number of the inbound message to a user's account and
updates that person's status on her behalf.
 
Search WWH ::




Custom Search