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. kubernetes 实践四:Pod详解

    本篇是关于k8s的Pod,主要包括Pod和容器的使用.Pod的控制和调度管理.应用配置管理等内容. Pod的定义 Pod是k8s的核心概念一直,就名字一样,是k8s中一个逻辑概念.Pod是docekr ...

  2. 如何将 Redis 用于微服务通信的事件存储

    来源:Redislabs作者:Martin Forstner 翻译:Kevin (公众号:中间件小哥) 以我的经验,将某些应用拆分成更小的.松耦合的.可协同工作的独立逻辑业务服务会更易于构建和维护.这 ...

  3. CCF 2016-12-1 工资计算

    CCF 2016-12-1 工资计算 题目 问题描述 小明的公司每个月给小明发工资,而小明拿到的工资为交完个人所得税之后的工资.假设他一个月的税前工资(扣除五险一金后.未扣税前的工资)为S元,则他应交 ...

  4. 1+X证书学习日志 —— css样式表

    ## 因为初级的内容较多,所以选了一些有用的 需要记忆的内容写下 方便日后回顾 CSS语法   选择符{属性:属性值;} ##             所有的css代码 都要放在css样式表里面    ...

  5. 爬虫之PyQuery的base了解

    爬虫之PyQuery的base了解 pyquery库是jQuery的Python实现,能够以jQuery的语法来操作解析 HTML 文档,易用性和解析速度都很好,和它差不多的还有BeautifulSo ...

  6. Java 之 web服务器—Tomcat

    一.服务器 1.服务器 服务器:安装了服务器软件的计算机 2.服务器软件 服务器软件:接收用户的请求,处理请求,做出响应 3.Web 服务器软件 web 服务器软件:接收用户的请求,处理请求,做出响应 ...

  7. HTML表格跨行、跨列操作(rowspan、colspan)

    转自:https://blog.csdn.net/u012724595/article/details/79401401 一般使用<td>元素的colspan属性来实现单元格跨列操作,使用 ...

  8. 0001-代码仓库-mvn

    暂缺 基本介绍 web管理 ifsvnadmin

  9. (比赛)C - 小Q系列故事——最佳裁判(水题)

    C - 小Q系列故事——最佳裁判 Time Limit:200MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Des ...

  10. 浅谈 form 表单提交

    原创文章,转载请注明出处:http://www.cnblogs.com/weix-l/p/7675230.html 若有错误,请评论指出,谢谢! Form 对象代表一个 HTML 表单.在 HTML ...