Skip to Content
1
Aug 29, 2019 at 05:57 AM

How to make synchronous and Asynchronous call together?

46 Views

Hi All,

We have a requirement to make both async and sync calls for few methods and i have made the following spring configuration in the spring.xml:

<inbound-channel-adapter channel="customerChannel" auto-startup="true" ref="customerBean" method="prepareMessage" >
<!--Triggers for every 12 AM in a day--> 
<poller cron="${customer.cron.expression}"></poller>
</inbound-channel-adapter>

   <service-activator input-channel="updateCustomerLocationsB2BUnitChannel" ref="updateCustomerB2BUnit" method="loadCustomerLocationsB2Bunits" output-channel="endChannel" />
   <service-activator input-channel="updateCustomerLocationsChannel" ref="updateCustomerLocations" method="loadCustomerLocations" output-channel="endChannel"/>
   <service-activator input-channel="updateCustomerSalesOrgChannel" ref="updateCustomerSalesOrg" method="updateCustomerSalesOrg" output-channel="endChannel"/>
   <recipient-list-router id="updateCustomerListRouter" input-channel="customerChannel">
            <recipient channel="updateCustomerLocationsB2BUnitChannel" />
            <recipient channel="updateCustomerLocationsChannel" />
  <recipient channel="updateCustomerSalesOrgChannel" /> 
    </recipient-list-router>

With the above configuration i am able to call only methods asynchronous but i have to call one after the other as well.

Requirement:

loadCustomerLocationsB2Bunits

loadCustomerLocations

updateCustomerSalesOrg

All the methods should execute at a time and after completion of execution of one method the other should execute i.e.,

loadCustomerLocationsB2Bunits -> loadCustomerLocations -> updateCustomerSalesOrg

Thanks,

G Gopinath.