简体   繁体   English

Apache Camel:从Bean消费

[英]Apache Camel: Consume from Bean

I have a question about how to invoke a bean as an uri like this: 我有一个关于如何像这样的uri调用bean的问题:

from("bean:MyBeanCall?method=beancallMethod(String1)")

The Consumer has to be dynamic and returns the URI as a String from the bean. 消费者必须是动态的,并从Bean返回URI作为字符串。 Inside the bean I want also use the @Header Annotation to add some Header properties. 在bean中,我还想使用@Header Annotation添加一些Header属性。

The working bean call looks like this: 工作bean调用如下所示:

.bean(MyBeanCall.class,"beancall('String1')");

The bean looks like this: Bean看起来像这样:

public static void beancall(String test, @Header("theHeader") String header, @Header("JMSCorrelationID") String correlationID){...}

But I need the call inside the from() to generate the consumer with the String1 and the Headers. 但是我需要在from()内部进行调用,以使用String1和Headers生成使用者。

From the documentation http://camel.apache.org/bean.html 从文档http://camel.apache.org/bean.html

A bean: endpoint cannot be defined as the input to the route; Bean:端点不能定义为路由的输入; ie you cannot consume from it, you can only route from some inbound message Endpoint to the bean endpoint as output. 也就是说,您不能从中消费,只能将某些入站消息端点路由到bean端点作为输出。 So consider using a direct: or queue: endpoint as the input. 因此,请考虑使用direct:或queue:端点作为输入。

Depending on your requirements, you can use a timer, a scheduleRoutingPolicy, a SimpleScheduleRoutingPolicy or a CronScheduleRoutingPolicy to trigger the route. 根据您的要求,可以使用计时器,scheduleRoutingPolicy,SimpleScheduleRoutingPolicy或CronScheduleRoutingPolicy来触发路由。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM