2016-05-04 71 views
0

發送一個消息,我有以下的代碼:Spring集成/彈簧云溪:如何使用@inboundchanneladapter

@Bean 
    @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) 
    public MessageSource<String> timerMessageSource() { 
     logger.info("Sending Message"); 
     return() -> new GenericMessage<>(new SimpleDateFormat().format(new Date())); 
    } 

我希望禁用輪詢,這樣我可以發送一個消息出來。我怎麼做?

回答

0

這不會使此應用程序成爲stream :-)您可能只需編寫一個發送單個消息的task

+0

實測值上stackoverlfow帖子的一個例子。 –

-1

代碼:

public interface MessageChannels { 

    @Output("activationMsgQueue") 
    MessageChannel save(); 
} 

代碼:

@Service 
@EnableBinding(MessageChannels.class) 
public class CloudStreamProducer implements MessageSender { 

    private static final Logger LOGGER = LoggerFactory 
     .getLogger(CloudStreamProducer.class); 

    @Autowired 
    MessageChannels msgChannel; 

    public void sendMessage(ActivationDataInfo msg) { 
     msgChannel.save().send(MessageBuilder.withPayload(msg).build()); 
     LOGGER.info("Sent Activation Message to apt Topic : Acct NO = " + msg.getAcctNo() 
      + " TN = " + msg.getTn() + " FlowType = " + msg.getFlowType()); 
    } 

} 
+0

你想用一些解釋來增加你的代碼唯一的答案嗎?它可能會顯着改善它。 – Yunnosch