title: Spring Integration - The 'currentComponent' (routerFlow) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'
body: <p>I have implemented a RecipientListRouter shown below -</p>
  <pre><code>    @Bean
      public RecipientListRouter routerFlow() {
          RecipientListRouter router = new RecipientListRouter();
          router.setIgnoreSendFailures(true);
          router.setApplySequence(true);
          router.addRecipient(&quot;channelChkn&quot;, &quot;headers.get('eventSubType').contains('CHKN')&quot;);
          router.addRecipient(&quot;channelBkd&quot;, &quot;headers.get('eventSubType').contains('BKD')&quot;);
          router.addRecipient(&quot;channelBrd&quot;, &quot;headers.get('eventSubType').contains('BRD')&quot;);
          router.addRecipient(&quot;channelAciRecCncl&quot;, &quot;headers.get('eventSubType').contains('ACI-REC-CNCL')&quot;);
          router.addRecipient(&quot;channelSeatAsgn&quot;, &quot;headers.get('eventSubType').contains('SEATNBR-')&quot;);
          router.addRecipient(&quot;channelDeboard&quot;, &quot;headers.get('isDeBoarded') == true&quot;);
          router.setDefaultOutputChannelName(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
          LOGGER.info(&quot;********************* RecipientListRouter *********************&quot; + router.getRecipients());
          return router;
      }
  
  </code></pre>
  <p>My event flow is</p>
  <pre><code>    @Bean
      public IntegrationFlow baseEventFlow() {
  
          return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(kafkaMessageListenerContainer))
                  .filter(filterMessage, &quot;rejectPastData&quot;)
                  .transform(aciMessageTransformer, &quot;parserXMLMessage&quot;)
                  .route(routerFlow())
                  // executor used to parallelise the multiple subscribe execution
                  .publishSubscribeChannel(Executors.newCachedThreadPool(),
                          pubsub -&gt; pubsub.subscribe(flow -&gt; flow.channel(&quot;pubCountEvntChannel&quot;))
                                  .subscribe(flow -&gt; flow.channel(&quot;pubTravlerEventChannel&quot;)))
                  .get();
  
      }
  </code></pre>
  <p>I am getting the Bean Creation exception - The 'currentComponent' (routerFlow) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'</p>
  <p>It seems that after route we can't invoke any handler method in the parent flow. But in my scenario the handler in the route processes the data and sets a value in the java object that needs to be used in the main flow to publish to the down-line channels.</p>
  <p>Please suggest how to achieve this</p>
  <p>##Edited##</p>
  <p>If I add the below recipient in the router list then I believe the the channel will always be among the list of recipients and I can do the processing after the event is processed by the handlers.  Please confirm if the below recipient will be added at the end of the router list.</p>
  <pre><code>router.addRecipient(&quot;pubSubChannel&quot;);
  </code></pre>
  <p>Also, if the message header doesn't match with any of the values then we are sending it to the default NULL channel, discarding the message.</p>
  <p>If we add the above &quot;pubSubChannel&quot; recipient then what will be the impact of the un-matched messages. Do I have to handle the unmatched messages in the pubSubEventChannel?</p>
  <p>Please suggest</p>
  <p><strong>###EDITED</strong></p>
  <pre><code>    @Bean
      public IntegrationFlow baseEventFlow() {
  
          return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(kafkaMessageListenerContainer))
                  .filter(filterMessage, &quot;rejectPastData&quot;)
                  .transform(aciMessageTransformer, &quot;parserXMLMessage&quot;)
                  .gateway(eventFlow())
                  .handle (test())
                  .get()
     }
  
      @Bean
      public IntegrationFlow eventFlow() {
          return f -&gt; f.route(routerFlow());
      }
  
      @Bean
      public RecipientListRouter routerFlow() {
          RecipientListRouter router = new RecipientListRouter();
          router.setIgnoreSendFailures(true);
          router.setApplySequence(true);
          router.addRecipient(&quot;channelChkn&quot;, &quot;headers.get('eventSubType').contains('CHKN')&quot;);
          router.addRecipient(&quot;channelBkd&quot;, &quot;headers.get('eventSubType').contains('BKD')&quot;);
          router.addRecipient(&quot;channelBrd&quot;, &quot;headers.get('eventSubType').contains('BRD')&quot;);
          router.addRecipient(&quot;channelAciRecCncl&quot;, &quot;headers.get('eventSubType').contains('ACI-REC-CNCL')&quot;);
          router.addRecipient(&quot;channelSeatAsgn&quot;, &quot;headers.get('eventSubType').contains('SEATNBR-')&quot;);
          // router.addRecipient(&quot;channelSeatAsgn&quot;,&quot;headers.get('eventSubType').contains('SEATNBR-ASSIGN')&quot;);
          // router.addRecipient(&quot;channelSeatAsgn&quot;,&quot;headers.get('eventSubType').contains('SEATNBR-CHG')&quot;);
          router.addRecipient(&quot;channelDeboard&quot;, &quot;headers.get('isDeBoarded') == true&quot;);
          //router.setDefaultOutputChannelName(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
          LOGGER.info(&quot;********************* RecipientListRouter *********************&quot; + router.getRecipients());
          return router;
      }
  
  </code></pre>