INTSAMPLES-42 rename readme.txt files to README.md
This commit is contained in:
26
intermediate/async-gateway/README.md
Normal file
26
intermediate/async-gateway/README.md
Normal 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
|
||||
@@ -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
|
||||
6
intermediate/errorhandling/README.md
Normal file
6
intermediate/errorhandling/README.md
Normal 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**.
|
||||
44
intermediate/file-processing/README.md
Normal file
44
intermediate/file-processing/README.md
Normal 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.
|
||||
@@ -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.
|
||||
29
intermediate/multipart-http/README.md
Normal file
29
intermediate/multipart-http/README.md
Normal 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
|
||||
@@ -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
|
||||
@@ -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.
|
||||
44
intermediate/travel/README.md
Normal file
44
intermediate/travel/README.md
Normal 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user