From 0f568c05262c67392ae1b3997f45e9df2a1b9e00 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 10 Nov 2014 09:51:35 -0500 Subject: [PATCH] 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 --- .../IntegrationMessageHeaderAccessor.java | 6 +- .../channel/DefaultHeaderChannelRegistry.java | 2 + ...ressionEvaluatingRequestHandlerAdvice.java | 5 +- .../selector/MetadataStoreSelector.java | 4 +- src/reference/docbook/message.xml | 108 ++++++++++++++---- 5 files changed, 95 insertions(+), 30 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java b/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java index 42a9848f49..04da278728 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java @@ -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 diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java index 64b036ae93..28567482d5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java @@ -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) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java index 0ab29c6a82..979d8c9653 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java @@ -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 diff --git a/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java b/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java index ff55a88cc6..d56e038017 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java @@ -25,10 +25,10 @@ import org.springframework.util.Assert; /** * The {@link MessageSelector} implementation using a {@link ConcurrentMetadataStore} - * and {@link MessageProcessor}. + * and {@link MessageProcessor}. *

* The {@link #accept} method extracts {@code metadataKey} from the provided {@code message} - * using {@link MessageProcessor} 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. *

* The successful result of the {@link #accept} method is based on the diff --git a/src/reference/docbook/message.xml b/src/reference/docbook/message.xml index d109ccc7ba..05cfc36c9e 100644 --- a/src/reference/docbook/message.xml +++ b/src/reference/docbook/message.xml @@ -63,30 +63,39 @@ The following Message headers are pre-defined: Pre-defined Message Headers - + Header Name Header Type + Usage - ID - java.util.UUID + MessageHeaders.ID + java.util.UUID + An identifier for this message instance. Changes each time a message is mutated. - TIMESTAMP - java.lang.Long + MessageHeaders.TIMESTAMP + java.lang.Long + The time the message was created. Changes each time a message is mutated. - REPLY_CHANNEL - java.lang.Object (can be a String or MessageChannel) + MessageHeaders.REPLY_CHANNEL + java.lang.Object (String or MessageChannel) + A channel to which a reply (if any) will be sent when no explicit output + channel is configured and there is no ROUTING_SLIP or the + ROUTING_SLIP is exhausted. If the value is a String + it must represent a bean name, or have been generated by a ChannelRegistry. - ERROR_CHANNEL - java.lang.Object (can be a String or MessageChannel) + MessageHeaders.ERROR_CHANNEL + java.lang.Object (String or MessageChannel) + A channel to which errors will be sent. If the value is a String + it must represent a bean name, or have been generated by a ChannelRegistry. @@ -94,59 +103,108 @@ 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 AmqpHeaders, JmsHeaders etc.
MessageHeaderAccessor API - 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 spring-messaging module and the new MessageHeaderAccessor 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 - IntegrationMessageHeaderAccessor: + IntegrationMessageHeaderAccessor class:
Pre-defined Message Headers - + Header Name Header Type + Usage - CORRELATION_ID - java.lang.Object + IntegrationMessageHeaderAccessor.CORRELATION_ID + java.lang.Object + Used to correlate two or more messages. - SEQUENCE_NUMBER - java.lang.Integer + IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER + java.lang.Integer + Usually a sequence number with a group of messages with a + SEQUENCE_SIZE but can also + be used in a <resequencer/> to resequence an unbounded + group of messages. - SEQUENCE_SIZE - java.lang.Integer + IntegrationMessageHeaderAccessor.SEQUENCE_SIZE + java.lang.Integer + The number of messages within a group of correlated messages. - EXPIRATION_DATE - java.lang.Long + IntegrationMessageHeaderAccessor.EXPIRATION_DATE + java.lang.Long + Indicates when a message is expired. Not used by the framework directly + but can be set with a header enricher and used in a <filter/> + configured with an UnexpiredMessageSelector. - PRIORITY - java.lang.Integer + IntegrationMessageHeaderAccessor.PRIORITY + java.lang.Integer + Message priority; for example within a PriorityChannel + + + IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE + java.lang.Boolean + True if a message was detected as a duplicate by an idempotent receiver + interceptor. See .
- Convenient typed getters for these headers are provided on the + Convenient typed getters for some of these headers are provided on the IntegrationMessageHeaderAccessor class: + + The following headers also appear in the + IntegrationMessageHeaderAccessor but are generally not used by + user code; their inclusion here is for completeness: + + Pre-defined Message Headers + + + + + Header Name + Header Type + Usage + + + + + IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS + java.util.List< List<Object>> + A stack of correlation data used when nested correlation is needed (e.g. + splitter->...->splitter->...->aggregator->...->aggregator). + + + IntegrationMessageHeaderAccessor.ROUTING_SLIP + java.util.Map< List<Object>, Integer> + See . + + + +
+

Message ID Generation