title: UDP handler with Reactor in Spring
body: <p>I want my app to react on UDP events sent from thousands of different clients. Each client sends 1-10 UDP packets every 5-10s. Each packet will and should be processed very quickly (mainly in memory and small calculations, helped with redis, only occasional DB calls). There will be no returning of data to the callers.</p>
  
  <p>I implemented Reactor in Spring like they described on the <a href="https://github.com/reactor/reactor/wiki/Spring" rel="nofollow noreferrer">wiki</a>.
  Then I implemented UDP inbound channel like described on their Spring Integration docs. Here is the config : </p>
  
  <pre><code>&lt;int-ip:udp-inbound-channel-adapter id="receiverChannel"
                                      channel="stringConvert"
                                      port="9000"
                                      multicast="false"
                                      check-length="false"
                                      pool-size="10"
                                      lookup-host="false"
          /&gt;
  
  &lt;int:transformer id="convertChannel"
                   input-channel="stringConvert"
                   output-channel="toProcess"
                   ref="transformer"
                   method="transform"
  
          /&gt;
  
  &lt;int:service-activator input-channel="toProcess"
                         ref="accumulator"
                         method="accumulate"/&gt;
  
  &lt;bean id="accumulator" class="hello.UDPAccumulator" /&gt;
  &lt;bean id="transformer" class="hello.UDPTransformer" /&gt;
  </code></pre>
  
  <p>And then in UDPAccumulator I publish that message to reactor: </p>
  
  <pre><code>@Service
  public class UDPAccumulator {
  
  @Autowired
  ReactorProducer producer;
  
  public void accumulate(String quote) {
      producer.fireEvent(quote);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Is this the "right" way to do this, concerning that I want high throughoutput? What is the inner working of the <em>int-ip:udp-inbound-channel-adapter</em> and can it be the bottle neck before it passes messages to the reactor? I see that reactor have some TCP related classes and support but no UDP. Any suggestion on how to do this the best way is appreciated! </p>
  
  <p>Bonus question. What if messages arrive faster than they are dispatched to reactor? Will <a href="http://docs.spring.io/spring-integration/docs/2.1.x/reference/html/redis.html" rel="nofollow noreferrer">redis message store</a> (bottom of the article) help? And what if my method that crunches this packets in reactor is slow?</p>