Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24dd2de
commit 3833090
Showing
11 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
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,27 @@ | ||
import logging | ||
|
||
from amqpstorm import Connection | ||
from amqpstorm import Message | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def publish_message(channel, body, queue): | ||
# Create a message. | ||
message = Message.create(channel, body) | ||
|
||
# Publish the message to a queue. | ||
message.publish(queue) | ||
|
||
|
||
if __name__ == '__main__': | ||
with Connection('127.0.0.1', 'guest', 'guest') as CONNECTION: | ||
with CONNECTION.channel() as CHANNEL: | ||
# Declare the Queue, 'simple_queue' with a message ttl of 6000ms. | ||
CHANNEL.queue.declare('simple_ttl_queue', arguments={ | ||
'x-message-ttl': 6000, | ||
}) | ||
|
||
# Publish the message to a queue called, 'simple_queue' with an | ||
# expiration set to 6000ms. | ||
publish_message(CHANNEL, 'Hello World', 'simple_ttl_queue') |
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,26 @@ | ||
import logging | ||
|
||
from amqpstorm import Connection | ||
from amqpstorm import Message | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def publish_message(channel, body, queue, expiration="600"): | ||
# Create the message with a expiration (time to live). | ||
message = Message.create(channel, body, | ||
properties={"expiration": expiration}) | ||
|
||
# Publish the message to a queue. | ||
message.publish(queue) | ||
|
||
|
||
if __name__ == '__main__': | ||
with Connection('127.0.0.1', 'guest', 'guest') as CONNECTION: | ||
with CONNECTION.channel() as CHANNEL: | ||
# Declare the Queue, 'simple_queue'. | ||
CHANNEL.queue.declare('simple_queue') | ||
|
||
# Publish the message to a queue called, 'simple_queue' with an | ||
# expiration set to 6000ms. | ||
publish_message(CHANNEL, 'Hello World', 'simple_queue', "6000") |
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
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
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