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. node.js中favicon.ico请求两次问题

    var http=require("http"); var server=http.createServer(); server.on("request",fu ...

  2. Sql Server专题三:SQL操作与技巧

    一.基础 1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- ...

  3. JSONP(转)

    1.一个众所周知的问题,Ajax直接请求普通文件存在跨域无权限访问的问题,甭管你是静态页面.动态网页.web服务.WCF,只要是跨域请求,一律不准: 2.不过我们又发现,Web页面上调用js文件时则不 ...

  4. JVM的体系结构——JVM之三

    JVM的内部体系结构分为四部分, (1)类装载器(ClassLoader)子系统 作用: 用来装载.class文件 (2)执行引擎 作用:执行字节码,或者执行本地方法 (3)垃圾回收子系统 作用:垃圾 ...

  5. 小巧数据库 Derby 使用攻略

    阅读目录 1. Derby 介绍 2. 稍稍配置下环境变量 3. Derby 操作和 Java 访问 回到顶部 1. Derby 介绍 将目光放在小 Derby 的原因是纯绿色.轻巧.内存占用小,分分 ...

  6. grok 正则捕获(就是perl的正则捕获)

    2.3.2 grok 正则捕获: \s+ 和 [\n\t\r\f]+ 一样 1.命名分组格式为(?<grp name>),反向引用时用\k<grp name> 2.命名分组的匹 ...

  7. linux下修改ip地址,默认网关以及DNS

    *修改IP地址 即时生效: ifconfig eth0 192.168.1.100  netmask 255.255.255.0 重启生效: vim  /etc/sysconfig/network-s ...

  8. 2.2.2 胸腰差和胸臀差的应用_米人NOONE_新浪博客

    2.2.2  胸腰差和胸臀差的应用_米人NOONE_新浪博客 腰差和胸臀差的应用(2009-06-16 19:24:57)转载▼标签:校园         前面已经对这两个概念作了简单的讲解.这两个概 ...

  9. SQL中如何使用UPDATE语句进行联表更新(转)

    在本例中: 我们要用表member中的name,age字段数据去更新user中的同字段名的数据,条件是当user 中的id字段值与member中的id字段值相等时进行更新. SQL Server语法: ...

  10. 网站被百度和google封了,怎么办?

    很多站长总是抱着侥幸的心里,通过作弊的方式在搜索引擎上获得一定排名,以致于网站被百度和google封了,也就是所谓的被K站. 那么,要是网站被百度和Google封了,怎么办? 首先要确定你的网站已经被 ...