简体   繁体   English

在构造后触发Spring Integration inbound-channel-adapter?

[英]Spring integration inbound-channel-adapter triggered at post construct?

Suppose I have this class: 假设我有这个课:

public class MyClass {
    public String myMethod() {
         //...
    }
}

What I want is when my application starts, to send the result that myMethod() returns to a certain channel in Spring Integration. 我想要的是在应用程序启动时将myMethod()返回的结果发送到Spring Integration中的某个通道。 What I have tried: 我尝试过的

<bean id="myClass" class="myPackage.MyClass"/>

<int:inbound-channel-adapter channel="channelINeedToSendTo" ref="myClass" method="myMethod">
    <int:poller cron=""/>  <!-- poller configuration -->
</int:inbound-channel-adapter>

Now what can I configure in poller is to call myMethod() at a certain time, on regularly on a certain scheduling, but I wanted to be run exactly after the application started (something like @PostConstruct ). 现在,我可以在poller中配置的是在特定时间,按特定计划定期调用myMethod() ,但我希望在应用程序启动后准确运行(类似于@PostConstruct )。 Is there a simple way achieving this, without complicated AOP techniques? 没有复杂的AOP技术,有没有简单的方法可以实现这一目标?

You can add an Event Inbound Channel Adapter to capture the ContextRefreshedEvent Application Event; 您可以添加事件入站通道适配器以捕获ContextRefreshedEvent应用程序事件; then wire that adapter to a <service-activator/> that invokes myMethod() ; 然后将该适配器连接到调用myMethod()<service-activator/> the result will be on the output-channel . 结果将在output-channel

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Integration轮询多台服务器上的入站通道适配器 - Spring Integration polling inbound-channel-adapter on multiple servers Spring JPA:入站通道适配器配置 - Spring jpa:inbound-channel-adapter configuration 是否可以从Spring Integration http inbound-channel-adapter返回application / json? - Is it possible to return a application/json from a Spring Integration http inbound-channel-adapter? 接收:MessageDeliveryException:分派器没有订阅者在2个不同的spring集成模块中使用入站通道适配器 - Receiving: MessageDeliveryException: Dispatcher has no subscribers using inbound-channel-adapter in 2 different spring integration modules 使用 jms:inbound-channel-adapter 使用 spring 集成向发件人发送自定义确认消息 - Send Custom Acknowledgement message to sender using jms:inbound-channel-adapter using spring integration 春季整合sftp:inbound-channel-adapter delete-remote-files = false - spring integration sftp:inbound-channel-adapter delete-remote-files=false 触发spring-integration int-mail的合适方法是什么:inbound-channel-adapter? - What is the appropriate way to trigger spring-integration int-mail:inbound-channel-adapter? 将作业参数传递给spring集成ftp中的过滤器:inbound-channel-adapter - Pass job parameters to filter in spring integration ftp:inbound-channel-adapter Spring Integration Inbound-Channel-Adapter可逐行读取大型文件 - Spring Integration Inbound-Channel-Adapter to read large files line-by-line Spring Integration入站通道适配器中的覆盖方法 - Override method in spring integration inbound channel adapter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM