10.5.13
Output-channel of Service Activator
public class SimpleServiceActivatorWithOutput {
@ServiceActivator
public String sayHello(String name) {
return "Hello to " + name;
}
}
<int:channel id="output">
<int:queue/>
</int:channel>
<int:channel id="input"/>
<int:service-activator id="activator" ref="handler" input-channel="input" output-channel="output" />
@Test
public void test() {
input.send(MessageBuilder.withPayload("Jeff").build());
Message<?> r = output.receive();
System.out.println(r.getPayload());
}
If I replace SimpleServiceActivatorWithOutput with SimpleDelayedHandler:
public class SimpleDelayedHandler {
@ServiceActivator
public Object justDelay(Object obj) throws Exception {
int wait = new Random().nextInt(5);
System.out.println("Delays in thread " + Thread.currentThread().getId() + " for " + wait + " secs.");
TimeUnit.SECONDS.sleep(wait);
System.out.println("Ends Delaying in thread " + Thread.currentThread().getId());
return null;
}
I can't get things out of output-channel. But if I change "return null" to "return """, then everything works fine.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment