Created
November 15, 2011 11:56
-
-
Save kkung/1366905 to your computer and use it in GitHub Desktop.
Amazon SQS in Kombu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kombu/transport/__init__.py b/kombu/transport/__init__.py | |
index 0acdce3..66c17d7 100644 | |
--- a/kombu/transport/__init__.py | |
+++ b/kombu/transport/__init__.py | |
@@ -46,6 +46,8 @@ def _sqlalchemy_transport(): | |
_requires("SQLAlchemy transport", "sqlakombu", "kombu-sqlalchemy") | |
return "sqlakombu.transport.Transport" | |
+def _sqs_transport(): | |
+ return "kombu.transport.SQS.Transport" | |
def _ghettoq(name, new, alias=None): | |
xxx = new | |
@@ -75,7 +77,7 @@ TRANSPORT_ALIASES = { | |
"syncpika": "kombu.transport.pypika.SyncTransport", | |
"memory": "kombu.transport.memory.Transport", | |
"redis": "kombu.transport.pyredis.Transport", | |
- "SQS": "kombu.transport.SQS.Transport", | |
+ "sqs": _sqs_transport, | |
"beanstalk": "kombu.transport.beanstalk.Transport", | |
"mongodb": "kombu.transport.mongodb.Transport", | |
"couchdb": "kombu.transport.pycouchdb.Transport", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kombu import BrokerConnection | |
from random import random | |
AWS_ACCESS_KEY = "" | |
AWS_SECRET_KEY = "" | |
sqs_uri = "sqs://%s:%s@sqs:80//" % ( AWS_ACCESS_KEY, AWS_SECRET_KEY) | |
rand_val = random() | |
with BrokerConnection(sqs_uri, transport_options = { 'region': 'ap-northeast-1' }) as conn: | |
with conn.SimpleQueue(u"kombu") as q: | |
q.put({"hello": "world", "random": rand_val}, serializer="json") | |
print "Message queued(rand: %f)" % rand_val | |
with BrokerConnection(sqs_uri, transport_options = { 'region': 'ap-northeast-1' }) as conn: | |
with conn.SimpleQueue(u"kombu") as q: | |
msg = q.get(block=True, timeout=3) | |
msg.ack() | |
print msg.payload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment