JNDI support differences between Tibco EMS and ActiveMQ
Introduction
Recently our team was working on Veracity Quick Start sprint, when I was trying to migrate the JMS provider implementation from Tibco EMS to ActiveMQ. I found that there are notable differences between these two JMS implementations on their JNDI support, which will be illustrated below.
Code to demonstrate
Code below is a main function which use Java JNDI API to retrieve JMS queue and topic. We will try each implementation by put relevant INITIAL_CONTEXT_FACTORY and PROVIDER_URL into the props object.
public class Main {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
// ActiveMQ
// props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
// props.put(Context.PROVIDER_URL, "tcp://localhost:61616");
// Tibco
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
props.put(Context.PROVIDER_URL, "tibjmsnaming://localhost:7222");
// create a new intial context
javax.naming.Context ctx = new javax.naming.InitialContext(props);
// lookup an existing topic
javax.jms.Topic myTopic = (javax.jms.Topic) ctx.lookup("MyTopic");
System.out.println(myTopic);
// lookup an existing queue
javax.jms.Queue myQueue = (javax.jms.Topic) ctx.lookup("MyQueue");
System.out.println(myQueue);
}
}
Try Tibco EMS
When using Tibco EMS, in order to let the code run successfully, i.e. retrieved myTopic and myQueue objects:
1) There must be a Tibco JMS server running on localhost:7222.
2) A topic named MyTopic and a queue named MyQueue must already be defined.
No other configuration files needed.
Try ActiveMQ
When you try ActiveMQ(uncomment line 5 and 6, and comment line 9 and 10), things are little different:
1) You don’t need to have MyTopic and MyQueue already exists on ActiveMQ server.
2) You even needn’t have a server running at localhost:61616.
3) Put a jndi.properties file on your class path, in which you predefined the wanted queues and topics:
Or use a little different syntax when invoke lookUp in your java code: use dynamicTopics/MyTopic instead of MyTopic, and dynamicQueues/MyQueue instead of MyQueue.
Conclusion
I checked the documentation of both products, also relevant sections in the book ActionMQ in action, and figure out the differences about their JNDI capability:
1) Tibco EMS implements a server-side JNDI provider, you actually need to communicate to server to get your defined queues and topics.
2) ActiveMQ implements a client-side JNDI provider, no communication with server is needed.
When you get queue or topic object by a name passing to lookUp(), it doesn’t means they already exist on server, nor they will be created at that moment. ActiveMQ queues and topics are dynamically created when you actually use them, for example, when you actually send a message to a queue.
Suffice to say, the JNDI support is completely local and has nothing to do with server.
JNDI support differences between Tibco EMS and ActiveMQ的更多相关文章
- tibco EMS 8.2.0安装
安装环境 序号 项目 值 1 OS版本 Red Hat Enterprise Linux Server release 7.1 (Maipo) 2 内核版本 3.10.0-229.el7.x86_64 ...
- Spring 整合 Tibco EMS
参考文档: http://haohaoxuexi.iteye.com/blog/1893038 http://www.blogjava.net/chenhui7502/archive/2011/08 ...
- TIBCO EMS安装部署
创建用户 groupadd -g 800 tibcouseradd -u 801 -g tibco -d /home/tibco/ -s /bin/bash tibco 目前关于sharedatast ...
- ActiveMQ(5.10.0) - JNDI Support
1. Place the jndi.properties file on the classpath. java.naming.factory.initial = org.apache.activem ...
- python 使用 tibco ems
emshelper.py #encoding=utf-8 import jpype jvmpath=r"C:\Program Files\Java\jre1.8.0_161\bin\serv ...
- 使用Tomcat、JNDI与ActiveMQ实现JMS消息通信服务
前言 之所以使用JNDI 是出于通用性考虑,该例子使用JMS规范提供的通用接口,没有使用具体JMS提供者的接口,这样可以保证我们编写的程序适用于任何一种JMS实现(ActiveMQ.HornetQ等) ...
- Table of Contents - ActiveMQ
Getting Started ActiveMQ 的安装 Hello World Configuring Standard ActiveMQ Components Connecting to Acti ...
- eclipse内嵌jetty(run-jetty-run插件) 配置jndi数据源
运行环境 java 6,eclipse juno,ssh(spring,hibernate,springmvc ) 1.离线安装 下载地址:http://pan.baidu.com/s/1qX67wO ...
- 基于ActiveMQ的统一日志服务
概述 以ActiveMQ + Log4j + Spring的技术组合,实现基于消息队列的统一日志服务. 参考:Spring+Log4j+ActiveMQ实现远程记录日志——实战+分析 与参考文章的比较 ...
随机推荐
- nodejs学习随机记录
1. nodejs的顶层对象:global(nodejs中没有window) 2. nodejs一个文件就是一个模块 每个模块都有自己的作用域 通过var声明的变量,只属于当前模块下,并非全局的 va ...
- 容联手机接口封装到ThinkPHP3.2.菜鸟图文教学
今天来说下短信发送技术. 使用的是 容联http://www.yuntongxun.com/ 用法很简单, 具体要知道的参数有 ACCOUNT SID 应用ID AUTH TOKEN 应用toke ...
- 当each遇上list 的一些困惑
在看手册函数的时候,看到each,如下: array each ( array &$array ) 返回数组中当前的键/值对并将数组指针向前移动一步 在执行 each() 之后,数组指针将停留 ...
- PHP性能优化之:配置opcache
启用opcache,并对配置参数进行优化 [opcache] zend_extension = /usr/local/php5/lib/php/extensions/no-debug-zts-2012 ...
- Lwip lwip_recvfrom函数一个数据包不能分多次读取。
最近在写一个基于Lwip协议栈的网络程序,对于一包数据,想先获得包头信息,再根据包头信息读取后面的数据,但是调用recvfrom后,发现读取后面的数据读取不到,进一步查阅发现,原来对于UDP协议,一次 ...
- 从数据库读取数据后显示成html标签
也许很多人从数据库中读的数据是不需要数据成html标签的,但是也许有一天你们会发现当我们需要输出成html标签时编译器却自动帮我们输出成字符串了这是我们可以这样来 方法1: 最常用的方法,使用JS或J ...
- Nginx 变量漫谈(六)
Nginx 内建变量用在“子请求”的上下文中时,其行为也会变得有些微妙. 前面在 (三) 中我们已经知道,许多内建变量都不是简单的“存放值的容器”,它们一般会通过注册“存取处理程序”来表现得与众不同, ...
- HeadFirst设计模式读书笔记(5)-单例模式
单例模式:确保一个类只有一个实例,并提供一个全局访问点. 应用场景:数据库连接.线程池.缓存.对话框.处理偏好设置.注册表的对象.日志对象.充当打印机.显卡等设备的驱动程序对象.任务管理器.网站的计数 ...
- window.opener方法的使用 js跨域
原文:window.opener方法的使用 js跨域 最近公司网站登陆加入了第三方登陆.可以用QQ直接登陆到我们网站,在login页面A中点QQ登陆时,调用了一个window.open文件打开一个lo ...
- 在C#中调用Win32函数EnumWindows枚举所有窗口。
原文 http://www.cnblogs.com/mfm11111/archive/2009/06/30/1514322.html 开发旺旺群发软件,难点及重要技术点分析(一) 一. ...