diff --git a/spring-integration-reference/src/adapters.xml b/spring-integration-reference/src/adapters.xml
index e39f2f0e08..1554b5789e 100644
--- a/spring-integration-reference/src/adapters.xml
+++ b/spring-integration-reference/src/adapters.xml
@@ -9,8 +9,14 @@
are external to the messaging system. As the name implies, the interaction consists of adapting the external
system or component to send-to and/or receive-from a MessageChannel. Within
Spring Integration, there is a distinction between source adapters and target
- adapters. In the 1.0 Milestone 2 release, Spring Integration includes source and target adapters
- for JMS, Files, Streams, and Spring ApplicationEvents as well as a target adapter for sending e-mail.
+ adapters. In the 1.0 Milestone 3 release, Spring Integration includes source and target adapters
+ for JMS, RMI, Files, Streams, Spring's HttpInvoker and Spring ApplicationEvents. A source adapter for FTP is
+ also available as well as target adapters for sending e-mail and invoking Web Services.
+
+
+ All of these adapters are discussed in this section. However, namespace support is provided for many of them
+ and is typically the most convenient option for configuration. For examples, see
+ .
@@ -65,6 +71,47 @@
Integration's namespace support.
+
+ RMI Adapters
+
+ The RmiSourceAdapter is built upon Spring's RmiServiceExporter.
+ However, since it is adapting a MessageChannel, there is no need to specify
+ the serviceInterface. Likewise, the serviceName is automatically
+ generated based on the channel name. Therefore, creating the adapter is as simple as providing a reference
+ to its channel: RmiSourceAdapter rmiSourceAdapter = new RmiSourceAdapter(channel);
+
+
+
+ The RmiTargetAdapter encapsulates the creation of a proxy that is capable of
+ communicating with an RmiSourceAdapter running in another process. Since the interface
+ is already known, the only required information is the URL. The URL should include the host, port (default is
+ '1099'), and 'serviceName'. The 'serviceName' must match that created by the
+ RmiSourceAdapter (the prefix is available as a constant).
+ String url = "http://somehost:1099/" + RmiSourceAdapter.SERVICE_NAME_PREFIX + "someChannel";
+RmiTargetAdapter rmiTargetAdapter = new RmiTargetAdapter(url);
+
+
+
+
+ HttpInvoker Adapters
+
+ The source and target adapters for HttpInvoker are very similar to the RMI adapters. For a source, only the
+ channel needs to be provided, and for a target, only the URL. If running in a Spring MVC environment, then
+ the HttpInvokerSourceAdapter simply needs to be defined and provided in a
+ HandlerMapping. For example, the following would be exposed at the path
+ "http://somehost/path-mapped-to-dispatcher-servlet/httpInvokerAdapter" when a simple
+ BeanNameUrlHandlerMapping strategy is enabled:
+
+
+]]>
+ When not running in a Spring MVC application, simply define a servlet in 'web.xml' whose type is
+ HttpRequestHandlerServlet and whose name matches the bean name of the source
+ adapter. As with the RmiTargetAdapter, the
+ HttpInvokerTargetAdapter only requires the URL that matches an instance of
+ HttpInvokerSourceAdapter running in a web application.
+
+
File Adapters
@@ -78,9 +125,23 @@
adapter also accepts an implementation of the FileNameGenerator strategy that
defines the following method: String generateFileName(Message message)
+
+
+ FTP Adapters
- As with the JMS adapters, the most convenient way to configure File adapters is with the namespace support. For
- examples, see .
+ To poll a directory with FTP, configure an instance of FtpSourceAdapter. The adapter
+ expects a number of properties for connecting to the FTP server (as shown below) as well as the
+ 'channel' and the 'period' for polling. For example, the following adapter would poll every 30 seconds:
+
+
+
+
+
+
+
+
+]]>
@@ -99,32 +160,69 @@
message);
}]]>
- A static implementation is available out-of-the-box, but typically most of the properties would need to be
- dynamically generated based on the message itself. The following is an example of a configured
- mail adapter.
-
+ The default implementation will look for attributes in the MessageHeader with
+ the following constants defining the keys:
+ MailAttributeKeys.SUBJECT
+MailAttributeKeys.TO
+MailAttributeKeys.CC
+MailAttributeKeys.BCC
+MailAttributeKeys.FROM
+MailAttributeKeys.REPLY_TO
+
+
+ A static implementation is also available out-of-the-box and may be useful for testing. However, when
+ customizing, the properties would typically be generated dynamically based on the message itself. The
+ following is an example of a configured mail adapter.
+
]]>
+
+ Web Service Adapters
+
+ To invoke a Web Service upon sending a message to a channel, there are two options:
+ SimpleWebServiceTargetAdapter and
+ MarshallingWebServiceTargetAdapter. The former will accept either a
+ String or javax.xml.transform.Source as the message
+ payload. The latter provides support for any implementation of the Marshaller
+ and Unmarshaller interfaces. Both require the URI of the Web Service to be
+ called.simpleAdapter = new SimpleWebServiceTargetAdapter(uri);
+
+marshallingAdapter = new MarshallingWebServiceTargetAdapter(uri, marshaller);
+
+ As with the other target adapters, this can then be referenced from a MessageEndpoint
+ that is subscribed to a channel. The endpoint is then responsible for passing the response to the proper
+ channel. It will first check for a returnAddress on the original message's header, and it
+ will fallback to the endpoint's own default output channel.
+
+
+ For more detail on the inner workings, see the Spring Web Services reference guide's chapter covering
+ client access
+ as well as the chapter covering
+ Object/XML mapping.
+
+
Stream Adapters
Spring Integration also provides adapters for streams. Both ByteStreamSourceAdapter and
CharacterStreamSourceAdapter extend the PolllingSourceAdapter so
- that the polling period can be configured, and the Message Bus can automatically detect and schedule them. Both
- require an InputStream as the single constructor argument. The
+ that the polling period can be configured, and the Message Bus can automatically detect and schedule them. The
+ byte stream version requires an InputStream, and the character stream version requires a
+ Reader as the single constructor argument. The
ByteStreamSourceAdapter also accepts the 'bytesPerMessage' property to determine how many
bytes it will attempt to read into each Message.
For target streams, there are also two implementations: ByteStreamTargetAdapter and
- CharacterStreamTargetAdapter. Each defines a constructor that requires an
- OutputStream, and each provides a second constructor that adds the optional
- 'bufferSize' property. Since both of these ultimately implement the MessageHandler
- interface, they can be referenced from an endpoint configuration as will be described in more detail in
- .
+ CharacterStreamTargetAdapter. Each requires a single constructor argument -
+ OutputStream for byte streams or Writer for character streams,
+ and each provides a second constructor that adds the optional 'bufferSize' property. Since both of these
+ ultimately implement the MessageHandler interface, they can be referenced from an
+ endpoint configuration as will be described in more detail in .
diff --git a/spring-integration-reference/src/configuration.xml b/spring-integration-reference/src/configuration.xml
index 98323c651c..690f9cf1e8 100644
--- a/spring-integration-reference/src/configuration.xml
+++ b/spring-integration-reference/src/configuration.xml
@@ -9,13 +9,11 @@
needs and at what level you prefer to work. As with the Spring framework in general, it is also possible to mix
and match the various techniques according to the particular problem at hand. For example, you may choose the
XSD-based namespace for the majority of configuration combined with a handful of objects that are configured with
- annotations. Of course, it is also possible to always stick with a single approach. The main point is that these
- are options for configuration motivated by the need to support a user community with a wide
- range of preferences. That said, there has also been a concerted effort to provide consistent naming so that, for
- example, the XML elements defined by the XSD schema will match the names of annotations, and the attributes of
- those XML elements will match the names of annotation properties. Direct usage of the API is yet another option
- and is described in detail in . We expect that most users will choose one of the
- higher-level options, such as the namespace-based or annotation-driven configuration.
+ annotations. As much as possible, the two provide consistent naming. XML elements defined by the XSD schema will
+ match the names of annotations, and the attributes of those XML elements will match the names of annotation
+ properties. Direct usage of the API is yet another option and is described in detail in .
+ We expect that most users will choose one of the higher-level options, such as the namespace-based or
+ annotation-driven configuration.
@@ -33,9 +31,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
]]>xmlns:integration="http://www.springframework.org/schema/integration"http://www.springframework.org/schema/integration
- http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ ]]>http://www.springframework.org/schema/integration
+ http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
You can choose any name after "xmlns:"; integration is used here for clarity, but you might
@@ -46,9 +44,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
]]>xmlns:beans="http://www.springframework.org/schema/beans"]]>
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/integration
+ http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">]]>
When using this alternative, no prefix is necessary for the Spring Integration elements. On the other hand, if
@@ -99,6 +97,17 @@
provided as a comma-delimited list:
]]>
+
+ To create a PriorityChannel, use the "priority-channel" element:
+ ]]>
+ By default, the channel will consult the MessagePriority value in the
+ message's header. However, a custom Comparator reference may be
+ provided instead. Also, the PriorityChannel does support the "datatype"
+ attribute. The following example demonstrates both:
+
+]]>
+
Message channels may also have interceptors as described in . One or
more <interceptor> elements can be added as sub-elements of <channel>. Provide the "ref" attribute
@@ -177,6 +186,8 @@
]]>]]>]]>
Recall the default concurrency policy values as listed in .
+ If no concurrency settings are provided (i.e. a null
+ ConcurrencyPolicy), the endpoint's handler will be invoked in the caller's thread.
The default queue capacity of 0 triggers the creation of a SynchronousQueue. In many
@@ -227,16 +238,36 @@
Configuring Channel Adapters
The most convenient way to configure Channel Adapters is by using the namespace support. The following examples
- demonstrate the namespace-based configuration of source and target adapters (Spring Integration 1.0 M1 includes
- namespace support for JMS and Files):
+ demonstrate the namespace-based configuration of several source and target adapters:
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
]]>
@@ -275,7 +306,7 @@ public class FooService {
public class FooService {
@Handler
- public void processFoo(Foo foo) {
+ public void bar(Foo foo) {
...
}
}
@@ -289,9 +320,20 @@ public class FooService {
@MessageEndpoint(input="exampleChannel", defaultOutput="replyChannel")
- Finally, just as the 'schedule' sub-element and its 'period' attribute can be provided for a namespace-based
+ Just as the 'schedule' sub-element and its 'period' attribute can be provided for a namespace-based
endpoint, the 'pollPeriod' attribute can be provided on the @MessageEndpoint.
@MessageEndpoint(input="exampleChannel", pollPeriod=3000)
+ Likewise, @Concurrency provides an annotation-based equivalent of the
+ <concurrency/> element:
+ @MessageEndpoint(input="fooChannel")
+@Concurrency(coreSize=5, maxSize=20)
+public class FooService {
+
+ @Handler
+ public void bar(Foo foo) {
+ ...
+ }
+}
Two additional annotations are supported, and both act as a special form of handler method:
diff --git a/spring-integration-reference/src/core-api.xml b/spring-integration-reference/src/core-api.xml
index 51d7e33973..9db8b16ee4 100644
--- a/spring-integration-reference/src/core-api.xml
+++ b/spring-integration-reference/src/core-api.xml
@@ -53,7 +53,7 @@
priority
- int
+ MessagePriority (an enum)
properties
@@ -79,6 +79,17 @@ new GenericMessage<T>(T payload, MessageHeader headerToCopy)StringMessage and ErrorMessage. The latter accepts any
Throwable object as its payload.
+
+ The MessagePriority is only considered when using a PriorityChannel
+ (as described in the next section). It is defined as an enum with five possible values:
+ public enum MessagePriority {
+ HIGHEST,
+ HIGH,
+ NORMAL,
+ LOW,
+ LOWEST
+}
+
The Message is obviously a very important part of the API. By encapsulating the
data in a generic wrapper, the messaging system can pass it around without any knowledge of the data's type. As
@@ -200,8 +211,12 @@ new GenericMessage<T>(T payload, MessageHeader headerToCopy)MessageChannels and MessageHandlers. It provides
the following methods:
public void registerChannel(String name, MessageChannel channel)
-public void registerHandler(String name, MessageHandler handler, Subscription subscription)
-public void registerHandler(String name, MessageHandler handler, Subscription subscription,
+
+public void registerHandler(String name, MessageHandler handler,
+ Subscription subscription)
+
+public void registerHandler(String name, MessageHandler handler,
+ Subscription subscription,
ConcurrencyPolicy concurrencyPolicy)
As those method signatures reveal, the message bus is handling several of the concerns here so that the channel
and handler objects can be as simple as possible. These responsibilities include the creation and lifecycle
@@ -292,7 +307,7 @@ public void registerHandler(String name, MessageHandler handler, Subscription su
The scheduling metadata is provided as an implementation of the Schedule
interface. This is an abstraction designed to allow extensibility of schedulers for messaging tasks. Currently,
- there is a single implementation called PollingSchedule that provides the following
+ there is a single implementation named PollingSchedule that provides the following
properties:
Properties of the PollingSchedule
@@ -430,14 +445,15 @@ assertFalse(selector.accept(new GenericMessage(someObject)));
channel.purge(someSelector);
There is even a ChannelPurger utility class whose purge operation is a good candidate for
Spring's JMX support:
- ChannelPurger purger = new ChannelPurger(channel, new ExampleMessageSelector());
+ ChannelPurger purger = new ChannelPurger(new ExampleMessageSelector(), channel);
purger.purge();
Implementations of MessageSelector might provide opportunities for reuse on
channels in addition to endpoints. For that reason, Spring Integration provides a simple selector-wrapping
ChannelInterceptor that accepts one or more selectors in its constructor.
- MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector1, selector2);
+ MessageSelectingInterceptor interceptor =
+ new MessageSelectingInterceptor(selector1, selector2);
channel.addInterceptor(interceptor);
diff --git a/spring-integration-reference/src/samples.xml b/spring-integration-reference/src/samples.xml
index 6656efff01..8861acea5b 100644
--- a/spring-integration-reference/src/samples.xml
+++ b/spring-integration-reference/src/samples.xml
@@ -5,8 +5,8 @@
The Cafe Sample
- In this section, we will review a sample application that is included in the Spring Integration Milestone 1
- release. This sample is inspired by one of the samples featured in Gregor Hohpe's
+ In this section, we will review a sample application that is included in the Spring Integration
+ distribution. This sample is inspired by one of the samples featured in Gregor Hohpe's
Ramblings.
@@ -30,19 +30,18 @@
Here is the XML configuration:
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/integration
+ http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-2.5.xsd">
-
@@ -50,13 +49,15 @@
-
-
+
+
+
-
]]>
Notice that the Message Bus is defined. It will automatically detect and register all channels and endpoints.
The 'annotation-driven' element will enable the detection of the splitter and router - both of which carry
@@ -107,7 +108,8 @@ public class Barista {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
- System.out.println("prepared hot drink #" + hotDrinkCounter.incrementAndGet() + ": " + drink);
+ System.out.println("prepared hot drink #" +
+ hotDrinkCounter.incrementAndGet() + ": " + drink);
}
public void prepareColdDrink(Drink drink) {
@@ -116,7 +118,8 @@ public class Barista {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
- System.out.println("prepared cold drink #" + coldDrinkCounter.incrementAndGet() + ": " + drink);
+ System.out.println("prepared cold drink #" +
+ coldDrinkCounter.incrementAndGet() + ": " + drink);
}
}]]>
@@ -171,7 +174,7 @@ public class Barista {
as described in . Additionally, you can experiment with the channel's
configuration, such as adding a 'dispatcher-policy' as described in . If you
want to explore the sample in more detail, the source JAR is available in the "dist" directory:
- 'spring-integration-samples-sources-1.0.0.m1.jar'.
+ 'spring-integration-samples-sources-1.0.0.M3.jar'.
\ No newline at end of file
diff --git a/spring-integration-reference/src/spring-integration-reference.xml b/spring-integration-reference/src/spring-integration-reference.xml
index 432a18b707..bc4e90338a 100644
--- a/spring-integration-reference/src/spring-integration-reference.xml
+++ b/spring-integration-reference/src/spring-integration-reference.xml
@@ -13,7 +13,7 @@
Spring Integration Reference Manual
Spring Integration
- 1.0.0.m2 (Milestone 2)
+ 1.0.0.M3 (Milestone 3)
@@ -31,7 +31,7 @@
- Copyright © SpringSource Inc., 2008
+ © SpringSource Inc., 2008