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的更多相关文章

  1. tibco EMS 8.2.0安装

    安装环境 序号 项目 值 1 OS版本 Red Hat Enterprise Linux Server release 7.1 (Maipo) 2 内核版本 3.10.0-229.el7.x86_64 ...

  2. Spring 整合 Tibco EMS

    参考文档:  http://haohaoxuexi.iteye.com/blog/1893038 http://www.blogjava.net/chenhui7502/archive/2011/08 ...

  3. TIBCO EMS安装部署

    创建用户 groupadd -g 800 tibcouseradd -u 801 -g tibco -d /home/tibco/ -s /bin/bash tibco 目前关于sharedatast ...

  4. ActiveMQ(5.10.0) - JNDI Support

    1. Place the jndi.properties file on the classpath. java.naming.factory.initial = org.apache.activem ...

  5. python 使用 tibco ems

    emshelper.py #encoding=utf-8 import jpype jvmpath=r"C:\Program Files\Java\jre1.8.0_161\bin\serv ...

  6. 使用Tomcat、JNDI与ActiveMQ实现JMS消息通信服务

    前言 之所以使用JNDI 是出于通用性考虑,该例子使用JMS规范提供的通用接口,没有使用具体JMS提供者的接口,这样可以保证我们编写的程序适用于任何一种JMS实现(ActiveMQ.HornetQ等) ...

  7. Table of Contents - ActiveMQ

    Getting Started ActiveMQ 的安装 Hello World Configuring Standard ActiveMQ Components Connecting to Acti ...

  8. eclipse内嵌jetty(run-jetty-run插件) 配置jndi数据源

    运行环境 java 6,eclipse juno,ssh(spring,hibernate,springmvc ) 1.离线安装 下载地址:http://pan.baidu.com/s/1qX67wO ...

  9. 基于ActiveMQ的统一日志服务

    概述 以ActiveMQ + Log4j + Spring的技术组合,实现基于消息队列的统一日志服务. 参考:Spring+Log4j+ActiveMQ实现远程记录日志——实战+分析 与参考文章的比较 ...

随机推荐

  1. 如何让secureCRT显示Linux的颜色

    style="padding-bottom: 0px; line-height: 1.5; margin: 0px; padding-left: 0px; padding-right: 0p ...

  2. jQuery中的DOM操作总结

    jQuery中的DOM操作 DOM是Document Object Medel的缩写,它的意思是文档对象模型,根据W3C的官方说法,DOM是一种跟浏览器,平台以及语言都没有关系的一种规范,也就是一种接 ...

  3. Android url中文编码问题

    最近项目遇见一个很奇葩问题,关于URL问题,项目中加载图片,图片的URL含有中文,但是,我的手机可以加载,没问题,同事也都可以,但是测试手机却不可以,加载失败,找到问题,就是URL含有中文问题. 解决 ...

  4. Android中Handle详解

    上图为本人总结的Handler,网上发现一片总结很好的博客就copy过来:作为参考 Handler有何作用?如何使用? 一 .Handler作用和概念 包含线程队列和消息队列,实现异步的消息处理机制, ...

  5. 复习完毕STM32开发板

        经过半个晚上的折腾,终于复习了STM32开发板,并使用ST官方库调试完毕一个printf重定向到串口的程序,3.5的库同以前的库不大一样,不过最终搞好了可以睡觉了,还可以睡7个小时.     ...

  6. javascript模式

    http://developer.51cto.com/art/201212/372725.htm http://justjavac.com/javascript/2012/12/14/model-vi ...

  7. [Leetcode][Python]54: Spiral Matrix

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 54: Spiral Matrixhttps://leetcode.com/p ...

  8. 【DSA MOOC】有序向量二分查找的三个 版本

    内容来自 TsinghuaX: 30240184X 数据结构(2015秋) 课程的Vector一章,对有序向量的二分查找有三个版本 三个版本的函数原型是一致的,都是 Rank search(T con ...

  9. hdu 1698 Just a Hook_线段树

    题意:给你个n,表示区间[1,n],价值初始为1,给你m段区间和价值,更新区间,区间价值以最后更新为准,问更新后区间价值总和为多少 思路:两种方法,可以先存下来,倒过来更新,一更新节点马上跳出,比较快 ...

  10. linux 启动 oracle数据库

    第一步:切换到oracle用户 su - oracle 第二步:启动oracle数据库监听 lsnrctl start 第三步:输入下方命令,出现:sql> sqlplus /nolog 第四步 ...