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
python获取报文参考代码的更多相关文章
- Python获取网页html代码
获取网页html代码: import requests res = requests.get('https://www.cnblogs.com/easyidea/p/10214559.html') r ...
- python获取系统时间代码解析
import time print time.time() 输出的结果是: 1279578704.6725271 但是这样是一连串的数字不是我们想要的结果,我们可以利用time模块 ...
- [python实用代码片段]python获取当前时间的前一天,前一周,前一个月
python获取当前时间的前一天,前一周,前一个月. 实用python的datetime.timedelta方法,避免了有的月份是30和31等不同的情况. 获取前一个月的时间,方法实现:首先datet ...
- python 获取 mac 地址 的代码
python 获取 mac 地址 的例子,有需要的朋友可以参考下. #!/bin/python import os import re def GetMac(): if os.name == ...
- python 获取代码宿主机名 ip
1.获取hostname 相同代码 不同宿主机 日志名 互异 且 可识别宿主机 分布式爬虫 https://docs.python.org/3.6/library/socket.html#socket ...
- Python获取CPU、内存使用率以及网络使用状态代码
Python获取CPU.内存使用率以及网络使用状态代码_python_脚本之家 http://www.jb51.net/article/134714.htm
- shell,python获取当前路径(脚本的当前路径) (aso项目记录)
一.shell获取脚本当前路径 cur_dir=$(cd "$(dirname "$0")"; pwd) #获取当前脚本的绝对路径,参数$0是当前脚本对象 等 ...
- c#代码 天气接口 一分钟搞懂你的博客为什么没人看 看完python这段爬虫代码,java流泪了c#沉默了 图片二进制转换与存入数据库相关 C#7.0--引用返回值和引用局部变量 JS直接调用C#后台方法(ajax调用) Linq To Json SqlServer 递归查询
天气预报的程序.程序并不难. 看到这个需求第一个想法就是只要找到合适天气预报接口一切都是小意思,说干就干,立马跟学生沟通价格. 不过谈报价的过程中,差点没让我一口老血喷键盘上,话说我们程序猿的人 ...
- 用Python获取计算机网卡信息
目录 0. 前言 1. 测试环境及关键代码解释 1.1 测试环境 1.1.1 系统: 1.1.2 开发工具: 2. 模块介绍及演示 2.1 platform模块使用示例 2.2 netifaces模块 ...
- Python 获取 exe 的 icon 并且保存
Python 获取 exe 的 icon 并且保存 参考链接:https://mail.python.org/pipermail/python-win32/2009-April/009078.html ...
随机推荐
- JavaSE——构造方法
package com.zhao.test3; public class Student { private String name; private int age; //如果我们自己没有写任何的构 ...
- go简单写个ini配置文件读取工具
直接上代码: 1 package main 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "reflect" 7 ...
- Python项目框架的搭建
Python的框架搭建,有七个步骤 第一步:创建项目 首先我们打开pycharm,然后点击第一个Create New Project ,创建一个新的项目. 在选项里面是有一个Flask的,然后就是项目 ...
- Spring框架3--Web
Spring框架之Web Javaweb三大组件和四大域 顺便:Javaweb中的四大域,作用范围如下:PageContext<Request<Session<ServletCont ...
- CSP202104-4校门外的树
`#include include include include include include include include include include include include us ...
- 22_webpack_优化
Terser是一个JS的解析(Parser).Mangleer(绞肉机).Compresor(压缩机)的工具 绞肉机如:一个函数 function functionsWithLongNames(){ ...
- (0313) ICer,root 权限密码
2020
- go 语言的宕机恢复(recover)
go 语言中的三种报错机制 第一种,也就是常说的 error 类型错误,不需要 recover 拯救,处理方式自己决定 第二种,panic 和 recover 是紧密集合的,有点类似 try catc ...
- Cannot add middleware after an application has started
This helped: Open the Command Prompt or the Windows PowerShell. Navigate to your Stable Diffusion fo ...
- csp2020——T3表达式
后缀表达式基本可以使用栈来表达,所以30分的暴力做法很好做 正解的做法是: 暴力的做法是每次重新建立栈,用符号来把栈顶的元素弹出来,做完运算之后再放入栈中,如果是与运算,弹出两个元素,如果是或运算,弹 ...