Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttl example #69

Open
berlinguyinca opened this issue Mar 3, 2019 · 5 comments
Open

ttl example #69

berlinguyinca opened this issue Mar 3, 2019 · 5 comments

Comments

@berlinguyinca
Copy link

thank you for your great work. Would you be able to provide an example how to send a message to a queue with a defined TTL?

I would like to set the ttl on the message it self, since different messages could have different TTL's

kind regards

@eandersson
Copy link
Owner

I'll provide you with an example in a day or two.

@berlinguyinca
Copy link
Author

berlinguyinca commented Mar 5, 2019 via email

@eandersson
Copy link
Owner

This example would set a queue ttl of 5000ms, but the message ttl lower at 600ms.

def publish_message(channel):
    # Declare the Queue, 'simple_queue' with a message ttl of 5000ms.
    channel.queue.declare('simple_queue', arguments={
        'x-message-ttl': 5000,
    })

    # Create the message with a ttl of 600ms.
    message = Message.create(channel, 'Hello World!', 
                             properties={"expiration": "600"})

    # Publish the message to a queue called, 'simple_queue'.
    message.publish('simple_queue')

@berlinguyinca
Copy link
Author

berlinguyinca commented Mar 8, 2019 via email

@berlinguyinca
Copy link
Author

berlinguyinca commented Mar 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants