Spring Integration - Corresponding Sort / Batch Call Template

I have a remote service that I call to download pricing data for a product when a specific event occurs. After loading, the product price is then transmitted to another consumer for processing elsewhere.

Instead of calling a remote service for each event, I would like to organize events in small groups and send them at a time.

I put together the following diagram based on the aggregator. Although it works, it smells a lot, especially mine SimpleCollatingAggregator. I am new to integrating Spring and EIP in general, and suspect that I am using components incorrectly.

The code

My code runs elsewhere in the code by calling the method below @Gateway:

public interface ProductPricingGateway {    
    @Gateway(requestChannel="product.pricing.outbound.requests")
    public void broadcastPricing(ProductIdentifer productIdentifier);
}

:

<int:channel id="product.pricing.outbound.requests" />
<int:channel id="product.pricing.outbound.requests.batch" />
<int:aggregator input-channel="product.pricing.outbound.requests"
output-channel="product.pricing.outbound.requests.batch" release-strategy="releaseStrategy"
    ref="collatingAggregator" method="collate"
    correlation-strategy-expression="0"
    expire-groups-upon-completion="true" 
    send-partial-result-on-expiry="true"/>  
<bean id="collatingAggregator" class="com.mangofactory.pricing.SimpleCollatingAggregator" />
<bean id="releaseStrategy" class="org.springframework.integration.aggregator.TimeoutCountSequenceSizeReleaseStrategy">
    <!-- Release when: 10 Messages ... or ... -->
    <constructor-arg index="0" value="10" />
    <!-- ... 5 seconds since first request -->
    <constructor-arg index="1" value="5000" />
</bean>

:

public class SimpleCollatingAggregator {

    public List<?> collate(List<?> input)
    {
        return input;
    }

}

, @ServiceActivator:

@ServiceActivator(inputChannel="product.pricing.outbound.requests.batch")
public void fetchPricing(List<ProductIdentifer> identifiers)
{
        // omitted
}

. @Async, . , .

1: , , ? - ?

2: 0, : ", , , ".

?

3: SimpleCollatingAggregator .

, ProductIdentifier , . , ? ?

+5
1

Q1: , . Q3 .
Q2: " " ( expire-groups-on-completion, ).
Q3: , ( ref method).

, ; ; , ( 5 ).

MessageGroupStoreReaper : http://static.springsource.org/spring-integration/reference/html/messaging-routing-chapter.html#aggregator

+3

All Articles