Java Reference
In-Depth Information
The String name of the channel to which the output of the current component
should be sent if an exception bubbles up into the runtime. This can be overridden.
Used by some components as a threshold for processing after which a component
can wait no longer in processing.
The order in which the message is to be sequenced; typically used with a
The size of the sequence so that an aggregator can know when to stop waiting for
more messages and move forward. This is useful in implementing “join”
Some header values are specific to the type of the source message's payload; for example, payloads
sourced from a file on the file system are different from those coming in from a JMS queue, which are
different from messages coming from an e-mail system. These different components are typically
packaged in their own JARs, and there's usually some class that provides constants for accessing
these headers. An example of component-specific headers are the constants defined for files on
org.springframework.integration.file.FileHeaders : FILENAME and PREFIX . Naturally, when in doubt
you can just enumerate the values manually because the headers are just a java.util.Map instance.
// …
public void interrogateMessage(Message<?> message) {
MessageHeaders headers = message.getHeaders();
for (String key : headers.keySet()) {
logger.debug(String.format("%s : %s", key, headers.get(key)));
These headers let you interrogate the specific features of these messages without surfacing them as
a concrete interface dependency if you don't want them. They can also be used to help processing and
allow you to specify custom metadata to downstream components. The act of providing extra data for
the benefit of a downstream component is called message enrichment . Message enrichment is when you
take the headers of a given Message and add to them, usually to the benefit of components in the
processing pipeline downstream. You might imagine processing a message to add a customer to a
customer relationship management (CRM) that makes a call to a third-party web site to establish credit
ratings. This credit is added to the headers so the component downstream is tasked with either adding
the customer or rejecting it can make its decisions.
Another way to get access to header metadata is to simply have it passed as parameters to your
component's method. You simply annotate the parameter with the @Header annotation, and Spring
Integration will take care of the rest.
package com.apress.springenterpriserecipes.springintegration;
Search WWH ::

Custom Search