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. 图片url地址的生成获取方法

    在写博客插入图片时,许多时候需要提供图片的url地址.作为菜鸡的我,自然是一脸懵逼.那么什么是所谓的url地址呢?又该如何获取图片的url地址呢? 首先来看一下度娘对url地址的解释:url是统一资源 ...

  2. WPF内嵌网页的两种方式

    在wpf程序中,有时会内嵌网页.内嵌网页有两种方法,一种是使用wpf自带WebBrowser控件来调用IE内核,另一种是使用CefSharp包来调用chrom内核. 一.第一种使用自带WebBrows ...

  3. 实战远程文件同步(Remote File Sync)

    1. 远程文件同步的常见方式: 1.cron + rsync 优点: 简单 缺点:定时执行,实时性比较差:另外,rsync同步数据时,需要扫描所有文件后进行比对,进行差量传输.如果文件数量达到了百万甚 ...

  4. glfw内存泄露测试

    1. glfwInit()   和  glfwTerminate()  放在主线程  循环次数 1    内存   14M 循环次数100    46M 循环次数1000   49M 2.  glfw ...

  5. 深入理解JVM(五) -- 垃圾回收算法

    上篇文章我们了解到哪些内存区域和哪些对象可以被回收,这篇文章我们就来了解一下具体的垃圾回收算法的思路,不讨论具体的实现. 一 最基础算法 标记-清除(Mark-Swap) 为什么说他是最基础的算法,因 ...

  6. WPF登录功能,对于密码框的操作,其实WPF有个PasswordBox专门的密码框控件,完全可以选择自己要显示的密码符号。

    在链接数据库后,点击登录时需要判断用户名和密码框是否为空,而PasswordBox不像textbox那样判断 textbox判断文本框为空 if (this.UserName.Text.Trim()= ...

  7. Entity framework 生成的SQL如何设置兼容低版本的数据(转载)

    来源:https://q.cnblogs.com/q/84401/ 右键 edmx 文件,有xml方式打开. 将ProviderManifestToken 改为 2008 .

  8. MyBatis之Oracle、Mysql批量插入

    Mybatis中Dao层 public interface UsersMapper { public void insertEntitys(List<UserEntity> users); ...

  9. MySQL Index--CREATE INDEX在各版本的优化

    FIC(Fast index creation)特性在MySQL 5.5版本中引入FIC(Fast index creation)特性,创建索引时无需再拷贝整表数据,以提升索引的创建速度. FCI 操 ...

  10. MySQL Hardware--FIO压测

    FIO参数 .txt 支持文件系统或者裸设备,-filename=/dev/sda2或-filename=/dev/sdb direct= 测试过程绕过机器自带的buffer,使测试结果更真实 rw= ...