3
votes

I am planning to use Spring cloud Stream for my project. I see that there's built-in Trigger source application starter. What I want to do is to use, quartz job scheduler as the source app. This is to allow dynamic job schedules from application. Is there a good sample to achieve this?

I found this. spring integration + cron + quartz in cluster?. This solution talks about getting reference to inbound channel adapter. I am using Annotation to define the inbound channel adapter. How do I get references to this object so that I can do start / stop mentioned in the solution.

This is how i define inbound channel adapter.

@Bean
@InboundChannelAdapter(autoStartup = "false", value = SourceChannel.CHANNEL_NAME, poller = @Poller(trigger = "fireOnceTrigger"))
public MessageSource<String> timerMessageSource() {
    return new MessageSource<String>() {
        public Message<String> receive() {
            System.out.println("******************");
            System.out.println("At the Source");
            System.out.println("******************");
            String value = "{\"value\":\"hi\"}";
            System.out.println("Sending value: " + value);
            return MessageBuilder.withPayload(value).setHeader(MessageHeaders.CONTENT_TYPE, "application/json").build();
        }
    };
}
1

1 Answers

1
votes

The related issue on GitHub: https://github.com/spring-projects/spring-integration-java-dsl/issues/138

The algorithm to build a bean name for automatically created endpoints is like:

The bean names are generated with this algorithm: * The MessageHandler (MessageSource) @Bean gets its own standard name from the method name or name attribute on the @Bean. This works like there is no Messaging Annotation on the @Bean method. * The AbstractEndpoint bean name is generated with the pattern: [configurationComponentName].[methodName].[decapitalizedAnnotationClassShortName]. For example the endpoint (SourcePollingChannelAdapter) for the consoleSource() definition above gets a bean name like: myFlowConfiguration.consoleSource.inboundChannelAdapter.

See Reference Manual for more information.