Spring Integration/Spring cloud Stream:如何使用@inboundchannelad



我有以下代码:

 @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()));
    }

我想禁用轮询器,这样我就可以发送一条消息了。我该怎么做?

这不会使此应用程序成为stream:-)您可能只编写一个发送单个消息的任务。

代码:

 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());
    }
}

最新更新