How to implement a Spring XD sink?

五迷三道 提交于 2019-12-06 11:24:22

A sink is just like a processor but without an output channel; use a @ServiceActivator to invoke your code (which should have a void return).

@MessageEndpoint
public class MyService  
{

    @ServiceActivator( inputChannel = "input")
    public void handle( String payload )
    {
        ...
    }

};

EDIT

For sources, there are two types:

Polled (messages are pulled from the source):

@InboundChannelAdapter(value = "output", 
        poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public String next() {
    return "foo";
}

Message-driven (where the source pushes messages):

@Bean
public MySource source() {
    // return my subclass of MessageProducer that has outputChannel injected
    // and calls sendMessage
    // or use a simple POJO that uses MessagingTemplate.convertAndSend(foo)
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!