Posts

Spring Integration Labs

Here we will try to understand Spring Integration(SI) using examples and will understand and cover each and every component in detail.

Spring Integration Tutorials

Spring Integration is an open source framework for enterprise application integration. It is a lightweight framework that builds upon the core Spring framework. It is designed to enable the development of integration solutions typical of event-driven architectures and messaging-centric architectures.

Spring Integration file-outbound-channel-adaptor :Lab-4

We will Create and test an inbound file adapter. Create and test an outbound file adapter Before we start we already explore adapters. we have already used adapters in the first lab. You used Standard Input and Standard Output adapters to bring String data into the message channel and print it to the Console view Here we will only be using file-outbound-channel-adapter channel in place of stdout-channel-adapter which we have used in previous labs(Channel labs) spring-integration-file-outbound-channel-adapter.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-file="http://www.springframework.org/schema/integration/file" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int-stream="http://www.springframework.org/schema/integration/stream" xsi:schemaLocation=" http://www.spr...

Spring Integration Channels-Direct channel :Lab-3

The only difference b/w Pollable and Direct channel is , There will not be any queue size limit in Direct channel <int:channel id=”messageChannel” /> Everything else will remain same as with pollable channel. spring-integration-channels.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:int="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int-stream="http://www.springframework.org/schema/integration/stream" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.x...

Spring Integration Channels Pollable :Lab-2

Subscribable channels don’t buffer messages and deliver the messages to any and all subscribers. Pollable channels, can buffer messages and deliver the message to a single subscriber. If there are more than one subscribers, it picks the first subscriber and skips the others. In this step, you replace the subscriber channel with a pollable channel to see the effect on the SI application. We will have same example of lab1 with minor changes. those changes are Remove Subscribable channel and add Pollable channel Remove channel: <int:publish-subscribe-channel id=”messageChannel” /> Add Channel: <int:channel id=”messageChannel” > <int:channel id="messageChannel" > <int:queue capacity="2"/></int:channel> So all xmls would be like below: spring-integration-channels.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:int="http://www.springframew...

Spring Integration Channels :Lab-1

Here we will understand publisher and subscriber interaction b/w channels using java project with scenarios. Pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.intertech.si</groupId> <artifactId>lab1-channels</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Spring Integration Lab 1</name> <description>Lab 1 - using channels</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <springframework.version>4.0.4.RELEASE</springframework.version> <spring.integration.version>4.0.0.RELEASE</spring.integration.version> <spring.integration.xml.version>4.0.0.RELEASE</spring.integration.x...

Spring Integration-6 :Enrichers

Spring Integration enrichers are really just a special type of transformer (see previous post in this series). Enrichers take a message from a channel and enhance it by adding information to its header or payload. Thus, an enricher is a transformer that only adds information to the message rather than alter it in other ways.

Spring Integration-5 :Routers

Image
In this installment of our Spring Integration tutorial, we examine routers. Routers distribute messages to one or more message channels. Some routers (content routers) examine the message payload or headers in order to select a particular destination message channel. Other routers (recipient list routers) simply distribute the message to all listed message channels. Example Content Router: <int:payload-type-router input-channel="routingChannel"> <int:mapping type="java.lang.String" channel="stringChannel"/> <int:mapping type="java.lang.Integer" channel="integerChannel" /></int:payload-type-router> Recipient List Router: <int:recipient-list-router id="customRouter" input-channel="routingChannel"> <int:recipient channel="channel1" selector-expression ="payload.equals('foo')"/> <int:recipient channel="channel2" selector-expression=...

Spring Integration-4 :Transformers

Image
Transformers take a message from a channel and creates a new message containing converted payload or message structure.  This allows the provider of information and the consumer of information to communicate via SI without having to settle on a common format.  XML can be transformed to JSON, JSON transformed to Java objects, etc. Transformers convert payload or structure of a message into a modified message Above image converting XML message to Json. Spring Integration Transformers: Transformers comes up with in-build transformers XML to Object(Unmarshallers) or Object to XML(Marshallers) Object to String / String to Object file to string / string to file Object Serialiser or deserialiser Object to Map / Map to Object Object to Json /Json to Object Claim check It uses simple POJOs to create your own custom transformer Simple Transformers examples: Object to String transformer: Takes message with an object payload from inbound channel calls toString method of a payloa...

Spring Integration-3 :Filters

Image
Filters allow, on the basis of a message’s content or metadata (in the message header), a message to pass from one channel to the next or reject and discard the message from the system – that is, not allowing the rejected message into the next channel. The filter is a “yea or nay” component determining which messages flow through and which messages do not. Filters are again endpoints that sit between channels that allows or rejects messages from one message channel to other. Filters allows some messages to pass from one channels to another channel. Messages not selected are discarded Selection occur based on message payload or message metadata(header information) As with Adapters, SI provides many filters out of the box We can create out own filter with its own custom message selection criteria SI Built-In Filters Spring Integration provides several ready to use filters with the framework , you merely have to configure them to use Built-In filters include Express...