title: Spring Integration + @Aysnc - Gateway vs ServiceActivator
body: <p>I have a remote service that I'm calling to load pricing data for a product, when a specific event occurs. Once loaded, the product pricing is then broadcast for another consumer to process elsewhere.</p>
  
  <p>The calling code doesn't care about the response - it's fire-and-forget, responding to an application event, and triggering a new workflow.</p>
  
  <p>In order to keep the calling code as quick as possible, I'd like to use @Async here, but I'm having mixed results.</p>
  
  <p>The basic flow is:</p>
  
  <pre><code>CallingCode -&gt; ProductPricingGateway -&gt; Aggregator -&gt; BatchedFetchPricingTask
  </code></pre>
  
  <p>Here's the Async setup:</p>
  
  <pre><code>&lt;task:annotation-driven executor="executor" scheduler="scheduler"/&gt;
  &lt;task:scheduler id="scheduler" pool-size="1" /&gt;
  &lt;task:executor id="executor" keep-alive="30" pool-size="10-20" queue-capacity="500" rejection-policy="CALLER_RUNS" /&gt;
  </code></pre>
  
  <p>The other two components used are a <code>@Gateway</code>, which the intiating code calls, and a down-stream <code>@ServiceActivator</code>, that sits behind an aggregator.  (Calls are batched into small groups).</p>
  
  <pre><code>public interface ProductPricingGateway {    
      @Gateway(requestChannel="product.pricing.outbound.requests")
      public void broadcastPricing(ProductIdentifer productIdentifier);
  }
  
  // ...elsewhere...
  @Component
  public class BatchedFetchPricingTask {
      @ServiceActivator(inputChannel="product.pricing.outbound.requests.batch")
      public void fetchPricing(List&lt;ProductIdentifer&gt; identifiers)
      {
          // omitted
      }
  }
  </code></pre>
  
  <p>And the other relevant intergation config:</p>
  
  <pre><code>&lt;int:gateway service-interface="ProductPricingGateway"
      default-request-channel="product.pricing.outbound.requests" /&gt;
  
  &lt;int:channel id="product.pricing.outbound.requests" /&gt;
  &lt;int:channel id="product.pricing.outbound.requests.batch" /&gt;
  </code></pre>
  
  <p>I find that if I declare <code>@Async</code> on the <code>@ServiceActivator</code> method, it works fine.
  However, if I declare it on the <code>@Gateway</code> method (which seems like a more appropriate place), the aggregator is never invoked.</p>
  
  <p>Why?</p>