INT-3557 Clarify MessageHeaders Constants

JIRA: https://jira.spring.io/browse/INT-3557

Add class names and code tags.

Add missing header constants.

Polishing for `timestamp` header doc.

Fix JavaDocs issues: https://build.spring.io/browse/INT-EIGHTAPI-296
This commit is contained in:
Gary Russell
2014-11-10 09:51:35 -05:00
committed by Artem Bilan
parent 0cc9273a2e
commit 0f568c0526
5 changed files with 95 additions and 30 deletions

View File

@@ -46,6 +46,10 @@ public class IntegrationMessageHeaderAccessor extends MessageHeaderAccessor {
public static final String SEQUENCE_DETAILS = "sequenceDetails";
/**
* @deprecated Not used; will be removed in 4.2.
*/
@Deprecated
public static final String POSTPROCESS_RESULT = "postProcessResult";
public static final String ROUTING_SLIP = "routingSlip";
@@ -107,7 +111,7 @@ public class IntegrationMessageHeaderAccessor extends MessageHeaderAccessor {
}
else if (IntegrationMessageHeaderAccessor.ROUTING_SLIP.equals(headerName)) {
Assert.isTrue(Map.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
+ "' header value must be an List.");
+ "' header value must be a Map.");
}
else if (IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE.equals(headerName)) {
Assert.isTrue(Boolean.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName

View File

@@ -124,6 +124,7 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport
/**
* @deprecated - this class will not implement {@link SmartLifecycle} in 4.2, just {@code Lifecycle}.
* @param phase - the phase to set.
*/
@Deprecated
public final void setPhase(int phase) {
@@ -141,6 +142,7 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport
/**
* @deprecated - this class will not implement {@link SmartLifecycle} in 4.2, just {@code Lifecycle}.
* @param autoStartup the boolean flag to specify {@code autoStartup} behaviour.
*/
@Deprecated
public final void setAutoStartup(boolean autoStartup) {

View File

@@ -33,8 +33,9 @@ import org.springframework.util.Assert;
* Used to advise {@link MessageHandler}s.
* Two expressions 'onSuccessExpression' and 'onFailureExpression' are evaluated when
* appropriate. If the evaluation returns a result, a message is sent to the onSuccessChannel
* or onFailureChannel as appropriate; the message is the input message with a header
* {@link org.springframework.integration.IntegrationMessageHeaderAccessor#POSTPROCESS_RESULT} containing the evaluation result.
* or onFailureChannel as appropriate; the message is an {@link AdviceMessage}
* containing the evaluation result in its payload and the {@code inputMessage} property containing
* the original message that was sent to the endpoint.
* The failure expression is NOT evaluated if the success expression throws an exception.
*
* @author Gary Russell

View File

@@ -25,10 +25,10 @@ import org.springframework.util.Assert;
/**
* The {@link MessageSelector} implementation using a {@link ConcurrentMetadataStore}
* and {@link MessageProcessor<String>}.
* and {@link MessageProcessor}.
* <p>
* The {@link #accept} method extracts {@code metadataKey} from the provided {@code message}
* using {@link MessageProcessor<String>} and uses the {@code timestamp} header as the {@code value}
* using {@link MessageProcessor} and uses the {@code timestamp} header as the {@code value}
* (hex) by default. The {@link #valueStrategy} can be provided to override the default behaviour.
* <p>
* The successful result of the {@link #accept} method is based on the

View File

@@ -63,30 +63,39 @@
The following Message headers are pre-defined:
<table id="message-headers-table">
<title>Pre-defined Message Headers</title>
<tgroup cols="2">
<tgroup cols="3">
<colspec align="left" />
<thead>
<row>
<entry align="center">Header Name</entry>
<entry align="center">Header Type</entry>
<entry align="center">Usage</entry>
</row>
</thead>
<tbody>
<row>
<entry>ID</entry>
<entry>java.util.UUID</entry>
<entry><code>MessageHeaders.ID</code></entry>
<entry><code>java.util.UUID</code></entry>
<entry>An identifier for this message instance. Changes each time a message is mutated.</entry>
</row>
<row>
<entry>TIMESTAMP</entry>
<entry>java.lang.Long</entry>
<entry><code>MessageHeaders.TIMESTAMP</code></entry>
<entry><code>java.lang.Long</code></entry>
<entry>The time the message was created. Changes each time a message is mutated.</entry>
</row>
<row>
<entry>REPLY_CHANNEL</entry>
<entry>java.lang.Object (can be a String or MessageChannel)</entry>
<entry><code>MessageHeaders.REPLY_CHANNEL</code></entry>
<entry><code>java.lang.Object</code> (String or MessageChannel)</entry>
<entry>A channel to which a reply (if any) will be sent when no explicit output
channel is configured and there is no <code>ROUTING_SLIP</code> or the
<code>ROUTING_SLIP</code> is exhausted. If the value is a <code>String</code>
it must represent a bean name, or have been generated by a <classname>ChannelRegistry.</classname></entry>
</row>
<row>
<entry>ERROR_CHANNEL</entry>
<entry>java.lang.Object (can be a String or MessageChannel)</entry>
<entry><code>MessageHeaders.ERROR_CHANNEL</code></entry>
<entry><code>java.lang.Object</code> (String or MessageChannel)</entry>
<entry>A channel to which errors will be sent. If the value is a <code>String</code>
it must represent a bean name, or have been generated by a <classname>ChannelRegistry.</classname></entry>
</row>
</tbody>
</tgroup>
@@ -94,59 +103,108 @@
</para>
<para>
Many inbound and outbound adapter implementations will also provide and/or expect certain headers, and additional
user-defined headers can also be configured.
user-defined headers can also be configured. Constants for these headers can be found in those modules where such
headers exist, for example <classname>AmqpHeaders</classname>, <classname>JmsHeaders</classname> etc.
</para>
<section id="message-header-accessor">
<title>MessageHeaderAccessor API</title>
<para>
Since Spring Framework 4.0 and Spring Integration 4.0, the core Messaging abstraction has been moved to
Starting with Spring Framework 4.0 and Spring Integration 4.0, the core Messaging abstraction has been moved to
the <emphasis>spring-messaging</emphasis> module and the new <classname>MessageHeaderAccessor</classname> API
has been introduced to provide additional abstraction over Messaging implementations. All Spring
has been introduced to provide additional abstraction over Messaging implementations. All (core) Spring
Integration specific Message Headers constants are now declared in the
<classname>IntegrationMessageHeaderAccessor</classname>:
<classname>IntegrationMessageHeaderAccessor</classname> class:
<table id="integration-message-headers-table">
<title>Pre-defined Message Headers</title>
<tgroup cols="2">
<tgroup cols="3">
<colspec align="left" />
<thead>
<row>
<entry align="center">Header Name</entry>
<entry align="center">Header Type</entry>
<entry align="center">Usage</entry>
</row>
</thead>
<tbody>
<row>
<entry>CORRELATION_ID</entry>
<entry>java.lang.Object</entry>
<entry><code>IntegrationMessageHeaderAccessor.CORRELATION_ID</code></entry>
<entry><code>java.lang.Object</code></entry>
<entry>Used to correlate two or more messages.</entry>
</row>
<row>
<entry>SEQUENCE_NUMBER</entry>
<entry>java.lang.Integer</entry>
<entry><code>IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER</code></entry>
<entry><code>java.lang.Integer</code></entry>
<entry>Usually a sequence number with a group of messages with a
<code>SEQUENCE_SIZE</code> but can also
be used in a <code>&lt;resequencer/&gt; to resequence an unbounded
group of messages.</code></entry>
</row>
<row>
<entry>SEQUENCE_SIZE</entry>
<entry>java.lang.Integer</entry>
<entry><code>IntegrationMessageHeaderAccessor.SEQUENCE_SIZE</code></entry>
<entry><code>java.lang.Integer</code></entry>
<entry>The number of messages within a group of correlated messages.</entry>
</row>
<row>
<entry>EXPIRATION_DATE</entry>
<entry>java.lang.Long</entry>
<entry><code>IntegrationMessageHeaderAccessor.EXPIRATION_DATE</code></entry>
<entry><code>java.lang.Long</code></entry>
<entry>Indicates when a message is expired. Not used by the framework directly
but can be set with a header enricher and used in a <code>&lt;filter/&gt;</code>
configured with an <classname>UnexpiredMessageSelector</classname>.</entry>
</row>
<row>
<entry>PRIORITY</entry>
<entry>java.lang.Integer</entry>
<entry><code>IntegrationMessageHeaderAccessor.PRIORITY</code></entry>
<entry><code>java.lang.Integer</code></entry>
<entry>Message priority; for example within a <classname>PriorityChannel</classname></entry>
</row>
<row>
<entry><code>IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE</code></entry>
<entry><code>java.lang.Boolean</code></entry>
<entry>True if a message was detected as a duplicate by an idempotent receiver
interceptor. See <xref linkend="idempotent-receiver" />.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
Convenient typed getters for these headers are provided on the
Convenient typed getters for some of these headers are provided on the
<classname>IntegrationMessageHeaderAccessor</classname> class:
<programlisting language="java"><![CDATA[IntegrationMessageHeaderAccessor accessor = new IntegrationMessageHeaderAccessor(message);
int sequenceNumber = accessor.getSequenceNumber();
Object correlationId = accessor.getCorrelationId();
...]]></programlisting>
</para>
<para>
The following headers also appear in the
<classname>IntegrationMessageHeaderAccessor</classname> but are generally not used by
user code; their inclusion here is for completeness:
<table id="extra-integration-message-headers-table">
<title>Pre-defined Message Headers</title>
<tgroup cols="3">
<colspec align="left" />
<thead>
<row>
<entry align="center">Header Name</entry>
<entry align="center">Header Type</entry>
<entry align="center">Usage</entry>
</row>
</thead>
<tbody>
<row>
<entry><code>IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS</code></entry>
<entry><code>java.util.List&lt; List&lt;Object&gt;&gt;</code></entry>
<entry>A stack of correlation data used when nested correlation is needed (e.g. <code>
splitter->...->splitter->...->aggregator->...->aggregator</code>).</entry>
</row>
<row>
<entry><code>IntegrationMessageHeaderAccessor.ROUTING_SLIP</code></entry>
<entry><code>java.util.Map&lt; List&lt;Object&gt;, Integer&gt;</code></entry>
<entry>See <xref linkend="routing-slip" />.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
<section id="message-id-generation">
<title>Message ID Generation</title>