python - Implement zeromq publisher in django with celery (Broker redis) -


i need implement zmq publisher in django , celery redis broker. client doesn't receive anything.

tasks.py

  celery import task   import zmq     try:       context = zmq.context()       publisher = context.socket(zmq.pub)       publisher.bind('tcp://192.168.0.14:9997')   except:       pass    def app_delivery():       publisher.send("testid : task ")       return "passed"   @task.task(ignore_result=true)   def add():       print "i going push message "       return app_delivery() 

views.py

from django.http import httpresponse notification_core.tasks import add  def resp(request):     param = request.get.get('param')     param = int(param)     i=0     while i<param:         add.delay()         i+=1     return httpresponse("done") 

then running workers using command--

python manage_back.py celery worker --loglevel=info 

workers console output

[2013-04-20 10:37:06,400: warning/poolworker-2] going push message [2013-04-20 10:37:06,400: info/mainprocess] task notification_core.tasks.add[6d44bb48-799e-43dc-af3e-278c0db732c4] succeeded in 0.000511169433594s: 'passed' [2013-04-20 10:37:06,575: info/mainprocess] got task broker: notification_core.tasks.add[8a787b31-5375-4c05-9ddc-2fc66b54ee19] [2013-04-20 10:37:06,575: warning/poolworker-3] going push message [2013-04-20 10:37:06,576: info/mainprocess] task notification_core.tasks.add[8a787b31-5375-4c05-9ddc-2fc66b54ee19] succeeded in 0.000941038131714s: 'passed' [2013-04-20 10:37:06,751: info/mainprocess] got task broker: notification_core.tasks.add[d73ebcdf-9765-43f6-823a-ad03881afa50] [2013-04-20 10:37:06,752: warning/poolworker-4] going push message [2013-04-20 10:37:06,752: info/mainprocess] task notification_core.tasks.add[d73ebcdf-9765-43f6-823a-ad03881afa50] succeeded in 0.000416040420532s: 'passed' 

zmq_client file

import zmq context = zmq.context()  subscriber = context.socket(zmq.sub) subscriber.connect('tcp://192.168.0.14:9997') subscriber.setsockopt(zmq.subscribe, "testid") while true:     message = subscriber.recv()     print "=========="     print message     print "=========="   

i not getting output in client, need suggestions.

did start client first? want start subs before pubs. may find using envelops helpful although seems overkill here.

http://zguide.zeromq.org/page%3aall#pub-sub-message-envelopes

hope gives of if aren't eating relevant exception mentioned.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -