骆驼 - 获取 jndi 注册表 [英] camel - get jndi registry

查看:33
本文介绍了骆驼 - 获取 jndi 注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 apache camel,我将需要 jndi 注册表,以便我可以将对象绑定到它.

I'm using apache camel, and I will be needing the jndi registry so that I can bind an object to it.

如何从 RouteBuilder 类中检索 JNDI 注册表?我也可以使用 xml 绑定吗?谢谢!

How do I retrieve a JNDI registry from a RouteBuilder class? Can I also bind using xml? Thanks!

推荐答案

我不是在 RouteBuilder 中而是在将上下文添加到 camelMain 之前做到的.

I was able to do it not within the RouteBuilder but before adding context to the camelMain.

JndiRegistry registry = new JndiRegistry();
...
registry.bind("myAntFilter", filter);

DefaultCamelContext context = new DefaultCamelContext(registry);
camelMain.getCamelContexts().add(context);

还需要注意的是,您的/resources 中需要有一个 jndi.properties,其内容如下:

It is also important to note that you need to have a jndi.properties in your /resources with the following content:

java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory

java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory

没有这个,我会得到一个例外.

Without this, I'm getting an exception.

希望对遇到同样问题的人有所帮助

Hope it helps people who stumbled on the same problem

这篇关于骆驼 - 获取 jndi 注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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