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.

 1 public class Main {
 2
 3
 4
 5        public static void main(String[] args) throws Exception {
 6
 7               Properties props = new Properties();
 8
 9               // ActiveMQ
10
11 //            props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
12
13 //            props.put(Context.PROVIDER_URL, "tcp://localhost:61616");
14
15
16
17               // Tibco
18
19               props.put(Context.INITIAL_CONTEXT_FACTORY, "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
20
21               props.put(Context.PROVIDER_URL, "tibjmsnaming://localhost:7222");
22
23
24
25               // create a new intial context
26
27               javax.naming.Context ctx = new javax.naming.InitialContext(props);
28
29
30
31               // lookup an existing topic
32
33               javax.jms.Topic myTopic = (javax.jms.Topic) ctx.lookup("MyTopic");
34
35               System.out.println(myTopic);
36
37
38
39 // lookup an existing queue
40
41               javax.jms.Queue myQueue = (javax.jms.Topic) ctx.lookup("MyQueue");
42
43               System.out.println(myQueue);
44
45        }
46
47 }

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

时间: 2024-10-09 09:40:45

JNDI support differences between Tibco EMS and ActiveMQ的相关文章

TIBCO EMS安装部署

创建用户 groupadd -g 800 tibcouseradd -u 801 -g tibco -d /home/tibco/ -s /bin/bash tibco 目前关于sharedatastore的方案是使用NAS. 创建准备使用的nfs目录,并赋权限 cd / mkdir/mqdata chown -R tibco:tibco  /mqdata 安装TIBCO   (TIBCO支持绿色安装,即直接从原来的机器上拷贝tibco目录从新创建配置文件即可使用.) cd /opt/softw

Table of Contents - ActiveMQ

ActiveMQ 的安装 Hello World JNDI Support Spring Support 使用 JDBC 持久化消息 删除闲置的队列或主题 Configuring the simple authentication plug-in Configuring the simple authentication plug-in Destination-level authorization Building a custom security plug-in Wildcards and

基于ActiveMQ的统一日志服务

概述 以ActiveMQ + Log4j + Spring的技术组合,实现基于消息队列的统一日志服务. 参考:Spring+Log4j+ActiveMQ实现远程记录日志——实战+分析 与参考文章的比较 1. 更新了技术的版本    e.g. Spring升级到4.2.0,ActiveMQ升级到5.13.2 2. 更新了依赖    e.g. 使用activemq-client 5.13.2替换activemq-core最高版本是5.7.0,并取消了多余的spring-jms依赖 3. 精简了配置 

Tibco BW Event 的调优之旅

开发了个Event Queue的application,从数据库查询一条语句,然后update这条数据,接着调用rest api,这个简单的服务在load test的时候却出现了很多问题. 有的是Event Queue consumer的配置问题,也有SQL语句的问题. 1.当同时传入多条同样的参数数据时候,update语句出现死锁 解决方法:update语句的条件使用主键 2.偶尔服务会出现time out,其实是有另一个定时的job耗时太久,影响到了这个服务 解决办法:将另一个定时job的s

Spring.net(一)----Spring.NET框架简介及模块说明

简介:    Spring.NET框架包括很多功能,Spring.NET 1.0包括完整的IoC容器和AOP类库.1.1版加入Web.ORM和数据模块.Spring.NET的下载包中并不包含与其它类库(如NHibernate,TIBCO EMS,Anthem,和IIOP.NET)集成的模块,如果需要您可以单独下载. Spring Framework天生丽质,因为其先进的架构和对一系列前沿开发思想的集成,使它从一产生就深得开发者欢迎,它将设计模式运用到了炉火纯青的地方,它的幽雅和魅力征服了许多JA

Embarcadero RAD Studio 2016 Product Approach and Roadmap

http://community.embarcadero.com/article/news/16211-embarcadero-rad-studio-2016-product-approach-and-roadmap-2 Embarcadero RAD Studio 2016 Product Approach and Roadmap Written by Marco Cantu, RAD PM. Posted in News As we enter into 2016, the team is

2016年 delphi roadmap

2016年delphi Roadmap 发布,这也是新公司的第一次发布路线图. 虽然稍微晚点( 原来说是1月份发布路线图),至少比过去积极点.喧嚣多年的靴子终于落地. Linux 的支持终于正式公布. http://community.embarcadero.com/article/news/16211-embarcadero-rad-studio-2016-product-approach-and-roadmap-2 整体来说,意料之中. The changes in ownership in

转:Oculus Unity Development Guide开发指南(2015-7-21更新)

http://forum.exceedu.com/forum/forum.php?mod=viewthread&tid=34175 Oculus Unity Development Guide开发指南转载请保留原始地   http://t.cn/RAblKoh Oculus/GearVR开发者群 302294234 Welcometo the Unity Development GuideIntroduction简介Welcometo the Oculus Unity Developer Gui

[转]Spring.Net介绍

转自:http://www.cnblogs.com/cilence/archive/2013/02/21/2920478.html Spring.NET下载地址:http://www.springframework.net/ 各大主流.Net的IOC框架性能测试比较 http://www.cnblogs.com/liping13599168/archive/2011/07/17/2108734.html Castle IOC容器与Spring.NET配置之比较 http://terrylee.c