Frage

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. 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). Is there a simple way achieving this, without complicated AOP techniques?

War es hilfreich?

Lösung

You can add an Event Inbound Channel Adapter to capture the ContextRefreshedEvent Application Event; then wire that adapter to a <service-activator/> that invokes myMethod(); the result will be on the output-channel.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top