python 使用 tibco ems
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的更多相关文章
- Spring 整合 Tibco EMS
参考文档: http://haohaoxuexi.iteye.com/blog/1893038 http://www.blogjava.net/chenhui7502/archive/2011/08 ...
- 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 ...
- TIBCO EMS安装部署
创建用户 groupadd -g 800 tibcouseradd -u 801 -g tibco -d /home/tibco/ -s /bin/bash tibco 目前关于sharedatast ...
- tibco EMS 8.2.0安装
安装环境 序号 项目 值 1 OS版本 Red Hat Enterprise Linux Server release 7.1 (Maipo) 2 内核版本 3.10.0-229.el7.x86_64 ...
- C# EMS Client
从 C# 客户端连接 Tibco EMS 下面例子简要介绍 C# 客户端怎样使用 TIBCO.EMS.dll 来连接 EMS 服务器. using System; using System.Diagn ...
- Jmeter批量调用web service,发送message到tibco JMS queue
[转载]Jmeter使用CSV Data Set Config参数化数据不重复的多次循环执行https://blog.csdn.net/qq_35123018/article/details/7877 ...
- EMS命令
Tibco EMS 初级使用方法小结 http://blog.csdn.net/bincavin/article/details/8290905
- Ajax、Comet、HTML 5 Web Sockets技术比较分析
最近因为考虑研究B/S结构网站即时消息处理 参考了 JAVA怎么样实现即时消息提醒http://bbs.csdn.net/topics/330015611http://www.ibm.com/deve ...
- [转]Spring.Net介绍
转自:http://www.cnblogs.com/cilence/archive/2013/02/21/2920478.html Spring.NET下载地址:http://www.springfr ...
随机推荐
- 下载安装GO,编辑器GOLand和在GOLand上运行项目的几种方式
下载安装GO 下载GO地址:https://golang.google.cn/dl/,一直下一步下一步的操作. 安装完成之后,会有一个GOPATH(此路径是创建go项目的时候会自动在该文件夹下创建), ...
- mongdb基本使用
mongodb创建用户,设置密码 参考:https://www.jianshu.com/p/237a0c5ad9fa MongoDB内置的数据库角色有: 1. 数据库用户角色:read.readWri ...
- Serializer组件
Serializer组件 一 .序列化器-Serializer 作用: 序列化,序列化器会把模型对象转换成字典,经过response以后变成json字符串 反序列化,把客户端发送过来的数据,经过req ...
- ModelSerializer组件
ModelSerializer组件 一 .DRF模型类序列化器 如果我们想要使用序列化器对应的是Django的模型类,DRF为我们提供了ModelSerializer模型类序列化器来帮助我们快速创建一 ...
- 【转】基于FPGA的Sobel边缘检测的实现
前面我们实现了使用PC端上位机串口发送图像数据到VGA显示,通过MATLAB处理的图像数据直接是灰度图像,后面我们在此基础上修改,从而实现,基于FPGA的动态图片的Sobel边缘检测.中值滤波.Can ...
- Locust性能测试_百度案例
一.安装: 1.Locust在PyPI上可用,可以通过pip或easy_install安装:pip install locustio 2.查看Locust可用选项:loc ...
- js获取项目名称
//获取路径 var pathName=window.document.location.pathname; //截取,得到项目名称 var projectName=pathName.substrin ...
- pythdon day13:网络编程socket
目录 day 13 learning python 49. 网络基础 49.1 IP地址 49.2 协议 50. socket编程(套接字编程) 50.1 socket编程简介 50.2 创建sock ...
- Vue通过WebSocket建立长连接
使用场景: 在项目开发中,后端需要处理一连串的逻辑,或者等待第三方的数据返回来进行处理之后在返回给前端,可能时间会很长,而且前端也不知道后端什么时候能处理好(时间长的话会达到10分钟左右),如果采用普 ...
- JavaScript的深浅复制
JavaScript的深浅复制 为什么有深复制.浅复制? JavaScript中有两种数据类型,基本数据类型如undefined.null.boolean.number.string,另一类是Obje ...