-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Azure Service Bus message queueing
Send a smaller payload (name, asset_id and location) to Azure Service Bus queue.
- Loading branch information
Mahmud
committed
Jun 2, 2016
1 parent
6389965
commit 10ca13d
Showing
8 changed files
with
310 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from azure.servicebus import ServiceBusService, Message, Queue | ||
import ast | ||
|
||
|
||
class ServiceBusQueue(object): | ||
def __init__(self, | ||
namespace, | ||
access_key_name, | ||
access_key_value, | ||
q_name, | ||
q_max_size='5120', | ||
msg_ttl='PT1M'): | ||
self.bus_svc = ServiceBusService( | ||
service_namespace=namespace, | ||
shared_access_key_name=access_key_name, | ||
shared_access_key_value=access_key_value | ||
) | ||
self.queue_options = Queue() | ||
self.queue_options.max_size_in_megabytes = q_max_size | ||
self.queue_options.default_message_time_to_live = msg_ttl | ||
|
||
self.queue_name = q_name | ||
self.bus_svc.create_queue(self.queue_name, self.queue_options) | ||
|
||
def send(self, msg): | ||
message = bytes(msg) | ||
message = Message(message) | ||
self.bus_svc.send_queue_message(self.queue_name, message) | ||
|
||
def receive(self): | ||
msg = self.bus_svc.receive_queue_message(self.queue_name, peek_lock=False) | ||
data = ast.literal_eval(msg.body) | ||
return data |