Download this file

amqp.py    31 lines (21 with data), 852 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import logging
from carrot.messaging import Publisher
from carrot.connection import BrokerConnection
from lamson.routing import route, route_like, stateless
from config.settings import relay
from lamson import view, queue
@route("forge-list@(host)")
#@route("(post_name)@osb\\.(host)")
@stateless
def POSTING(message, post_name=None, host=None):
relay.deliver(message)
conn = BrokerConnection(hostname="localhost", port=5672,
userid="celeryuser", password="celerypw",
virtual_host="celeryvhost")
publisher = Publisher(connection=conn,
exchange="forge", routing_key="mail")
publisher.send({"message": message}, serializer="pickle")
publisher.close()
#index_q = queue.Queue("run/posts")
#index_q.push(message)
return POSTING