zeromq

Python multithreaded ZeroMQ REQ-REP

淺唱寂寞╮ 提交于 2019-11-30 18:04:25
问题 I am looking to implement a REQ-REP pattern with Python and ZeroMQ using multithreading. With Python, I can create a new thread when a new client connects to the server. This thread will handle all communications with that particular client, until the socket is closed: # Thread that will handle client's requests class ClientThread(threading.Thread): # Implementation... def __init__(self, socket): threading.Thread.__init__(self) self.socket = socket def run(self): while keep_alive: # Thread

zero-mq: socket.recv() call is blocking

邮差的信 提交于 2019-11-30 17:50:07
问题 I am trying to use zero-mq.My requirement is very simple.I want to be able to communicate between two peers in a network.I came across this program in the examples in the book. $ pub_server.py import zmq import random import sys import time port = "5556" if len(sys.argv) > 1: port = sys.argv[1] int(port) context = zmq.Context() socket = context.socket(zmq.PUB) socket.bind("tcp://*:%s" % port) while True: topic = random.randrange(9999,10005) messagedata = random.randrange(1,215) - 80 print "%d

What is the difference between using ZMQ PUB with .connect() or .bind() methods?

一个人想着一个人 提交于 2019-11-30 17:44:26
问题 In Python ZMQ publisher/subscriber sample template, the publisher uses .bind() method and the subscriber uses .connect() method, that connected to the bind IP address. But we can replace .bind() and .connect() each with the other. My question is that what is the difference between two cases that determined below? (two scripts in these cases work fine) The first case, as default: pub1.py: import zmq import time from datetime import datetime def create_pub_socket(): context = zmq.Context()

examples of zeromq pub/sub with C# winform

自闭症网瘾萝莉.ら 提交于 2019-11-30 13:24:08
I'm trying to create a C# Winform application that uses ZeroMQ (clrzmq .net bindings (x86) via nuget) in a pub/sub model. After much searching, I can only find standalone C# examples where the code uses a while statement to process new messages indefinitely. When I try to use these examples, I don't know where to put the code, and it just blocks the gui and everything else. I don't know if it's impossible to do without using another thread, but I was under the impression that ZeroMQ's asynchronous behaviors could work without coding extra threads. Perhaps I just don't know where to put the

网站架构中为什么要用到消息队列

别说谁变了你拦得住时间么 提交于 2019-11-30 12:25:03
很多没有实际项目经验的小伙伴,对消息队列系统非常陌生,看着很多架构的介绍中,都提到消息队列。但是,不知道为什么要用消息队列?什么是消息队列?常见的消息队列产品有哪些? 通过阅读本文,帮你解开以上的疑惑。 1.为什么要用消息队列? 假设一个老大,接到一个任务要处理完。在处理这个任务时,把这个任务分解为几个小任务,只要分别完成了这几个小任务,整个任务也就完成了。 做到某个小任务时,发现这个小任务需要花很多时间完成,而且这个小任务迟点完成也不影响整个任务的完成进度。于是,老大把这个小任务交个一个小弟去做,自己去接着完成其他的任务。 在上面的例子中,老大就是后台系统,小弟就是消息队列系统,当后台系统发现完成某些小任务需要花很多时间,而且迟点完成也不影响整个任务的,就会把这些小任务交给消息队列系统。 在实际的app后端中,发送邮件,发送短信,推送等这些任务,都非常适合在消息队列系统中做的。大家想想,这些任务是不是都需要花比较多的时间,而且迟点完成也不影响的。把这些任务放在队列中,可加快请求的响应时间。 2.消息队列是怎么工作? 消息队列系统,一般都包含3个角色:队列服务端,队列的生产者,队列的消费者。 消息队列系统类似于这个场景:有一条信息传送带不停地运转。在传送带的起点,工人a不断地把信息放在一个盒子,把盒子放到传送带上,盒子被传送带传送到终点。在终点上,工人b把盒子上的信息取出来

Compile simple hello world ZeroMQ C example, compile flags?

大憨熊 提交于 2019-11-30 12:07:08
问题 Trying to compile the example hello_world.c from the zeromq tutorial: http://zguide.zeromq.org/page:all#Ask-and-Ye-Shall-Receive Pretty sure I have everything installed in OSX Mountain Lion. clang -Wall hwserver.c -o hwserver gives me an error: Undefined symbols for architecture x86_64: "_zmq_bind", referenced from: _main in hwserver-OgrEe6.o "_zmq_ctx_new", referenced from: _main in hwserver-OgrEe6.o "_zmq_msg_close", referenced from: _main in hwserver-OgrEe6.o "_zmq_msg_data", referenced

Compiling JZMQ on Ubuntu

空扰寡人 提交于 2019-11-30 10:39:50
问题 Hello all I'm attempting to follow the directions located at: https://github.com/nathanmarz/storm/wiki/Installing-native-dependencies for installing Zero MQ as a dependency for Storm on a Ubuntu 12.04 machine. However when trying to run the make command I get the following error Making all in src make[1]: Entering directory `/home/localadmin/jzmq/src' make[1]: *** No rule to make target `classdist_noinst.stamp', needed by `org/zeromq/ZMQ.class'. Stop. make[1]: Leaving directory `/home

Twitter Storm Ubuntu 单机安装

蹲街弑〆低调 提交于 2019-11-30 07:27:01
第 121 章 Twitter Storm 目录 121.1. 单机版 121.2. lein 安装 121.1. 单机版 操作系统环境:Ubuntu 13.04 KVM虚拟机 安装 storm 涉及到安装以下包:python、zookeeper、zeromq、jzmq、storm 过程 121.1. Ubuntu + Storm 单机环境安装 安装 zookeeper $ sudo apt-get install zookeeper zookeeper-bin zookeeperd 安装 zeromq 与 jzmq $ sudo apt-get install openjdk-7-jdk $ sudo apt-get install libzmq-dev 设置 JAVA_HOME 环境变量 $ export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64" 编译安装 jzmq $ cd /usr/local/src/ $ git clone git://github.com/nathanmarz/jzmq.git $ cd jzmq $ ./autogen.sh $ ./configure --prefix=/srv/jzmq-2.1.0 $ javac src/org/zeromq/*.java $ touch src

zmq send with NOBLOCK raise Resource temporarily unavailable

笑着哭i 提交于 2019-11-30 07:23:36
This code will raise Resource temporarily unavailable when call with NOBLOCK: context = zmq.Context() sender = context.socket(zmq.PUSH) sender.bind('tcp://*:15556') sender.send('KeEpAliv', zmq.NOBLOCK) # this line will throw exception #sender.send('KeEpAliv') # this line will ok After read the docs , I found no hints for this. but docs for recv explained this flag. Python wrappers raise zmq.error.Again if the underlying C API returns EAGAIN . Now, you should follow to zmq_send documentation, which states: ZMQ_NOBLOCK Specifies that the operation should be performed in non-blocking mode. If the

常用消息中间件

☆樱花仙子☆ 提交于 2019-11-30 06:07:13
Kafka、RabbitMQ、ZeroMQ、RocketMQ、ActiveMQ 17 个方面综合对比作为消息队列使用时的差异。 一 资料文档 Kafka:中。有kafka作者自己写的书,网上资料也有一些。rabbitmq:多。有一些不错的书,网上资料多。zeromq:少。没有专门写zeromq的书,网上的资料多是一些代码的实现和简单介绍。rocketmq:少。没有专门写rocketmq的书,网上的资料良莠不齐,官方文档很简洁,但是对技术细节没有过多的描述。activemq:多。没有专门写activemq的书,网上资料多。 二 开发语言 Kafka:Scala rabbitmq:Erlang zeromq:c rocketmq:java activemq:java 三 支持的协议 Kafka:自己定义的一套…(基于TCP) rabbitmq:AMQP zeromq:TCP、UDP rocketmq:自己定义的一套… activemq:OpenWire、STOMP、REST、XMPP、AMQP 四 消息存储 Kafka:内存、磁盘、数据库。支持大量堆积。 kafka的最小存储单元是分区,一个topic包含多个分区,kafka创建主题时,这些分区会被分配在多个服务器上,通常一个broker一台服务器。分区首领会均匀地分布在不同的服务器上,分区副本也会均匀的分布在不同的服务器上