python獲取報文參考代碼


# -*- 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM