python获取报文参考代码

2023-03-12,,

# -*- coding:utf-8 -*-

import sys
import stomp
import logging
import time class MyListener(object):
def on_error(self, headers, message):
print '%s:received an error:\n%s' % (time.strftime('%Y-%m-%d %X', time.localtime(time.time())), message) def on_message(self, headers, message):
print '%s:received a message:\n%s' % (time.strftime('%Y-%m-%d %X', time.localtime(time.time())), message) #机票信息
dest1 = '/topic/topic.testtour2.rss.packageBasic.update'
#航班和起降信息
dest2 = '/topic/topic.testtour2.rss.flightAndTakeOff.update'
#加价规则
dest3 = '/topic/topic.testtour2.rss.packageDatePrice.update'
#采购规则
dest4 = '/topic/topic.testtour2.rss.packagePurchase.update'
#库存信息
dest5 = '/topic/topic.menpiao.stk.diyPackageRound.update'
#全量机票
dest6='/topic/topic.testtour2.rss.packageResIds.update'
logging.basicConfig() conn = stomp.Connection([('IP地址', 61613)])
conn.set_listener('', MyListener())
conn.start()
conn.connect(wait = True) num=4
#机票信息=1,航班和起降信息=2,加价规则=3,采购规则=4,库存信息=5,全量机票n if num==1:
dest=dest1
elif num==2:
dest=dest2
elif num==3:
dest=dest3
elif num==4:
dest=dest4
elif num==5:
dest=dest5
else:
dest=dest6
conn.subscribe(destination = dest, id = 1, ack = 'auto')
while True:
try:
time.sleep(1)
except:
break

python获取报文参考代码的相关教程结束。

《python获取报文参考代码.doc》

下载本文的Word格式文档,以方便收藏与打印。