Merge pull request #30 from ghillert/INTSAMPLES-42

INTSAMPLES-42 - Convert all ReadMe files to MarkDown
This commit is contained in:
Gary Russell
2012-01-18 07:57:28 -08:00
54 changed files with 751 additions and 822 deletions

View File

@@ -3,15 +3,10 @@ Advanced Testing Examples
Example test cases that show advanced techniques to test Spring Integration based applications.
For basic testing examples see: *basic/testing-examples*
For basic testing examples see: **basic/testing-examples**
## Examples
...jms.JmsMockTests.java
**jms.JmsMockTests.java**
This test case shows how to test an integration flow that uses JMS inbound channel adapter
by using Mockito to mock a JmsTemplate (and dependent JMS objects). The example flow in
src/main/resources/integration-config.xml does not depend on JMS but includes some additional
error handling on errorChannel. The errorChannel is configured on the JMS adapter. So
We want test the entire flow for cases in which an invalid message is received via JMS and routed
to errorChannel. How do we do this without requiring a JMS message broker?
This test case shows how to test an integration flow that uses JMS inbound channel adapter by using **Mockito** to mock a *JmsTemplate* (and dependent JMS objects). The example flow in **src/main/resources/integration-config.xml** does not depend on JMS but includes some additional error handling on **errorChannel**. The **errorChannel** is configured on the JMS adapter. So we want test the entire flow for cases in which an invalid message is received via JMS and routed to **errorChannel**. How do we do this without requiring a JMS message broker?

View File

@@ -1,28 +1,19 @@
Dynamic FTP Sample
==================
This example demonstrates one technique for sending files to dynamic destinations.
See DynamicFtpChannelResolver. The resolve() method maps a customer to a
channel, where the channel is defined in a separate application context
for each customer. The application context property placeholders are configured
using the Spring 3.1 Environment management by supplying a custom property
source.
See **DynamicFtpChannelResolver**. The **resolve()** method maps a customer to a channel, where the channel is defined in a separate application context for each customer. The application context property placeholders are configured using the **Spring 3.1 Environment** management by supplying a custom property source.
A real implementation would provide these properties based on the customer; this
sample simply uses the customer as part of the host name.
A real implementation would provide these properties based on the customer; this sample simply uses the customer as part of the host name. The application context is loaded from the file in **src/main/resources/...**.
The application context is loaded from the file in src/main/resources/...
**DynamicFtpChannelResolverTests** is a simple JUnit test case that verifies the same channel is used for the same customer each time, and that a different channel is used for a different customer.
DynamicFtpChannelResolverTests is a simple JUnit test case that verifies
the same channel is used for the same customer each time, and that a
different channel is used for a different customer.
**FtpOutboundChannelAdapterSample** shows how messages sent with a different customer header are routed to a different ftp adapter. It simply verifies that the correct *UnknownHostException* is returned.
FtpOutboundChannelAdapterSample shows how messages sent with a different customer
header are routed to a different ftp adapter. It simply verifies that the
correct UnknownHostException is returned.
Notice in the config file how an expression-based router is used to invoke
the DynamicFtpChannelResolver to obtain a reference to the appropriate
channel for the customer. Notice that the channel resolver is a simple
POJO, invoked using SpEL...
Notice in the config file, how an **expression-based router** is used to invoke the **DynamicFtpChannelResolver** to obtain a reference to the appropriate channel for the customer. Notice that the channel resolver is a simple POJO, invoked using SpEL...
<int:router input-channel="toDynRouter"
expression="@channelResolver.resolve(headers['customer'])"/>

View File

@@ -1,27 +1,27 @@
Cafe Demo - Scripted Implementation
===================================
This is the scripted implementation of the classic **cafe** sample application. You can choose among **javascript**,
**groovy**, **ruby**, and **python** scripting languages. The functionality is basically identical in all cases to the
original cafe demo.
This is the scripted implementation of the classic **cafe** sample application. You can choose among **javascript**, **groovy**, **ruby**, and **python** scripting languages. The functionality is basically identical in all cases to the original cafe demo.
# Instructions for running the CafeDemo sample
The script language is passed as a command line argument. This may be run directly from maven:
>mvn clean compile
>mvn exec:exec -Dlang=[language]
$ mvn clean compile
$ mvn exec:exec -Dlang=[language]
## Groovy Control Bus
This sample also demonstrates the use of Spring Integration's **groovy control bus** which accepts
Groovy scripts as control messages. These scripts may invoke lifecycle operations on adapters or
operations on managed beans.
This sample also demonstrates the use of Spring Integration's **groovy control bus** which accepts Groovy scripts as control messages. These scripts may invoke lifecycle operations on adapters or operations on managed beans.
To demonstrate the control bus, while the CafeDemoApp is running, execute in a separate window:
>mvn exec:exec -Pcontrol-bus
$ mvn exec:exec -Pcontrol-bus
This will use groovy scripts to
* Query the waiter for the total number of orders delivered
* If the total orders > 3, stop the inbound adaptor on the cafe (the order flow). The Cafe application
will continue to run, but eventually the output will stop when all pending orders have completed.
* If the total orders > 3, stop the inbound adaptor on the cafe (the order flow). The Cafe application will continue to run, but eventually the output will stop when all pending orders have completed.

View File

@@ -0,0 +1,65 @@
Cafe Sample Application
=======================
The Cafe sample emulates a simple operation of the Coffee shop when modeled using Enterprise Integration Patterns (EIP). It is inspired by one of the samples featured in Gregor Hohpe's Ramblings. The domain is that of a Cafe, and the basic flow is depicted in the following diagram:
Barista
hotDrinks ____________________
|==========| -->| |
orders drinks / | prepareHotDrink() |
Place Order ->Cafe->|======|->OrderSplitter->|======|->DrinkRouter | |
\ coldDrinks | prepareColdDrink() |
|==========| -->| |
|____________________|
Legend: |====| - channels
The Order object may contain multiple OrderItems. Once the order is placed, a **Splitter** will break the composite order message into a single message per drink. Each of these is then processed by a **Router** that determines whether the drink is hot or cold (checking the OrderItem object's 'isIced' property). The Barista prepares each drink, but hot and cold drink preparation are handled by two distinct methods:
* prepareHotDrink
* prepareColdDrink
The prepared drinks are then sent to the Waiter where they are aggregated into a Delivery object.
## Instructions for running the CafeDemo sample
1. The example comes with two identical configurations. One is ANNOTATION-based another is XML-based
2. To run this sample simply execute the CafeDemoApp test classes in the **org.springframework.integration.samples.cafe.xml** or **org.springframework.integration.samples.cafe.annotation** package.
3. The example also provides an alternative configuration that uses AMQP channels to distribute the components in the **CafeDemo** sample. To run this alternative configuration of the sample, be sure to have a RabbitMQ broker started on localhost:5672 configured with the default guest|guest client credentials on the / vHost, then execute the following test classes in order:
1. **cafeDemoAppBaristaColdAmqp** - starts the Cold Drink Barista
2. **cafeDemoAppBaristaHotAmqp** - starts the Hot Drink Barista
3. **cafeDemoAppAmqp** - starts the Cafe Storefront (Places 100 orders on the orders queue)
4. **cafeDemoAppOperationsAmqp** - starts the Cafe Operations (OrderSplitter, DrinkRouter, PreparedDrinkAggregator)
**Note**: All AMQP exchanges, queues, and bindings needed for this sample are defined within the different xml config files that support the above test classes.
Upon running any of the alternatives, you should see the output similar to this:
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #1 for order #1: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #2 for order #2: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #3 for order #3: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #4 for order #4: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-2 prepared hot drink #1 for order #1: hot 2 shot LATTE
-----------------------
Order #1
Iced MOCHA, 3 shots.
Hot LATTE, 2 shots.
-----------------------
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #5 for order #5: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #6 for order #6: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #7 for order #7: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #8 for order #8: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #9 for order #9: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-2 prepared hot drink #2 for order #2: hot 2 shot LATTE
-----------------------
Order #2
Iced MOCHA, 3 shots.
Hot LATTE, 2 shots.
-----------------------
Happy integration :-)

View File

@@ -1,70 +0,0 @@
The Cafe sample emulates a simple operation of the Coffee shop shop when modeled using EIP
It is inspired by one of the samples featured in Gregor Hohpe's Ramblings.
The domain is that of a Cafe, and the basic flow is depicted in the following diagram:
Barista
hotDrinks ____________________
|==========| -->| |
orders drinks / | prepareHotDrink() |
Place Order ->Cafe->|======|->OrderSplitter->|======|->DrinkRouter | |
\ coldDrinks | prepareColdDrink() |
|==========| -->| |
|____________________|
Legend: |====| - channels
The Order object may contain multiple OrderItems. Once the order is placed, a Splitter will break the
composite order message into a single message per drink. Each of these is then processed by a Router that
determines whether the drink is hot or cold (checking the OrderItem object's 'isIced' property). The Barista
prepares each drink, but hot and cold drink preparation are handled by two distinct methods: 'prepareHotDrink'
and 'prepareColdDrink'. The prepared drinks are then sent to the Waiter where they are aggregated into a
Delivery object.
Instructions for running the CafeDemo sample
-------------------------------------------------------------------------------
1. The example comes with two identical configurations. One is ANNOTATION-based anther is XML-based
2. To run this sample simply execute the CafeDemoApp test classes
in the org.springframework.integration.samples.cafe.xml or
org.springframework.integration.samples.cafe.annotation package.
3. The example also provides an alternative configuration that uses AMQP channels to distribute the components
in the CafeDemo sample. To run this alternative configuration of the sample, be sure to have a RabbitMQ broker
started on localhost:5672 configured with the default guest | guest client credentials on the / vHost,
then execute the following test classes in order:
1. cafeDemoAppBaristaColdAmqp - starts the Cold Drink Barista
2. cafeDemoAppBaristaHotAmqp- starts the Hot Drink Barista
3. cafeDemoAppAmqp - starts the Cafe Storefront (Places 100 orders on the orders queue)
4. cafeDemoAppOperationsAmqp - starts the Cafe Operations (OrderSplitter, DrinkRouter, PreparedDrinkAggregator)
* Note: All AMQP exchanges, queues, and bindings needed for this sample are defined within the different xml
config files that support the above test classes.
Upon running any of the alternatives, you should see the output similar to this:
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #1 for order #1: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #2 for order #2: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #3 for order #3: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #4 for order #4: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-2 prepared hot drink #1 for order #1: hot 2 shot LATTE
-----------------------
Order #1
Iced MOCHA, 3 shots.
Hot LATTE, 2 shots.
-----------------------
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #5 for order #5: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #6 for order #6: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #7 for order #7: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #8 for order #8: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-1 prepared cold drink #9 for order #9: iced 3 shot MOCHA
INFO : org.springframework.integration.samples.cafe.annotation.Barista - task-scheduler-2 prepared hot drink #2 for order #2: hot 2 shot LATTE
-----------------------
Order #2
Iced MOCHA, 3 shots.
Hot LATTE, 2 shots.
-----------------------
Happy integration :-)

View File

@@ -0,0 +1,41 @@
Loan Broker Application
=======================
The Loan Broker sample is distributed as a Maven project, so you can run it in two ways.
### Maven (command line):
Execute **mvn install**. You should see output that looks similar to this:
. . . . .
INFO : org.springframework.integration.loanbroker.demo.LoanBrokerDemo -
********* Best Quote:
====== Loan Quote =====
Lender: StubBank-11
Loan amount: $270,279
Quotation Date: Fri Mar 12 02:19:35 EST 2010
Expiration Date: Tue Mar 16 02:19:35 EDT 2010
Term: 17 years
Rate: 5.9092593%
=======================
. . . . .
### Eclipse/STS (with m2eclipse plug-in)
1. Import project into Eclipse/STS. If the m2eclipse plugin is installed, the dependencies will be downloaded automatically.
2. Run the **org.springframework.integration.sample.loanbroker.demo.LoanBrokerDemo** class located in **src/test/java**.
# Loan Shark Extension
This extension to the loan broker sample shows how to exchange messages between Spring Integration applications (and other technologies) using UDP. Any loan quotes over 5.2% will be sent to the loanshark application.
* Deploy the **loanshark** sample to a web container (e.g. **mvn tomcat:run**); or
* run the perl (**udps.pl**) or groovy (**udps.groovy**) scripts from the command line.
Run the **LoanBrokerSharkDetectorDemo** test case. You can see the banks that were detected as loan sharks in the **loanshark web UI**.
If you use multicast (the default), messages will be received by the Roo UI war, the perl script, and the groovy script. If not using multicast, only one of the receivers can be used.
To change from multicast to unicast, change the udpOut adapter in **shark-detector-config.xml** to set **host** to **localhost** and multicast to **false**. Refer to the **README.md** file in the loanshark sample project to change it from multicast to unicast for either the Roo application or the groovy script.

View File

@@ -1,45 +0,0 @@
The Loan Broker sample is distributed as a valid Eclipse/Maven project, so you can run it in two ways.
Maven (command line):
1. Execute 'mvn install'
You should see output that looks similar to this:
. . . . .
INFO : org.springframework.integration.loanbroker.demo.LoanBrokerDemo -
********* Best Quote:
====== Loan Quote =====
Lender: StubBank-11
Loan amount: $270,279
Quotation Date: Fri Mar 12 02:19:35 EST 2010
Expiration Date: Tue Mar 16 02:19:35 EDT 2010
Term: 17 years
Rate: 5.9092593%
=======================
. . . . .
Eclipse/STS (with m2eclipse plug-in)
1. Import project into Eclipse/STS. If the m2eclipse plugin is installed, the dependencies will be downloaded automatically.
2. Run the 'org.springframework.integration.sample.loanbroker.demo.LoanBrokerDemo' class located in 'src/test/java'.
Loan Shark Extension
====================
This extension to the loan broker sample shows how to exchange messages between Spring Integration
applications (and other technologies) using UDP.
Any loan quotes over 5.2% will be sent to the loanshark application.
Deploy the loanshark sample in a web container (e.g. mvn tomcat:run); or run the perl (udps.pl)
or groovy (udps.groovy) scripts from the command line.
Run the LoanBrokerSharkDetectorDemo test case.
You can see the banks that were detected as loan sharks in the loanshark web UI.
If you use multicast (the default), messages will be received by the Roo UI war, the perl script,
and the groovy script. If not using multicast, only one of the receivers can be used.
To change from multicast to unicast, change the udpOut adapter in shark-detector-config.xml to set
'host' to "localhost" and multicast to "false". Refer to the ReadMe in loanshark to change it
from multicast to unicast for either the Roo application or the groovy script.

View File

@@ -0,0 +1,14 @@
Loan Shark Application
======================
See **README.txt** in the **loan-broker sample** for information about this sample.
To change the multicast code in **udps.groovy** to rely on unicast instead, simply change the *MulticastSocket* type to *DatagramSocket* and remove the next 2 lines that deal with joining the multicast group. Then, in the configuration of the actual adapter, set:
host="127.0.0.1" and multicast="false".
For the Roo/Spring Integration application:
* Edit the **integrationContext.xml** file
* On the udpIn adapter, set **multicast** to false and
* Remove the **multicast-address** attribute.

View File

@@ -1,10 +0,0 @@
See README.txt in loan-broker sample for information about this sample.
To change the multicast code in udps.groovy to rely on unicast instead, simply
change the MulticastSocket type to DatagramSocket and remove the next 2 lines
that deal with joining the multicast group. Then, in the configuration of the
actual adapter, set: host="127.0.0.1" and multicast="false".
For the Roo/Spring Integration application, edit the integrationContext.xml
file, on the udpIn adapter, set multicast to false and remove the
multicast-address attribute.

View File

@@ -0,0 +1,11 @@
Control Bus Sample
==================
This example demonstrates the functionality of the Control Bus component available with Spring Integration. The Control Bus uses SpEL to send a Control Message to start/stop an inbound adapter. To run the Control Bus sample simply execute **ControlBusDemoTest** in the **org.springframework.integration.samples.controlbus** package.
You will see output similar to this:
INFO : org.springframework.integration.samples.jmx.ControlBusDemo - Received before adapter started: null
INFO : org.springframework.integration.samples.jmx.ControlBusDemo - Received before adapter started: [Payload=Hello][Headers={timestamp=1294950897714, id=240e72fb-93b0-4d38-8fe8-b701cf7e9a5d}]
INFO : org.springframework.integration.samples.jmx.ControlBusDemo - Received after adapter stopped: null

View File

@@ -1,12 +0,0 @@
This example demonstrates the functionality of the Control Bus component available with Spring Integration:
Control Bus uses SpEL to send a Control Message to start/stop and inbound adapter
To run Control Bus sample simple execute ControlBusDemoTest
You will see the output similar to this
INFO : org.springframework.integration.samples.jmx.ControlBusDemo - Received before adapter started: null
INFO : org.springframework.integration.samples.jmx.ControlBusDemo - Received before adapter started: [Payload=Hello][Headers={timestamp=1294950897714, id=240e72fb-93b0-4d38-8fe8-b701cf7e9a5d}]
INFO : org.springframework.integration.samples.jmx.ControlBusDemo - Received after adapter stopped: null

View File

@@ -1,5 +1,5 @@
Spring Integration - Enricher Sample
================================
====================================
# Overview

5
basic/feed/README.md Normal file
View File

@@ -0,0 +1,5 @@
RSS Feed Sample
===============
This example demonstrates the usage of the Spring Integration RSS Feed Module using a **Feed Inbound Channel Adapter**. In order to run the sample, execute the test case located in the **org.springframework.integration.samples.feed** package.

View File

@@ -1,21 +0,0 @@
This example demonstrates the following aspects of the FEED (RSS/ATOM) support available with Spring Integration:
1. FEED Inbound Channel Adapter (receives news feeds)
#### INBOUND CHANNEL ADAPTER ####
To run INBOUND CHANNEL ADAPTER sample execute FeedInboundChannelAdapterSample test and you'll receive the feed entries for the
given URL. Feel free to plug in your own URL
The output should look similar to this:
=====
Thu Nov 18 01:28:54 EST 2010 - Rangel awaits House sanctions
Thu Nov 18 05:43:11 EST 2010 - Tweet lands woman in China labor camp
Thu Nov 18 06:13:24 EST 2010 - Bird flu is back in Hong Kong
Thu Nov 18 07:09:17 EST 2010 - Computer worm called 'game changer'
Thu Nov 18 08:00:11 EST 2010 - Murkowski declares victory in Alaska
Thu Nov 18 08:50:04 EST 2010 - Family awaits hanging verdict for mom
Thu Nov 18 09:14:20 EST 2010 - Suspect bag on Germany-bound plane
Thu Nov 18 09:47:15 EST 2010 - Zakaria: How serious is this deficit?
Thu Nov 18 09:51:15 EST 2010 - Two former Madoff employees arrested
Thu Nov 18 11:15:22 EST 2010 - WikiLeaks founder wanted in rape case
=====

View File

@@ -1,13 +1,18 @@
File Sample
===========
This example demonstrates the following aspects of the File operations support available with Spring Integration:
1. File Inbound Channel Adapter
2. File Outbound Channel Adapter
3. File-to-Bytes Transformer
as well as Poller
Furthermore, a Poller is used as well.
The use case is a simple file copy, but implemented in 3 basic flavors:
1. Binary file copy
2. Text file copy
3. Simple file copy
To run samples simply execute the 3 test cases located in the org.springframework.integration.samples.filecopy package
To run the samples simply execute the 3 test cases located in the **org.springframework.integration.samples.filecopy** package.

View File

@@ -0,0 +1,8 @@
Hello World Sample
==================
This is an obvious place to get started. It demonstrates a simple message flow represented by the diagram below:
Message -> Channel -> ServiceActivator -> QueueChannel
To run sample simply execute a test case in the **org.springframework.integration.samples.helloworld** package.

View File

@@ -1,5 +0,0 @@
This is an obvious place to get started. It demonstrates a simple message flow represented by the diagram below:
Message -> Channel -> ServiceActivator -> QueueChannel
To run sample simply execute a test case in org.springframework.integration.samples.helloworld package

15
basic/http/README.md Normal file
View File

@@ -0,0 +1,15 @@
Http Sample
===========
This example demonstrates simple request/reply communication when using a pair of **HTTP Inbound/Outbound Gateways**.
It consists of two parts - Client and Server. To run this sample:
1. Deploy project
* If you are using STS and project is imported as Eclipse project in your workspace you can just execute **Run on Server**
* You can also run **mvn clean install** and generate the WAR file that you can deploy the conventional way
2. Run the simple test client program: **org.springframework.integration.samples.http.DemoHttpClient**
The gateway initiates a simple request posting "Hello" to the server and server responds by appending **from the other side** to the message payload and returns. You should see the following output from the server:
INFO : org.springframework.integration.samples.http.HttpClientDemo - Replied with: Hello from the other side

View File

@@ -1,16 +0,0 @@
This example demonstrates simple request/reply communication when using a pair of HTTP Inbound/Outbound gateways
It consists of two parts - Client and Server.
To run this sample
1) deploy project
- If you are using STS and project is imported as Eclipse project in your workspace you can just execute 'Run on Server'
- You can also run 'mvn clean install' and generate the WAR file that you can deploy the conventional way
2) run the simple test client program: org.springframework.integration.samples.http.DemoHttpClient
The gateway initiates a simple request posting "Hello" to the server and server responds by appending "from the other side"
to the message payload and returns.
You should see the following output from the server:
INFO : org.springframework.integration.samples.http.HttpClientDemo - Replied with: Hello from the other side

25
basic/jms/README.md Normal file
View File

@@ -0,0 +1,25 @@
JMS Sample
==========
This example demonstrates the following aspects of the JMS support available with Spring Integration:
1. JMS Message-driven Channel Adapter
2. JMS Inbound Gateway
3. JMS Outbound Gateway
It also uses the following components:
1. Poller
2. Stdout Channel Adapter (from Stream support Module)
3. Stdin Channel Adapter (from Stream support Module)
The Stdout and Stdin Channel Adapters will allow you to interact with JMS via the console. It uses an embedded ActiveMQ broker.
To run the samples, simply execute the **GatewayDemo** and **ChannelAdapterDemo** classes located in the *org.springframework.integration.samples.jms* package.
When running demos you will see the following prompt:
> Please type something and hit return
* **GatewayDemo** uses *DemoBean* service, which will echo the response, upper-casing it.
* **ChannelAdapterDemo** will simply echo the response

View File

@@ -1,16 +0,0 @@
This example demonstrates the following aspects of the JMS support available with Spring Integration:
1. JMS Message-driven Channel Adapter
2. JMS Inbound Gateway
3. JMS Outbound Gateway
as well as Poller and stdout and stdin Channel Adapters (from Stream support) which will allow you to interact with JMS via the console.
It uses ActiveMQ embedded broker
To run samples simply execute GatewayDemo and ChannelAdapterDemo classes located in the org.springframework.integration.samples.jms package
When running demos you will see the following prompt:
> Please type something and hit return
GatewayDemo uses DemoBean service which will echo the response upper-casing it
ChannelAdapterDemo will simply echo the response

38
basic/jmx/README.md Normal file
View File

@@ -0,0 +1,38 @@
JMX Sample
==========
This example demonstrates the following aspects of the JMX support available with Spring Integration:
1. JMX Attribute Polling Channel
2. JMX Operation Invoking Channel Adapter
**StopWatch** is a Managed Bean. It is bootstraped and deployed using annotation support (*@Component*, *@ManagedResource*) and component scanning functionality provided by Spring JMX. Internally StopWatch simply runs a task that increments the value of its **seconds** attribute by 1 every second.
The **JMX Attribute Polling Channel Adapter** simply polls a managed attribute **seconds** of the **StopWatch** MBean identified by the name:
org.springframework.integration.samples.jmx:type=StopWatch,name=stopWatch
It sends its value to a **seconds** channel. The interesting part is that the **seconds** channel is a *publish-subscribe-channel* and has two subscribers:
- **Stdout Channel Adapter** which prints the value of the polled attribute to the console
- **Filter** which essentially waits till the payload value is 10
Once the payload value is 10, the filter sends the Message to a **reset** channel, which is represented as **JMX Operation Invoking Channel Adapter**. That adapter simply invokes the **reset** operation on the same **StopWatch** MBean resetting the **seconds** attribute value back to 1 and the process repeats.
To run the JMX Adapter sample simply execute **JmxAdapterDemoTest**. You will see output similar to this, which will loop for ~20 seconds:
1
2
3
4
5
6
7
8
9
10
1
2
3
. . .

View File

@@ -1,33 +0,0 @@
This example demonstrates the following aspects of the JMX support available with Spring Integration:
1. JMX Attribute Polling Channel
2. JMX Operation Invoking Channel Adapter
StopWatch is a Managed Bean. It is bootstraped and deployed using annotation support (@Component, @ManagedResource)
and component scanning functionality provided by Spring JMX. Internally StopWatch simply runs a task that increments the
value of its 'seconds' attribute by 1 every second.
JMX Attribute Polling Channel Adapter simply polls a managed attribute 'Seconds' of the StopWatch MBean identified by the 'org.springframework.integration.samples.jmx:type=StopWatch,name=stopWatch' name and sends its value to a 'seconds' channel.
The interesting this is that 'seconds' channel is a publish-subscribe-channel and has two subscribers;
- Stdout Channel Adapter which prints the value of the polled attribute to the console;
- Filter which essentially waits till payload value is 10;
Once the payload value is 10 filter sends the Message to a 'reset' channel which is represented as JMX Operation Invoking Channel Adapter
which simply invokes 'reset' operation on the same StopWatch MBean resetting 'Seconds' attribute value back to 1 and the process repeats.
To run JMX Adapter sample simple execute JmxAdapterDemoTest
You will see the output similar to this which will loop for ~ 20 sec:
1
2
3
4
5
6
7
8
9
10
1
2
3
. . .

33
basic/mail/README.md Normal file
View File

@@ -0,0 +1,33 @@
Mail sample
===========
This example demonstrates the following aspects of the Mail support available with Spring Integration:
1. IMAP IDLE Inbound Channel Adapter (with sample GMail configuration)
2. POP3 Inbound Channel Adapter (with sample GMail configuration)
Simply change configuration file (src/main/resources/META-INF/spring/integration/**gmail-imap-idle-config.xml** or **gmail-pop3-config.xml**) to point to your existing GMail account (replace userid and password) and run:
* GmailInboundImapIdleAdapterTest.java - for IMAP IDLE sample
* GmailInboundPop3AdapterTest - for POP3 sample
**IMPORTANT**: You must enable POP3/IMAP access for your google account (follow **Settings** link on your GMail page).
Once started, start sending emails to your account. You'll see that adapter will receive messages and will publish them to a channel specified by 'channel' attribute.
You should see the output similar to this:
DEBUG: org.springframework.integration.mail.ImapMailReceiver - connecting to store [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
DEBUG: org.springframework.integration.mail.ImapMailReceiver - opening folder [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
INFO : org.springframework.integration.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
Send a Message and you will see:
DEBUG: org.springframework.integration.mail.ImapMailReceiver - found 2 new messages
DEBUG: org.springframework.integration.mail.ImapIdleChannelAdapter - received 2 mail messages
INFO : org.springframework.integration.samples.mail.imapidle.GmailImapIdleAdapterTest - Message: [Payload=javax.mail.internet.MimeMessage@1f00aff5][Headers={$timestamp=1284745370451, $id=9dfd4b30-2d15-4905-9301-f39aa4073ea0}]
INFO : org.springframework.integration.samples.mail.imapidle.GmailImapIdleAdapterTest - Message: [Payload=javax.mail.internet.MimeMessage@66200db9][Headers={$timestamp=1284745370452, $id=4b8322ba-f469-4afc-af4f-1332a94b735b}]
DEBUG: org.springframework.integration.mail.ImapIdleChannelAdapter - waiting for mail
DEBUG: org.springframework.integration.mail.ImapMailReceiver - opening folder [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
You can experiment with various attributes of the adapter (e.g., should-delete-messages, should-mark-messages-as-read etc...)

View File

@@ -1,33 +0,0 @@
This example demonstrates the following aspects of the Mail support available with Spring Integration:
1. IMAP IDLE Inbound Channel Adapter (with sample GMail configuration)
2. POP3 Inbound Channel Adapter (with sample GMail configuration)
Simply change configuration file (src/main/resources/META-INF/spring/integration/gmail-imap-idle-config.xml or gmail-pop3-config.xml)
to point to your existing GMail account (replace userid and password) and run:
GmailInboundImapIdleAdapterTest.java - for IMAP IDLE sample
GmailInboundPop3AdapterTest - for POP3 sample
IMPORTANT: You must enable POP3/IMAP access for your google account (follow "Settings" link on your GMail page).
Once started start sending emails to your account. You'll see that adapter will receive messages and will
publish them to a channel specified by 'channel' attribute.
Make sure you enable your GMail account for IMAP/POP3 access.
You should see the output similar to this:
DEBUG: org.springframework.integration.mail.ImapMailReceiver - connecting to store [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
DEBUG: org.springframework.integration.mail.ImapMailReceiver - opening folder [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
INFO : org.springframework.integration.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
Send a Message and you will see:
DEBUG: org.springframework.integration.mail.ImapMailReceiver - found 2 new messages
DEBUG: org.springframework.integration.mail.ImapIdleChannelAdapter - received 2 mail messages
INFO : org.springframework.integration.samples.mail.imapidle.GmailImapIdleAdapterTest - Message: [Payload=javax.mail.internet.MimeMessage@1f00aff5][Headers={$timestamp=1284745370451, $id=9dfd4b30-2d15-4905-9301-f39aa4073ea0}]
INFO : org.springframework.integration.samples.mail.imapidle.GmailImapIdleAdapterTest - Message: [Payload=javax.mail.internet.MimeMessage@66200db9][Headers={$timestamp=1284745370452, $id=4b8322ba-f469-4afc-af4f-1332a94b735b}]
DEBUG: org.springframework.integration.mail.ImapIdleChannelAdapter - waiting for mail
DEBUG: org.springframework.integration.mail.ImapMailReceiver - opening folder [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
You can experiment with various attributes of the adapter (e.g., should-delete-messages, should-mark-messages-as-read etc...)

View File

@@ -1,15 +1,16 @@
Odd Even Sample
===============
This example demonstrates the following aspects of the CORE EIP support available with Spring Integration:
1. Inbound Channel Adapter
2. Filter
3. Router (SpEL based)
4. Poller with Cron and Interval Trigers
Messages are simply being emitted by the Poller (interval based or cron) triggering 'next()' method of Counter class and
sent to a 'numbers' channel - Inbound Channel Adapter. From the 'numbers' channel Messages are sent
to an expression-based router (Spring Expression Language). ALl that router does is simply routing messages
to OddLogger and EvenLogger service
Messages are simply being emitted by the Poller (interval based or cron) triggering '**next()**' method of Counter class and sent to a '**numbers**' channel - Inbound Channel Adapter. From the '**numbers**' channel Messages are sent to an expression-based router (Spring Expression Language). All that the router does is simply routing messages to *OddLogger* and *EvenLogger* service
To execute the Interval-based sample simply run IntervalOddEvenDemoTest class and for Cron-based sample simply
To execute the Interval-based sample simply run **IntervalOddEvenDemoTest** class and for Cron-based sample simply
run CronOddEvenDemo class, You should see the output similar to this:
INFO : org.springframework.integration.samples.oddeven.OddLogger - odd: 1 at 2010-09-16 05:55:46

28
basic/quote/README.md Normal file
View File

@@ -0,0 +1,28 @@
Quote Sample
============
This example demonstrates the following aspects of the CORE EIP support available with Spring Integration:
1. Channel Adapter (Inbound and Stdout)
2. Poller with Interval Trigers
3. Service Activator
It is a very simple example that introduces you to the Channel adapters and Pollers.
Messages are simply being emitted by the Poller (interval based) triggering **nextTicker()** method of *TickerStream* class and sent to a **tickers** channel from which they are retrieved by the *TickerStream* service.
*TickerStream* service generates random ticker symbols sending them to the **quotes** channel from which they are retrieved by the *QuoteService* (annotation based Service Activator). *QuoteService* generates random quotes sending them to the *Stdout Channel Adapter* where they are printed to a console.
To execute sample simply run **QuoteDemoTest**. You should see the output similar to this:
XNY: 90.03
XMR: 17.11
IWR: 35.85
KHR: 54.43
WUW: 95.29
YYC: 7.44
DYW: 84.76
TIW: 28.31
HGE: 28.90

View File

@@ -1,24 +0,0 @@
This example demonstrates the following aspects of the CORE EIP support available with Spring Integration:
1. Channel Adapter (Inbound and Stdout)
2. Poller with Interval Trigers
3. Service Activator
A very simple example that introduces you to the Channel adapters and Pollers.
Messages are simply being emitted by the Poller (interval based) triggering 'nextTicker()' method of TickerStream class and
sent to a 'tickers' channel from which they are retrieved by the TickerStream service. TockerStream service generates random
ticker symbols sending them to the 'quotes' channel from which they are retrieved by the QuoteService (annotation based Service Activator).
QuoteService generates random quotes sending them to the Stdout Channel Adapter where they are printed to a console.
To execute sample simply run QuoteDemoTest. You should see the output similar to this:
XNY: 90.03
XMR: 17.11
IWR: 35.85
KHR: 54.43
WUW: 95.29
YYC: 7.44
DYW: 84.76
TIW: 28.31
HGE: 28.90

71
basic/sftp/README.md Normal file
View File

@@ -0,0 +1,71 @@
SFTP Sample
===========
This example demonstrates the following aspects of the SFTP support available with Spring Integration:
1. SFTP Inbound Channel Adapter (transfers files from remote to local directory)
2. SFTP Outbound Channel Adapter (transfers files from local to the remote directory)
In order to run this sample you need to:
1. generate private/public keys. Below is simple directions what needs to be done
2. update user.properties file with appropriate values
3. run the sample
## INBOUND CHANNEL ADAPTER
To run the NBOUND CHANNEL ADAPTER sample execute **SftpInboundReceiveSample** test. You will see that based on configuration it will access the sample remote directory which contains 3 files and will attempt to securely copy them to a local directory which will be generated. The output should look like this:
Received first file message: [Payload=local-dir/a.txt][Headers={timestamp=1290066001349, id=9dca686a-cfd4-4d96-a1a7-761feb005e43}]
Received second file message: [Payload=local-dir/b.txt][Headers={timestamp=1290066001650, id=d33a475d-fa71-4c5b-b73e-3147969f1c6f}]
No third file was received null
As you can see, although the remote directory had 3 files we only received 2 since we were filtering only the files that end with **txt**.
## OUTBOUND CHANNEL ADAPTER
To run the OUTBOUND CHANNEL ADAPTER sample execute the **SftpOutboundTransferSample** test. You will see that based on the configuration it will attempt to transfer this **readme.txt** file to a remote directory **remote-target-dir**. The output should look like this:
Successfully transfered 'readme.txt' file to a remote location under the name 'readme.txt_foo'
NOTE: You can see that we are using *SpEL* via the **remote-filename-generator-expression** attribute to define the remote file name by simply appending **_foo** to the original file name.
## OUTBOUND GATEWAY
Run the **FtpOutoundGateway** sample as a JUnit test; it creates 2 files, retrieves and removes them over ftp. It cleans up by removing the retrieved files. The test assumes full access to the filesystem via **/tmp** where the test files are created. Requires **sshd** to be running on localhost.
This sample uses a property **private.keyfile** to point to the location of your private key. Requires setting of **user**, **private.keyfile** and, optionally, **passphrase** in **user.properties**.
### HOW TO GENERATE KEYS
>$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ozhurakousky/.ssh/id_rsa): ./sftp_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./sftp_rsa.
Your public key has been saved in ./sftp_rsa.pub.
The key fingerprint is:
2c:30:7c:18:3c:a0:d5:83:68:78:7e:c1:5f:c1:3e:3d ozhurakousky@oleg.home
The key's randomart image is:
+--[ RSA 2048]----+
|..o*. ... |
|o+o.Bo o |
|oo ==.o . |
| . .+..o E |
| . . S. . |
| . |
| |
| |
| |
+-----------------+
>$ ls
sftp_rsa sftp_rsa.pub
>$
* Create a file ~/.ssh/authorized_keys and give it the required permissions
>$ chmod 600 ~/.ssh/authorized_keys
* Then edit **authorized_keys** file and paste in the contents of the public key file **sftp_rsa.pub**.
* Move your private key file **sftp_rsa** to META-INF/keys directory

View File

@@ -1,79 +0,0 @@
This example demonstrates the following aspects of the SFTP support available with Spring Integration:
1. SFTP Inbound Channel Adapter (transfers files from remote to local directory)
2. SFTP Outbound Channel Adapter (transfers files from local to the remote directory)
In order to run this sample you need to
1. generate private/public keys. Below is simple directions what needs to be done
2. update user.properties file with appropriate values
3. run the sample
#### INBOUND CHANNEL ADAPTER ####
To run INBOUND CHANNEL ADAPTER sample execute SftpInboundReceiveSample test. You will see that based on configuration it
will access sample remote directory which contains 3 files and will attept to securly copy them to a local directory which
will be generated.
The output should look like this:
=====
Received first file message: [Payload=local-dir/a.txt][Headers={timestamp=1290066001349, id=9dca686a-cfd4-4d96-a1a7-761feb005e43}]
Received second file message: [Payload=local-dir/b.txt][Headers={timestamp=1290066001650, id=d33a475d-fa71-4c5b-b73e-3147969f1c6f}]
No third file was received null
=====
As you can see, although the remote directory had 3 files we only received 2 since we were filtering only the files that end with 'txt'.
#### OUTBOUND CHANNEL ADAPTER ####
To run OUTBOUND CHANNEL ADAPTER sample execute SftpOutboundTransferSample test. You will see that based on configuration it
will attempt to transfer this 'readme.txt' file to a remote directory 'remote-target-dir'
The output should look like this:
=====
Successfully transfered 'readme.txt' file to a remote location under the name 'readme.txt_foo'
=====
NOTE: You can see that we are using SpEL via 'remote-filename-generator-expression' attribute to define the remote file name by
simply appending '_foo' to the original file name.
#### OUTBOUND GATEWAY ####
Run the FtpOutoundGateway sample as a JUnit test; it creates 2 files, retrieves and removes them over ftp. It cleans up
by removing the retrieved files. Test assumes full access to the filesystem via /tmp where the test files are created.
Requires sshd to be running on localhost.
This sample uses a property 'private.keyfile' to point to the location of your private key.
Requires setting of user, private.keyfile and, optionally, passphrase in user.properties.
====== HOW TO GENERATE KEYS ======
>$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ozhurakousky/.ssh/id_rsa): ./sftp_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./sftp_rsa.
Your public key has been saved in ./sftp_rsa.pub.
The key fingerprint is:
2c:30:7c:18:3c:a0:d5:83:68:78:7e:c1:5f:c1:3e:3d ozhurakousky@oleg.home
The key's randomart image is:
+--[ RSA 2048]----+
|..o*. ... |
|o+o.Bo o |
|oo ==.o . |
| . .+..o E |
| . . S. . |
| . |
| |
| |
| |
+-----------------+
>$ ls
sftp_rsa sftp_rsa.pub
>$
2. Create a file ~/.ssh/authorized_keys and give it the required permissions
>$ chmod 600 ~/.ssh/authorized_keys
3. Then edit 'authorized_keys' file and paste in the contents of the public key file 'sftp_rsa.pub' .
4. Move your private key file 'sftp_rsa' to META-INF/keys directory

View File

@@ -0,0 +1,49 @@
TCP Sample
==========
This is a place to get started with the Transmission Control Protocol (TCP). It demonstrates a simple message flow represented by the diagram below:
Gateway -> Channel -> TcpOutboundGateway -> <===Socket===> -> TcpInboundGateway -> Channel -> ServiceActivator
The service returns a response which the inbound gateway sends back over the socket to the outbound gateway and the result is returned to the client that invoked the original SimpleGateway method.
To run sample simply execute a test case in **org.springframework.integration.samples.tcpclientservice** package.
Note that the test case includes an alternative configuration that uses the in-built conversion service and the channel dataType attribute, instead of explicit transformers, to convert from byte arrays to Strings.
Simply change the @ContextConfiguration to switch between the two techniques. In addition, a simple telnet server is provided; see **TelnetServer** in src/main/java. Run this class as a Java application and then use telnet to connect to the service (**telnet localhost 11111**).
Messages sent will be returned, preceded by 'echo:'.
$ telnet localhost 11111
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hello world!
echo:Hello world!
Test
echo:Test
^]
telnet> quit
Connection closed.
Note that the test case also demonstrates error handling on an inbound gateway using direct channels. If the payload is 'FAIL', the EchoService throws an exception. The gateway is configured with an error-channel attribute. Messages sent to that channel are consumed by a transformer that concatenates the inbound message payload with the message text from the thrown exception, returning **FAIL:Failure Demonstration** over the TCP socket.
This can also be demonstrated with the telnet client thus...
$ telnet localhost 11111
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hello world!
echo:Hello world!
FAIL
FAIL:Failure Demonstration
Hello
echo:Hello
^]
telnet> quit
Connection closed.

View File

@@ -1,58 +0,0 @@
This is a place to get started with tcp. It demonstrates a simple message flow represented by the diagram below:
Gateway -> Channel -> TcpOutboundGateway -> <===Socket===> -> TcpInboundGateway -> Channel -> ServiceActivator
The service returns a response which the inbound gateway sends back over the socket to the outbound gateway
and the result is returned to the client that invoked the original SimpleGateway method.
To run sample simply execute a test case in org.springframework.integration.samples.tcpclientservice package.
Note that the test case includes an alternative configuration that uses the in-built conversion service
and the channel dataType attribute, instead of explicit transformers, to convert from byte arrays to Strings.
Simply change the @ContextConfiguration to switch between the two techniques.
In addition, a simple telnet server is provided; see TelnetServer in src/main/java. Run this class as a
java application and then use telnet to connect to the service ('telnet localhost 11111').
Messages sent will be returned, preceded by 'echo:'.
$ telnet localhost 11111
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hello world!
echo:Hello world!
Test
echo:Test
^]
telnet> quit
Connection closed.
Note that the test case also demonstrates error handling on an inbound gateway using direct channels.
If the payload is 'FAIL', the EchoService throws an exception. The gateway is configured
with an error-channel attribute. Messages sent to that channel are consumed by a transformer
that concatenates the inbound message payload with the message text from the thrown
exception, returning 'FAIL:Failure Demonstration' over the TCP socket.
This can also be demonstrated with the telnet client thus...
$ telnet localhost 11111
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hello world!
echo:Hello world!
FAIL
FAIL:Failure Demonstration
Hello
echo:Hello
^]
telnet> quit
Connection closed.

View File

@@ -0,0 +1,41 @@
Testing Examples
================
A series of test cases that show techniques to test Spring Integration applications.
## ...chain.SpelChainTests.java
This test case shows how to test a fragment of a larger integration flow. In this example, we have a simple chain containing a header enricher and a transformer. It uses Direct channels. The test case shows how to bridge the output channel to a queue channel so we can retrieve the output message after the test executes and verify the appropriate actions were applied to the input message.
## ...splitter.CommaDelimitedSplitterTests.java
This test case shows both unit testing a custom splitter class as well as testing it within a Spring Integration flow fragment.
## ...aggregator.CommaDelimitedAggregatorTests.java
This test case shows both unit testing a custom aggregator class as well as testing it within a Spring Integration flow fragment.
## ...externalgateway.ExternalGatewaySubstitutionTests.java
This example is a little more complex. The application is a simplified version of a travel demo presented at SpringOne in 2010. You do not need to fully understand the application for the purposes of this demonstration. Suffice it to say that a zip (postal) code is sent to two outbound gateways (one web service, one http) and the weather and traffic for that zip code are aggregated together. You can run the "real" application by executing the Main class in src/main/java and entering a valid zip code in the console.
In many cases, when integrating with external services, we can't rely on those services being available while we test. Consequently, we need a mechanism to stub out those services so we can run the remainder of the flow in a repeatable manner without need for connectivity to the services. This example uses dummy service activators in place of the real outbound gateways.
This separation of 'infrastructure' from application beans is similar to the way we separate *DataSource*, *ConnectionFactory* beans etc so that the application can be tested with local versions.
## ...router.PetRouterTests.java
This test case shows both unit testing a custom router class as well as testing it within a Spring Integration flow fragment. A second filter is defined, that uses a discard channel for filtered messages.
## ...filter.PetFilterTests.java
This test case shows both unit testing a custom filter class as well as testing it within a Spring Integration flow fragment.
## ...gateway.GatewayTests.java
This test case shows how to verify that a <gateway/> has been configured to work as expected, including @Header parameters on the gateway method and <method/> elements in the configuration.
## ...errorhandling.GatewayTests.java
This test case shows how to verify that gateway error-channel configuration is correct, and show how to extract the cause and failed message from the MessagingException.

View File

@@ -1,77 +0,0 @@
A series of test cases that show techniques to test Spring Integration applications.
Examples
========
...chain.SpelChainTests.java
This test case shows how to test a fragment of a larger integration flow.
In this example, we have a simple chain containing a header enricher and
a transformer. It uses Direct channels. The test case shows how to
bridge the output channel to a queue channel so we can retrieve the
output message after the test executes and verify the appropriate
actions were applied to the input message.
...splitter.CommaDelimitedSplitterTests.java
This test case shows both unit testing a custom splitter class as well
as testing it within a Spring Integration flow fragment.
...aggregator.CommaDelimitedAggregatorTests.java
This test case shows both unit testing a custom aggregator class as well
as testing it within a Spring Integration flow fragment.
...externalgateway.ExternalGatewaySubstitutionTests.java
This example is a little more complex. The application is simplified version of a
travel demo presented at SpringOne in 2010. You do not need to fully understand
the application for the purposes of this demonstration. Suffice it to
say that a zip code is sent to two outbound gateways (one web service, one http) and
the weather and traffic for that zip code are aggregated together. You
can run the "real" application by executing the Main class in src/main/java
and entering a valid zip code in the console.
In many cases, when integrating with external services, we can't rely on
those services being available while we test. Consequently, we need a
mechanism to stub out those services so we can run the remainder of the
flow in a repeatable manner without need for connectivity to the services.
This example uses dummy service activators in place of the real outbound
gateways.
This separation of 'infrastructure' from application beans is similar to
the way we separate DataSource, ConnectionFactory beans etc so that the
application can be tested with local versions.
...router.PetRouterTests.java
This test case shows both unit testing a custom router class as well
as testing it within a Spring Integration flow fragment.
A second filter is defined, that uses a discard channel for filtered
messages.
...filter.PetFilterTests.java
This test case shows both unit testing a custom filter class as well
as testing it within a Spring Integration flow fragment.
...gateway.GatewayTests.java
This test case shows how to verify that a <gateway/> has been configured
to work as expected, including @Header parameters on the gateway method
and <method/> elements in the configuration.
...errorhandling.GatewayTests.java
This test case shows how to verify that gateway error-channel configuration
is correct, and show how to extract the cause and failed message from
the MessagingException.

36
basic/twitter/README.md Normal file
View File

@@ -0,0 +1,36 @@
Twitter Sample
==============
This example demonstrates the following aspects of the Twitter support available with Spring Integration:
1. Twitter Inbound Channel Adapter - allows you to receive HOME status updates
2. Twitter Inbound Search Channel Adapter - allows you to receive HOME status updates
3. Twitter Outboud Channel Adapter - allows send status updates
In order to run this sample you need to configure OAuth and set the values in the OAuth properties.
To use OAuth authentication/authorization with Twitter you must create new Application on Twitter Developers site.
Follow the directions below to create a new application and obtain consumer keys and access token:
* Go to http://dev.twitter.com/
* Click on 'Register an app' link and fill out all required fields on the form provided;
* Set 'Application Type' to 'Client' and depending on the nature of your application
* Select 'Default Access Type' as 'Read & Write' or 'Read-only'
* Submit the form.
* If everything is successful you'll be presented with the 'Consumer Key' and 'Consumer Secret'.
* Copy both values in the safe place.
* On the same page you should see 'My Access Token' button on the side bar (right).
* Click on it and you'll be presented with two more values: 'Access Token' and 'Access Token Secret'.
* Copy these values in a safe place as well.
When done fill out **oauth.properties** file so it looks similar to this.
twitter.oauth.consumerKey=4XzBPabcJQxyBzzzH3TrRQ
twitter.oauth.consumerSecret=ab2piKdMfPu8bVa3ab6DAIvIWEVZyMDL0RSEN2I8
twitter.oauth.accessToken=21691649-4XYZY5iJEOfz2A9qCFd9SjBRGb3HLmIm4HNE6AMv4
twitter.oauth.accessTokenSecret=AbRxUAvyNCtqQtvxFK8w5ZMtMj20KFhB6oEfTA0
NOTE: the above values are not real ;)
Now you ready to execute samples. Just run each sample and look for the output produced by the inbound adapters (**TwitterSearchSample.java** and **TwitterTimelineUpdateSample.java**)
The outbound adapter sample (**TwitterSendUpdatesSample.java**) will not produce any output. Instead within seconds you should see your tweet.

View File

@@ -1,36 +0,0 @@
This example demonstrates the following aspects of the Twitter support available with Spring Integration:
1. Twitter Inbound Channel Adapter - allows you to receive HOME status updates
2. Twitter Inbound Search Channel Adapter - allows you to receive HOME status updates
3. Twitter Outboud Channel Adapter - allows send status updates
In order to run this sample you need to configure OAuth and set the values in the OAuth properties.
================
To use OAuth authentication/authorization with Twitter you must create new Application on Twitter Developers site.
Follow the directions below to create a new application and obtain consumer keys and access token:
- Go to http://dev.twitter.com/
- Click on 'Register an app' link and fill out all required fields on the form provided;
- Set 'Application Type' to 'Client' and depending on the nature of your application select
'Default Access Type' as 'Read & Write' or 'Read-only' and Submit the form.
- If everything is successful you'll be presented with the 'Consumer Key' and 'Consumer Secret'.
- Copy both values in the safe place.
On the same page you should see 'My Access Token' button on the side bar (right).
- Click on it and you'll be presented with two more values: 'Access Token' and 'Access Token Secret'.
Copy these values in a safe place as well.
When done fill out oauth.properties file so it looks similar to this.
twitter.oauth.consumerKey=4XzBPabcJQxyBzzzH3TrRQ
twitter.oauth.consumerSecret=ab2piKdMfPu8bVa3ab6DAIvIWEVZyMDL0RSEN2I8
twitter.oauth.accessToken=21691649-4XYZY5iJEOfz2A9qCFd9SjBRGb3HLmIm4HNE6AMv4
twitter.oauth.accessTokenSecret=AbRxUAvyNCtqQtvxFK8w5ZMtMj20KFhB6oEfTA0
NOTE: the above values are not real ;)
=======================
Now you ready to execute samples. Just run each sample and look for the output produced by the
inbound adapters (TwitterSearchSample.java and TwitterTimelineUpdateSample.java)
The outbound adapter sample (TwitterSendUpdatesSample.java) will not produce any output.
Instead within seconds you should see your tweet.

View File

@@ -0,0 +1,13 @@
Web Service Inbound Gateway Sample
==================================
This sample demonstrates a barebones *inbound Web Service Gateway*. Take a look at **web.xml** in the WEB-INF directory where the Spring Web Services Message-dispatching Servlet is defined. Then have a look at the **spring-ws-config.xml** file (also in the WEB-INF directory) where the Spring WS EndpointMapping is defined. Finally view the Spring Integration configuration in the **inbound-gateway-config.xml** file within the **org.springframework.integration.samples.ws** package where the actual gateway is defined along with a channel and service-activator.
To use the gateway, you can run the tests that are located within the **src/test/java** directory. One is for standalone testing of the gateway itself, while the other tests the gateway running on a web server. The latter uses Spring Web Services' client-side support. Alternatively, you can simply start the server, and then send invocations with any standalone HTTP client testing tool. The request format should be similar to the following and should be POSTed to the service URL (e.g. http://localhost:8080/ws-inbound-gateway/echoservice):
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<echoRequest xmlns="http://www.springframework.org/spring-ws/samples/echo">hello</echoRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

View File

@@ -1,10 +0,0 @@
This sample demonstrates a barebones inbound Web Service Gateway. Take a look at "web.xml" in the WEB-INF directory where the Spring Web Services Message-dispatching Servlet is defined. Then have a look at the "spring-ws-config.xml" file (also in the WEB-INF directory) where the Spring WS EndpointMapping is defined. Finally view the Spring Integration configuration in the "inbound-gateway-config.xml" file within the "org.springframework.integration.samples.ws" package where the actual gateway is defined along with a channel and service-activator.
To use the gateway, you can run the tests that are located within the "src/test/java" directory. One is for standalone testing of the gateway itself, while the other tests the gateway running on a web server. The latter uses Spring Web Services' client-side support. Alternatively, you can simply start the server, and then send invocations with any standalone HTTP client testing tool. The request format should be similar to the following and should be POSTed to the service URL (e.g. http://localhost:8080/ws-inbound-gateway/echoservice):
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<echoRequest xmlns="http://www.springframework.org/spring-ws/samples/echo">hello</echoRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

View File

@@ -0,0 +1,17 @@
WS Outbound Gateway Sample
==========================
This example demonstrates the following aspects of the WS support available with Spring Integration:
1. WS Outbound Gateway
2. Content Enricher
3. Composed Message Processor
A very simple example that show you how easy it is to invoke a SOAP based service using Spring Integration.
* A Message is simply sent to a channel, where it is retrieved by a *Chain* which consists of a *Header Enricher* and a *WS Outbound Gateway*.
* The *Header Enricher* enriches the Message with the SOAP action header.
* The *WS Outbound Gateway* converts the Message to a SOAP request and sends it to a remote service, which converts a temperature from
Fahrenheit to Celsius and the result is printed to the console.
To run sample simply execute **WebServicesDemoTest**

View File

@@ -1,15 +0,0 @@
This example demonstrates the following aspects of the WS support available with Spring Integration:
1. WS Outbound Gateway
as well as:
2. Content Enricher
3. Composed Message Processor
A very simple example that show you how easy it is to invoke a SOAP based service using Spring Integration
Message is simply sent to a channel where it is retrieved by a Chain which consists of Header Enricher and WS Outbound Gateway
Header Enricher enriches Message with the SOAP action header
WS Outbound Gateway converts Message to a SOAP request and sends it to a remote service which converts temperature from
Fahrenheit to Celsius and sent back where the result is printed to a console.
To run sample simply execute WebServicesDemoTest

30
basic/xml/README.md Normal file
View File

@@ -0,0 +1,30 @@
XML Sample
==========
This example demonstrates the following aspects of the XML support available with Spring Integration:
1. XPath Splitter - to split an order with multiple items into several order messages for separate processing.
2. XPath Router - to route messages according to the evaluation of an XPath expression which tests to see if the order item is in stock.
3. XPath Expression - which tests to see if the order item is in stock
3. XSLT Transformer - to transform the payload of the order message into a resupply message where the order item is found to be out of stock.
To run sample simply execute **BookOrderProcessingTest**. You should see the following output:
INFO : org.springframework.integration.samples.xml.WarehouseDispatch - Warehouse dispatching orderItem:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<orderItem in-stock="true" xmlns="http://www.example.org/orders">
<isbn>0321200683</isbn>
<quantity>2</quantity>
</orderItem>
INFO : org.springframework.integration.samples.xml.ExternalResupply - Placing resupply order:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bb:bigBooksOrder xmlns:bb="http://www.example.org/orders-bigbooks"
xmlns:sb="http://www.example.org/orders">
<bb:order>
<bb:purchaser>smallbooks</bb:purchaser>
<bb:quantity>5</bb:quantity>
<bb:isbn>1590596439</bb:isbn>
</bb:order>
</bb:bigBooksOrder>

View File

@@ -1,25 +0,0 @@
This example demonstrates the following aspects of the XML support available with Spring Integration:
1. XPath Splitter - to split an order with multiple items into several order messages for separate processing.
2. XPath Router - to route messages according to the evaluation of an XPath expression which tests to see if the order item is in stock.
3. XPath Expression - which tests to see if the order item is in stock
3. XSLT Transformer - to transform the payload of the order message into a resupply message where the order item is found to be out of stock.
To run sample simply execute BookOrderProcessingTest. You should see the following output:
INFO : org.springframework.integration.samples.xml.WarehouseDispatch - Warehouse dispatching orderItem:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<orderItem in-stock="true" xmlns="http://www.example.org/orders">
<isbn>0321200683</isbn>
<quantity>2</quantity>
</orderItem>
INFO : org.springframework.integration.samples.xml.ExternalResupply - Placing resupply order:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bb:bigBooksOrder xmlns:bb="http://www.example.org/orders-bigbooks"
xmlns:sb="http://www.example.org/orders">
<bb:order>
<bb:purchaser>smallbooks</bb:purchaser>
<bb:quantity>5</bb:quantity>
<bb:isbn>1590596439</bb:isbn>
</bb:order>
</bb:bigBooksOrder>

19
basic/xmpp/README.md Normal file
View File

@@ -0,0 +1,19 @@
XMPP Sample
===========
This example was prepared for testing with GoogleTalk and demonstrates the following aspects of the *Extensible Messaging and Presence Protocol* (XMPP) support available with Spring Integration:
1. XMPP Inbound Channel Adapter - receive instant messages.
2. XMPP Outboud Channel Adapter - send instant messages.
In order to run this sample you need to provide correct values in **xmpp.properties**.
Everything there was already preset. The only 3 properties you need to provide values for are:
* user.login
* user.password
* send.to.user
You'll also need to test it with your friend or have two Google accounts setup.
To test **SendInstantMessageSample.java**, first log on to the account identified via **send.to.user** property and make sure that that account is in your buddy list. Then run the demo.
To test **ReceiveInstantMessageSample.java**, first log on to the account identified via **send.to.user** property. Then run the demo. When demo class is started you'll see on GoggleTalk that your buddy (ReceiveInstantMessageSample.java) has just signed on. Now you can send a message from GoogleTalk and see it appear ion the console.

View File

@@ -1,21 +0,0 @@
This example was prepared for testing with GoogleTalk and
demonstrates the following aspects of the XMPP support available with Spring Integration:
1. XMPP Inbound Channel Adapter - receive instant messages.
2. XMPP Outboud Channel Adapter - send instant messages.
In order to run this sample you need to provide correct values in xmpp.properties.
Everything there was already preset. The only 3 properties you need to provide values for are:
- user.login
- user.password
- send.to.user
You'll also need to test it with your friend or have two Google accounts setup
To test SendInstantMessageSample.java, first log on to the account identified via 'send.to.user' property
and make sure that that account is in your buddy list. Then run the demo.
To test ReceiveInstantMessageSample.java, first log on to the account identified via 'send.to.user' property.
Then run the demo. When demo class is started you'll see on GoggleTalk that your buddy (ReceiveInstantMessageSample.java)
has just signed on. Now you can send a message from GoogleTalk and see it appear ion the console.

View File

@@ -0,0 +1,26 @@
Async Gateway Sample
====================
Gateways provide a convenient way to expose a Proxy over a service-interface thus giving you POJO-based access to a messaging system (based on objects in your own domain, or primitives/Strings, etc). However, when you invoke a method, you expect the method to return. A gateway's method call represents a contract with the messaging system, which states that for each request, there will always be a reply. Therefore you must always guarantee that your message flow is in compliance with such a contract.
But what about the cases where you can't (e.g, message was filtered out and discarded or routed into a unidirectional sub-flow)?
Starting with Spring Integration 2.0, we are introducing support for an Asynchronous Gateway, which is a convenient way to initiate flows, where you may not know, if a reply is expected or how long will it take for it to arrive. A natural way to handle these types of scenarios in Java would be to rely upon **java.util.concurrent.Future** instances. That is exactly what Spring Integration uses to support Asynchronous Gateways.
This example demonstrates how you can apply an Asynchronous Gateway based on the following simple use case:
We are sending a request to a **MathService** to multiply random numbers by 2. As you can see from the configuration there is a filter that discards any request for the number that is less then a 100. This means that there will be no replies coming for the requests with numbers less then 100. Typically, when using the regular Gateway, the gateway method would lock until a timeout occurs. In this example, however, the responses are coming back right away as Java Futures which we evaluate.
To run this sample, simply execute **org.springframework.integration.samples.async.gateway.AsyncGatewayTest**.
You should see the following output:
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 107 by 2 is 214
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 146 by 2 is 292
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 189 by 2 is 378
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 130 by 2 is 260
. . . . .
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 38 by 2 is can not be accomplished in 20 seconds
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 39 by 2 is can not be accomplished in 20 seconds
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 36 by 2 is can not be accomplished in 20 seconds
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 37 by 2 is can not be accomplished in 20 seconds

View File

@@ -1,34 +0,0 @@
Gateway provides a convenient way to expose a Proxy over a service-interface thus giving you a POJO-based access
to a messaging system (based on objects in your own domain, or primitives/Strings, etc).
However when you invoke a method you expect the method to return. And since gateway's method call represents a
contract with the messaging system which states that for each request there will always be a reply you must always
guarantee that your message flow is in compliance with such contract. And in a lot of cases you can based on how your
flow is structured. But what about the cases where you can't (e.g, message was filtered out and discarded or routed into
a unidirectional sub-flow)?
With Spring Integration 2.0 we are introducing support for an Asynchronous Gateway which is
a convenient way to initiate flows where you may not know if a reply is expected or how long will it take for it
to arrive.
A natural way to handle these types of scenarios in Java would be relying upon java.util.concurrent.Future
instances, and that is exactly what Spring Integration uses to support an Asynchronous Gateway.
This example demonstrates how you can apply Asynchronous Gateway based on the simple use case:
We are sending request to a MathService to multiply random numbers by 2. As you can see from the configuration there is a filter that
discards any request for the number that is less then a 100. This means that there will be no replies coming for the requests with
numbers less then 100.
Typically when using the regular Gateway the gateway method would lock until a timeout where here responses are coming back right away as Java Futures
which we evaluate.
To run this sample simply execute To run this sample simply execute org.springframework.integration.samples.async.gateway.AsyncGatewayTest
You should see the following output:
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 107 by 2 is 214
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 146 by 2 is 292
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 189 by 2 is 378
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 130 by 2 is 260
. . . . .
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 38 by 2 is can not be accomplished in 20 seconds
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 39 by 2 is can not be accomplished in 20 seconds
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 36 by 2 is can not be accomplished in 20 seconds
INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 37 by 2 is can not be accomplished in 20 seconds

View File

@@ -0,0 +1,6 @@
Error Handling Sample
=====================
Demonstrates the handling of Exceptions in an asynchronous messaging environment. View the **errorHandlingDemo.xml** configuration file. Notice the use of a **Header Enricher** within a **Chain**, that establishes an **error-channel** reference prior to passing the message to a **Service Activator**.
In order to run the sample, execute **PartyDemoTest** in package **org.springframework.integration.samples.errorhandling**.

View File

@@ -0,0 +1,44 @@
File Processing Sample
======================
This sample demonstrates how to wire a message flow to process Files sequentially (maintain the order) or concurrently (no order). The difference is in the *Poller* configuration - single threaded or multi-threaded.
The Poller, configured for the File Inbound Channel Adapter and after polling files and converting them to Messages, will distribute these Messages one at the time using its own thread by default. So files will be pulled based in the order they were created in the directory and processed in such order.
See **sequentialFileProcessing-config.xml** for configuration details. The FileProcessor class will randomly delay the file processing, but the order of processing is still maintained regardless of this delay.
If order is not important, then you can process files concurrently. All you need to do, is to configure a **task-executor** for the Poller. Based on the delay in **FileProcessor**, you'll clearly observe that the order of processing is based on the availability of the thread in the thread poll of task executor
To run sample, execute **FileProcessingTest**. You should see the following output:
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest -
#### Starting Sequential processing test ####
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populating directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populated directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Starting Spring Integration Sequential File processing
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_2.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_2.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest -
#### Starting Concurrent processing test ####
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populating directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populated directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Starting Spring Integration Sequential File processing
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_2.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_2.txt unless you specify task-executor or introduce task-executor somewhere downstream you are fine.

View File

@@ -1,51 +0,0 @@
This sample demonstrates how to wire a message flow to process Files
sequentially (maintain the order) or concurrently (no order).
The difference is in poller configuration - single threaded or multi-threaded.
Poller, configured for File Inbound Channel Adapter, after polling files and converting them to Messages
will distribute these Messages one at the time using its own thread by default. So files will be pulled
based in the order they were created in the directory and processed in such order.
See sequentialFileProcessing-config.xml for configuration details.
The FileProcessor class will randomly delay the file processing, but the order of processing is still maintained
regardless of this delay
If order is not important, then you can process files concurrently. ALl you need to do is configure task-executor for poller.
Based on the delay in FileProcessor you'll clearly observe that the order of processing is based on the availability
of the thread in the thread poll of task executor
To run sample execute FileProcessingTest. You should see the following output:
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest -
#### Starting Sequential processing test ####
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populating directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populated directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Starting Spring Integration Sequential File processing
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_2.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_2.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest -
#### Starting Concurrent processing test ####
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populating directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Populated directory with files
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Starting Spring Integration Sequential File processing
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_1.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_0.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_3.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_4.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessor - Processing File: input/file_2.txt
INFO : org.springframework.integration.samples.fileprocessing.FileProcessingTest - Finished processing input/file_2.txt unless you specify task-executor or introduce task-executor somewhere downstream you are fine.

View File

@@ -0,0 +1,29 @@
Multipart Http Sample
=====================
This sample demonstrates how you can send a *multipart request* to a Spring Integration's HTTP service using 2 scenarios:
1. Spring's RestTemplate
2. Spring Integration Http Outbound Gateway
It consists of two parts - Client and Server. There are two client programs:
1. MultipartRestClient. It uses Spring's RestTemplate to assemble and send multipart request
2. MultipartClientForHttpOutboundClient. It uses Spring Integration Http Outbound Gateway to send multipart request.
The interesting part about this client is the way it assembles the Multipart request using a plain old Map.
The Server is Spring Integration's HTTP endpoint configuration.
To run this sample:
1. Deploy project
* If you are using STS and project is imported as Eclipse project in your workspace you can just execute **Run on Server**
* You can also run **mvn clean install** and generate the WAR file that you can deploy the conventional way
2. run the simple test client program: **org.springframework.integration.samples.multipart.MultipartClient**
You should see the following output from the server:
INFO : ...MultipartClient - Successfully recieved multipart request: {company=[[Ljava.lang.String;@147e8bd9], company-logo=[org.springframework.integration.http.UploadedMultipartFile@f5e12]}
INFO : ...MultipartClient - company - SpringSource
INFO : org.springframework.integration.samples.multipart.MultipartClient - company-logo - as UploadedMultipartFile: spring09_logo.png

View File

@@ -1,26 +0,0 @@
This sample demonstrates how you can send a multipart request to a Spring Integration's HTTP service using 2 scenarios;
1. Spring's RestTemplate
2. Spring Integration Http Outbound Gateway
It consists of two parts - Client and Server.
There are two client programs.
1. MultipartRestClient. It uses Spring's RestTemplate to assemble and send multipart request
2. MultipartClientForHttpOutboundClient. It uses Spring Integration Http Outbound Gateway to send multipart request.
The interesting part about this client is the way it assembles Multipart request using a plain old Map.
Server is Spring Integration's HTTP endpoint configuration.
To run this sample
1) deploy project
- If you are using STS and project is imported as Eclipse project in your workspace you can just execute 'Run on Server'
- You can also run 'mvn clean install' and generate the WAR file that you can deploy the conventional way
2) run the simple test client program: org.springframework.integration.samples.multipart.MultipartClient
You should see the following output from the server:
INFO : ...MultipartClient - Successfully recieved multipart request: {company=[[Ljava.lang.String;@147e8bd9], company-logo=[org.springframework.integration.http.UploadedMultipartFile@f5e12]}
INFO : ...MultipartClient - company - SpringSource
INFO : org.springframework.integration.samples.multipart.MultipartClient - company-logo - as UploadedMultipartFile: spring09_logo.png

View File

@@ -1,20 +1,10 @@
tcp-client-server-multiplex
===========================
TCP Client-Server Multiplex Sample
==================================
If this is your first experience with the spring-integrtion-ip module, start with the **tcp-client-server** project in the basic folder.
That project uses outbound and inbound tcp gateways for communication. As discussed in the Spring Integration Reference Manual, this has some limitations for performance. If a shared socket (single-use="false") is used, only one message can be processed at a time (on the client side); we must wait for the response to the current request before we can send the next request. Otherwise, because only the payload is sent over tcp, the framework cannot correlate responses to requests.
That project uses outbound and inbound tcp gateways for communication. As discussed in the Spring Integration
Reference Manual, this has some limitations for performance. If a shared socket (single-use="false") is used,
only one message can be processed at a time (on the client side); we must wait for the response to the
current request before we can send the next request. Otherwise, because only the payload is sent over
tcp, the framework cannot correlate responses to requests.
An alternative is to use a new socket for each message, but this comes with a performance overhead. The solution is to use **Collaborating Channel Adapters** (see SI Reference Manual). In such a scenario, we can send multiple requests before a response is received. This is termed multiplexing.
An alternative is to use a new socket for each message, but this comes with a performance overhead.
The solution is to use 'Collaborating Channel Adapters' (see SI Reference Manual). In such a scenario,
we can send multiple requests before a response is received. This is termed multiplexing.
This sample demonstrates how to configure collaborating channel adapters, on both the client and
server sides, and one technique for correlating the responses to the corresponding request.
This sample demonstrates how to configure collaborating channel adapters, on both the client and server sides, and one technique for correlating the responses to the corresponding request.

View File

@@ -0,0 +1,44 @@
Travel Sample
=============
This example demonstrates a simple process that could be useful when building travel related applications. It defines two services:
1. Get Weather report based on the ZIP (Postal) code
2. Get Traffic report based on the ZIP (Postal) code
It uses real services provided by third party providers.
* Get Weather report Service is a SOAP Web Service
* Get Traffic report Service is an HTTP Service
This example demonstrates how to configure both:
* HTTP Outbound Gateway - to integrate with HTTP Service
* WS Outbound Gateway - to integrate with WS Service
The diagram below shows the message flow:
weatherPreProcessChannel weatherChannel weatherServiceChannel
|------------------------| -> transformer -> |--------------| -> header-enricher -> |---------------------| -> ws:outbound-gateway
|-> getWeatherByZip(zip) routingChannel /
TravelGateway --> |--------------| -> h-v-r|
|-> getTrafficByZip(zip) | trafficChannel
\ |-----------------| -> http:outbound-gateway
Two services are exposed via the Gateway. The gateway enriches the headers of the message with the type of request **weather** or **traffic** and sends the Message to the **routingChannel** from which it is retrieved by the **HeaderValueRouter** (h-v-r) which routes the Message to either **weatherPreProcessChannel** or **trafficChannel** based on the value of the *REQUEST_TYPE* header hat was set by the Gateway.
The WS service requires that the message would be is a certain format. We first need to wrap it into an XML request (done by a transformer), then we need to add a SOAP Header (done by header-enricher). Once Message is properly formatted it is sent to the **ws:outbound-gateway**, which replies with XML describing real time weather conditions in a particular ZIP code.
The HTTP Service does not require any pre-processing. All we need to do is map the HTTP URI variable **{zipCode}**.
We do it via the **<uri-variable>** element of the **http:outbound-gateway**.
<uri-variable name="zipCode" expression="payload"/>
Here you see, we are using Spring Expression Language (SpEL) to bind the value of the payload (zipCode) to this variable. To run sample, execute **TravelDemo** class.

View File

@@ -1,44 +0,0 @@
This example demonstrates a simple process that could be useful when building travel related applications;
It defines two services:
1. Get Weather report based on the ZIP code
2. Get Traffic report based on the ZIP code
It uses real services provided by third party providers.
Get Weather report Service is a SOAP Web Service
Get Traffic report Service is an HTTP Service
This example demonstrates how to configure both:
-<2D>HTTP Outbound Gateway - to integrate with HTTP Service
-<2D>WS Outbound Gateway - to integrate with WS Service
The diagram below shows the message flow.
<09><> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> weatherPreProcessChannel <20> <20> <20> <20> <20> <20> <20> <20> <20> <20><>weatherChannel <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> weatherServiceChannel
<09><> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> |------------------------| -> transformer -> |--------------| -> header-enricher -> |---------------------| -> ws:outbound-gateway<61>
<EFBFBD><EFBFBD> <20> |-><3E>getWeatherByZip(zip) <20> <20> routingChannel <20> <20> <20> <20> <20> /
TravelGateway <20> <20> <20> <20> <20> <20> <20> <20>--> |--------------| -> h-v-r|
<EFBFBD><EFBFBD> <20> |-><3E>getTrafficByZip(zip) <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> | <20> <20> trafficChannel
<EFBFBD><EFBFBD> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> \ |-----------------| -> http:outbound-gateway <20> <20><>
Two services are exposed via the Gateway. The gateway enriches the headers of the message with the
type of request 'weather' or 'traffic' and sends the Message to the 'routingChannel' from which it is retrieved by
HeaderValueRouter (h-v-r) which routes Message to either 'weatherPreProcessChannel' or 'trafficChannel' based
on the value of the REQUEST_TYPE header hat was set by the Gateway.
WS service, requires that the message would be is a certain format. We first need to wrap it into XML request (done by a transformer),
then we need to add a SOAP Header (done by header-enricher). Once Message was properly formated it is sent to ws:outbound-gateway
which replies with XML describing real time weather conditions in a particular ZIP code.
HTTP Service does not require any pre-processing. All we need to do is map HTTP URI variable {zipCode}.
We do it via <uri-variable> element of http:outbound-gateway.
<uri-variable name="zipCode" expression="payload"/>
Here you see we are using Spring Expression Language to bind the value of the payload (zipCode) to this variable.
To run sample execute TravelDemo.class