From 858570882e5b5b20aa0329da66dd1d99ada9c0ac Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Fri, 12 Nov 2010 09:27:49 -0500 Subject: [PATCH] INT-1516 added docs for aggregator ans SpEL --- docs/src/reference/docbook/aggregator.xml | 39 ++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/src/reference/docbook/aggregator.xml b/docs/src/reference/docbook/aggregator.xml index 585d3f30d8..b37f0b0e1d 100644 --- a/docs/src/reference/docbook/aggregator.xml +++ b/docs/src/reference/docbook/aggregator.xml @@ -323,7 +323,8 @@ id="aggxmlCorrelationStrategyMethod" /> + send-timeout="86420000" ]]> @@ -420,6 +421,10 @@ The timeout for sending the aggregated messages to the output or reply channel. Optional. + + + SpEL expression to handle release strategy Optional. + Using a "ref" attribute is generally recommended if a custom @@ -492,6 +497,38 @@ strategy method and the aggregator method can be combined in a single bean (all of them or any two). + + + Aggregators and Spring Expression Language (SpEL) + + + + Since Spring Integration 2.0, the release strategy may be handled with SpEL (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html) + which would be recommend if the logic behind such release strategy is relatively simple. + Let's say you have a legacy component which was designed to receive an array of objects. We know that default release + strategy will assemble all aggregated messages in the List. So now we have two problems. First we need to extract individual + messages form such list, extract payload of each message and assemble them into the array of objects (see code below) + + > mesages){ + List strList = new ArrayList(); + for (Message message : mesages) { + strList.add(message.getPayload()); + } + return strList.toArray(new String[]{}); +}]]> + + However, with SpEL such requirement could actually be handled relatively easy with a simple + one-line expression, thus sparing you from writing a custom class and configuring it as a bean. + + ]]> + + In the above configuration we are using Collection Projection expression + (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html#d0e12113) to + assemble a new collection from the payloads of all messages in the list and then transforming it to an Array, thus + achieving the same result as the java code above. +