Oleg's recent segmentation presentation offered a alternative to an error being propagated all the way back to the start of the message flow.

I've encountered an issue and I don't know whether it's my misunderstanding or a bug. If a void method is used in the inbound gateway, and a service-activator/gateway is added to segment the message flow, the call on the void method in the inbound gateway hangs forever. Here's a minimal example:

config.xml
Code:
<int:gateway service-interface="com.example.Producer" default-request-channel="channelA"/>
	
<int:service-activator input-channel="channelA" ref="gateway2"/>
<int:gateway id="gateway2" default-request-channel="channelB"/>
	
<bean id="consumer" class="com.example.Consumer"/>
<int:service-activator input-channel="channelB"  ref="consumer" method="consume"/>
Producer.java
Code:
package com.example;

public interface Producer {
    public void produce(int value);
}

Consumer.java
Code:
package com.example;

public class Consumer {
   public void consume(int value) {
        System.out.println("Consume");
   }
}
Main.java
Code:
package com.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class Main {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("config.xml", Main.class);
        Producer gateway = context.getBean(Producer.class);
        gateway.produce(10);
        System.out.println("Done"); 
    }
    
}
When this code is run "Consume" will be printed but not "Done". It hangs.

This only happens when using a void method. If the produce() and consume() return types are changed to something other than void it does not hang and "Done" is printed.

If the service-activator/gateway2 pair are removed and bypassed it works fine.

If I set a default-reply-timeout on gateway2 it will work, so clearly it is gateway2 that is waiting for a result. It seems like I need a way to tell gateway2 not to expect a reply... but how?

Any suggestions appreciated, setting the default-reply-timeout on gateway2 seems like a bit of a hack!