有没有人知道如何将松弛通道连接到一条路由上?使用Java DSL可以做到这一点吗?
有没有人有配置该组件的示例?
发布于 2018-10-20 05:51:12
Apache使用松弛的传入webhook。This link显示了如何创建应用程序和设置webhooks的详细信息。
如果您的通道能够接收消息,您的java代码可能如下所示(XXX/YYY/ZZZ将根据您创建的钩子进行更改):
final CamelContext camel = new DefaultCamelContext();
final SlackComponent slackComponent = (SlackComponent) camel.getComponent("slack");
slackComponent.setWebhookUrl("https://hooks.slack.com/services/XXX/YYY/ZZZ");
/* Create the routes */
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("timer:test?period=2000").setBody(simple("foo")).to("slack:#general");
}});
考虑到由于webhooks的限制,消费端将无法工作,您只能将消息发送到一个通道。
发布于 2016-11-29 23:51:55
阿帕奇似乎支持使用incoming webhook向slack发送消息。
有关详细信息,请查看官方Apache camel文档here。
发布于 2018-03-13 00:57:13
一旦您在项目中添加了camel-slack依赖项,组件就会自动注册到camel上下文中。您可以从那里获取SlackComponent并在扩展的RouteBuilder中对其进行配置:
public void configure() throws Exception {
//...
// get the slack component
final SlackComponent slackComponent = (SlackComponent) this.getContext().getComponent("slack");
// set the webhook URL
slackComponent.setWebhookUrl("<yourWebhookUrl>"));
//...
this.from("direct:notification").to("slack:#your-channel")
}
https://stackoverflow.com/questions/40869183
复制相似问题