Java 如何实现Spring XD接收器?
到目前为止,我已经实现了Spring XD处理器,例如:Java 如何实现Spring XD接收器?,java,spring,spring-xd,Java,Spring,Spring Xd,到目前为止,我已经实现了Spring XD处理器,例如: @MessageEndpoint public class MyTransformer { @Transformer( inputChannel = "input", outputChannel = "output" ) public String transform( String payload ) { ... } }; 然而,我现在一直在实现一个自定义接收器。当前的文档不是很有用,因为它只是
@MessageEndpoint
public class MyTransformer
{
@Transformer( inputChannel = "input", outputChannel = "output" )
public String transform( String payload )
{
...
}
};
然而,我现在一直在实现一个自定义接收器。当前的文档不是很有用,因为它只是通过XML“神奇地”配置了一些东西:
这将使用redis store出站通道适配器作为接收器。然而,文档并没有告诉我如何创建一个简单、通用的接收器,它只有一个输入通道并使用消息
有谁能给我一个简单的例子吗?接收器就像处理器,但没有输出通道;使用
@ServiceActivator
调用代码(应该有void
返回)
编辑
对于源,有两种类型:
轮询(从源中提取消息):
消息驱动(其中源推送消息):
看起来不错。我假设同样的事情也存在于来源?因为那将是我想尝试的下一件事。。。
<beans ...>
<int:channel id="input" />
<int-redis:store-outbound-channel-adapter
id="redisListAdapter" collection-type="LIST" channel="input" key="${collection}" auto-startup="false"/>
<beans:bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<beans:property name="hostName" value="${host}" />
<beans:property name="port" value="${port}" />
</beans:bean>
</beans>
@MessageEndpoint
public class MyService
{
@ServiceActivator( inputChannel = "input")
public void handle( String payload )
{
...
}
};
@InboundChannelAdapter(value = "output",
poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public String next() {
return "foo";
}
@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)
}