diff --git a/spring-integration-reference/src/core-api.xml b/spring-integration-reference/src/core-api.xml
index 6d795a8f38..1633b68a37 100644
--- a/spring-integration-reference/src/core-api.xml
+++ b/spring-integration-reference/src/core-api.xml
@@ -102,7 +102,7 @@ new GenericMessage<T>(T payload, Map<String, Object> headers)and payload of that
Message will be copied to the new Message:
- Message<String> message1 = MessageBuilder.fromPayload("test")
+ Message<String> message1 = MessageBuilder.fromPayload("test")
.setHeader("foo", "bar")
.build();
@@ -114,7 +114,7 @@ assertEquals("bar", message2.getHeaders().get("foo"));
If you need to create a Message with a new payload but still want to copy the
headers from an existing Message, you can use one of the 'copy' methods.
- Message<String> message3 = MessageBuilder.fromPayload("test3")
+ Message<String> message3 = MessageBuilder.fromPayload("test3")
.copyHeaders(message1.getHeaders())
.build();
@@ -129,7 +129,7 @@ assertEquals(123, message4.getHeaders().get("foo"));
second example above, you can see how to set any user-defined header with setHeader.
Finally, there are set methods available for the predefined headers as well as a non-destructive method for
setting any header (MessageHeaders also defines constants for the pre-defined header names).
- Message<Integer> importantMessage = MessageBuilder.fromPayload(99)
+ Message<Integer> importantMessage = MessageBuilder.fromPayload(99)
.setPriority(MessagePriority.HIGHEST)
.build();
@@ -166,11 +166,21 @@ assertEquals(MessagePriority.HIGHEST, anotherMessage.getHeaders().getPriority())
MessageSource
- The MessageSource interface defines a single method for receiving
- Message objects.
- public interface MessageSource<T> {
+ As alluded to in the overview, the MessageSource interface is itself a marker
+ interface for any "source" of Messages. The two sub-interfaces - PollableSource
+ and SubscribableSource - accommodate two types of source: those that must be
+ polled and those that send Messages on their own. An example of the first type would be a source that represents
+ a directory in the File-system, and an example of the second type would be an inbound RMI invocation.
+
+
+ The PollableSource interface defines a single method for receiving Message objects.
+ public interface PollableSource<T> extends MessageSource<T> {
Message<T> receive();
}
+ The BlockingSource interface extends PollableSource
+ and adds a single method with a timeout: Message<T> receive(long timeout);
+
+
Spring Integration also provides a MethodInvokingSource implementation that serves as an
adapter for invoking any arbitrary method on a plain Object (i.e. there is no need to implement an interface).
To use the MethodInvokingSource, provide the Object reference and the method name.
@@ -178,8 +188,8 @@ assertEquals(MessagePriority.HIGHEST, anotherMessage.getHeaders().getPriority())
source.setObject(new SourceObject());
source.setMethodName("sourceMethod");
Message<?> result = source.receive();
- It is generally more common to configure a MethodInvokingSource in XML by providing a
- bean reference in the "source" attribute of a <channel-adapter> element.
+ It is also possible to configure a MethodInvokingSource in XML by providing a
+ bean reference in the "source" attribute of a <channel-adapter> element along with a "method" attribute.
]]>
@@ -210,24 +220,45 @@ target.send(new StringMessage("test"));
While the Message plays the crucial role of encapsulating data, it is the
MessageChannel that decouples message producers from message consumers.
- Spring Integration's MessageChannel interface is defined as follows.
- MessageChannel interface is defined as follows.
+ > clear();
- List> purge(MessageSelector selector);
}]]>
+ Because it extends BlockingTarget, it inherits the following methods:
+ boolean send(Message message);
+
+boolean send(Message message, long timeout);
When sending a message, the return value will be true if the message is sent successfully.
- If the send call times out or is interrupted, then it will return false. Likewise when
- receiving a message, the return value will be null in the case of a timeout or interrupt.
+ If the send call times out or is interrupted, then it will return false.
- Spring Integration provides several different implementations of the
- MessageChannel interface. Each is briefly described in the sections below.
+ Since Message Channels are also Message Sources, there are two sub-interfaces corresponding to the two source
+ types. Here is the definition of PollableChannel.
+ public interface PollableChannel extends MessageChannel, BlockingSource {
+
+ List<Message<?>> clear();
+
+ List<Message<?>> purge(MessageSelector selector);
+
+}
+ Since the PollableChannel interface extends BlockingSource, it also inherits the following methods:
+ Message<T> receive();
+
+Message<T> receive(long timeout);
+ Similar to the send methods, when receiving a message, the return value will be null in the
+ case of a timeout or interrupt.
+
+
+ The subscribable channels implement the SubscribableSource interface. Instead
+ of providing receive methods for polling, these channels will send messages directly to their subscribers.
+ The SubscribableSource interface defines the following two methods:
+ boolean subscribe(MessageTarget target);
+
+boolean unsubscribe(MessageTarget target);
+
+
+ Spring Integration provides several different Message Channel implementations. Each is briefly described in the
+ sections below.