Spring 云流 + Quartz
Spring Cloud Stream + Quartz
我打算在我的项目中使用 Spring 云流。我看到有内置的触发器源应用程序启动器。我想要做的是使用石英作业调度程序作为源应用程序。这是为了允许来自应用程序的动态作业计划。有没有很好的示例来实现这个?
我找到了这个。 spring integration + cron + quartz in cluster?。该解决方案讨论获取对入站通道适配器的引用。我正在使用注释来定义入站通道适配器。如何获取对此对象的引用,以便我可以执行解决方案中提到的启动/停止。
这就是我定义入站通道适配器的方式。
@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();
}
};
}
GitHub 上的相关问题:https://github.com/spring-projects/spring-integration-java-dsl/issues/138
为自动创建的端点构建 bean 名称的算法如下:
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
.
有关详细信息,请参阅 Reference Manual。
我打算在我的项目中使用 Spring 云流。我看到有内置的触发器源应用程序启动器。我想要做的是使用石英作业调度程序作为源应用程序。这是为了允许来自应用程序的动态作业计划。有没有很好的示例来实现这个?
我找到了这个。 spring integration + cron + quartz in cluster?。该解决方案讨论获取对入站通道适配器的引用。我正在使用注释来定义入站通道适配器。如何获取对此对象的引用,以便我可以执行解决方案中提到的启动/停止。
这就是我定义入站通道适配器的方式。
@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();
}
};
}
GitHub 上的相关问题:https://github.com/spring-projects/spring-integration-java-dsl/issues/138
为自动创建的端点构建 bean 名称的算法如下:
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. * TheAbstractEndpoint
bean name is generated with the pattern:[configurationComponentName].[methodName].[decapitalizedAnnotationClassShortName]
. For example the endpoint (SourcePollingChannelAdapter
) for theconsoleSource()
definition above gets a bean name like:myFlowConfiguration.consoleSource.inboundChannelAdapter
.
有关详细信息,请参阅 Reference Manual。