如何使用Java DSL将类型为object的组件参数设置为路由? [英] How do I set a component parameter of type object to a route using Java DSL?

查看:81
本文介绍了如何使用Java DSL将类型为object的组件参数设置为路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是与Camel及其JMS组件一起使用.

My objective is to use Camel along with its JMS component.

路由配置如下所示-

from("jms:queue:test").to(mybean) 

我想添加'parameter'类型的选项并在该路由中键入'object'-例如选项'jmsMessageType'.

I would like to add the option of kind 'parameter' and type 'object' to this route -for example the option 'jmsMessageType'.

我看到了其他一些文章,它们讨论在路由定义上使用setProperty(),但是找不到确切的答案.可以将类型为字符串"和数字的选项附加到URI,但不能附加到对象.

I saw some other posts that talks about using setProperty() on route definition but I could not find a definite answer. Options of type 'string' and numbers can be appended to the URI but not objects.

JMS有一个taskExecutor选项,但是如何将其实例添加到URI进行路由.

JMS has an option of taskExecutor but how can i add an instance of this to URI for routing.

推荐答案

我必须通过将实例添加到自定义注册表中并通过端点URI使用它们来解决此问题

I had to resolve this by adding the instances to a custom registry and using them from the endpoint URI

从Apache Camel官方页面上

From official Apache Camel page

从骆驼2.0:

From Camel 2.0:

使用URI语法配置端点时,您现在可以引用bean 在注册表中使用#表示法.如果参数值开始 带有#号,然后Camel将在注册表中查找Bean的 给定的类型.例如:

When configuring endpoints using URI syntax you can now refer to beans in the Registry using the # notation. If the parameter value starts with a # sign then Camel will lookup in the Registry for a bean of the given type. For instance:

file://inbox?sorter =#mySpecialFileSorter

file://inbox?sorter=#mySpecialFileSorter

这篇关于如何使用Java DSL将类型为object的组件参数设置为路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆