emshelper.py

#encoding=utf-8
import jpype jvmpath=r"C:\Program Files\Java\jre1.8.0_161\bin\server\jvm.dll" class EmsHelper(object):
def __init__(self, server= "tcp://localhost:7222",user="admin",pwd=""):
gemsjar = r"E:\EDriver\software\JAVA\jar\Gems.jar;D:\tibco\bw5\ems\8.2\lib\tibjms.jar;D:\tibco\bw5\ems\8.2\lib\tibcrypt.jar;D:\tibco\bw5\ems\8.2\lib\slf4j-api-1.4.2.jar;D:\tibco\bw5\ems\8.2\lib\slf4j-simple-1.4.2.jar;D:\tibco\bw5\ems\8.2\lib\tibjmsadmin.jar;D:\tibco\bw5\ems\8.2\lib\jms-2.0.jar;D:\tibco\bw5\ems\8.2\lib\jndi.jar"
#gemsjar = r"D:\tibco\bw5\ems\8.2\lib\jms-2.0.jar;E:\EDriver\software\JAVA\jar\tibjms.jar"
jvmArg = "-Djava.class.path=.;%s" % gemsjar
jpype.startJVM(jvmpath,jvmArg)
self.TibjmsConnection = jpype.JClass('com.tibco.tibjms.TibjmsConnection')
self.TibjmsConnectionFactory = jpype.JClass('com.tibco.tibjms.TibjmsConnectionFactory') def SendQueueMsg(self,qname="testq",msgstr=str({'id':1,'name':"tname"})):
connfac = self.TibjmsConnectionFactory(server)
conn=connfac.createConnection(user,pwd)
session=conn.createSession(0,1)
dest=session.createQueue(qname)
msgProducer = session.createProducer(None)
msg = session.createTextMessage()
msg.setText(msgstr)
msgProducer.send(dest, msg)
conn.close() def ShowQueueMsg(self,qname="testq",maxlen=5):
connfac = self.TibjmsConnectionFactory(server)
conn=connfac.createConnection(user,pwd)
session=conn.createSession()
queue = session.createQueue(qname)
browser = session.createBrowser(queue)
msgs = browser.getEnumeration()
num = 0
while(msgs.hasMoreElements()):
num+=1
message =msgs.nextElement()
print message.getText()
if(num>=maxlen):
break
browser.close()
conn.close() def HandleOneQueueMsg(self,qname="testq"):
connfac = self.TibjmsConnectionFactory(server)
conn=connfac.createConnection(user,pwd)
session=conn.createSession()
queue = session.createQueue(qname)
dest=session.createQueue(qname)
msgConsumer = session.createConsumer(dest)
conn.start()
msg = msgConsumer.receive()
msg.acknowledge()
self.HandleMsg(msg.getText())
conn.close() def HandleMsg(self,msgstr):
print "message is : ",msgstr if __name__ == '__main__':
server,user,pwd,qname,msgstr="tcp://localhost:7222","admin","","testq",str({'id':1,'name':"tname"})
eh=EmsHelper(server,user,pwd)
eh.HandleQueueMsg()

python 使用 tibco ems的更多相关文章

  1. Spring 整合 Tibco EMS

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

  2. JNDI support differences between Tibco EMS and ActiveMQ

    Introduction Recently our team was working on Veracity Quick Start sprint, when I was trying to migr ...

  3. TIBCO EMS安装部署

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

  4. tibco EMS 8.2.0安装

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

  5. C# EMS Client

    从 C# 客户端连接 Tibco EMS 下面例子简要介绍 C# 客户端怎样使用 TIBCO.EMS.dll 来连接 EMS 服务器. using System; using System.Diagn ...

  6. Jmeter批量调用web service,发送message到tibco JMS queue

    [转载]Jmeter使用CSV Data Set Config参数化数据不重复的多次循环执行https://blog.csdn.net/qq_35123018/article/details/7877 ...

  7. EMS命令

    Tibco EMS 初级使用方法小结 http://blog.csdn.net/bincavin/article/details/8290905

  8. Ajax、Comet、HTML 5 Web Sockets技术比较分析

    最近因为考虑研究B/S结构网站即时消息处理 参考了 JAVA怎么样实现即时消息提醒http://bbs.csdn.net/topics/330015611http://www.ibm.com/deve ...

  9. [转]Spring.Net介绍

    转自:http://www.cnblogs.com/cilence/archive/2013/02/21/2920478.html Spring.NET下载地址:http://www.springfr ...

随机推荐

  1. change事件传值方式 data-set 以及复杂数据类型 可以动态创建对象push到数组里面

    <template>   <div>     <!-- <div class="banner">       <a-breadcru ...

  2. AS3数字取整

    AS3 数字取整方法int()去掉小数点trace(int(3.14)); //输出3trace(int(-3.14)); //输出-3Math.round()方法:Math.round()可以四舍五 ...

  3. [LOJ#3120][Luogu5401][CTS2019]珍珠(容斥+生成函数)

    https://www.luogu.org/blog/user50971/solution-p5401 #include<cstdio> #include<algorithm> ...

  4. Harbor 企业级私有仓库 Ubuntu16.04 搭建及使用

    一.Harbor简介 1.1.什么是Harbor 几个VMware中国的人搞了一个容器镜像仓库.Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器. 1.2.Harbor架 ...

  5. whois

    import 'dart:io'; import 'dart:convert'; main()async{ List a = ['1.cn','2.cn','3.cn','4.cn','5.cn',' ...

  6. sourceTree 3.X免注册[学习]

    一. 在路径C:\****\AppData\Local\Atlassian\SourceTree下创建accounts.json文件 [ { "$id": "1" ...

  7. C++线程同步之事件(生产者与消费者问题)

    #include <windows.h> #include <stdio.h> HANDLE g_hSet = NULL; HANDLE g_hClear = NULL; HA ...

  8. a标签中target属性为“_blank”时存在安全问题

    今天看到一个比较有意思的洞,虽然不够严重,但是却普遍存在各大src中 熟悉js的朋友都应该知道当我们在调用window下的open方法创建一个新窗口的同时,我们可以获得一个创建窗口的opener句柄, ...

  9. AutoMapper 初次使用心得

    本例以asp.net webform为例: 结构: 主要代码:AutoMapperConfig 类 public class AutoMapperConfig { public static void ...

  10. org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案

    org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案 背景描述 Sprin ...