amqpstorm icon indicating copy to clipboard operation
amqpstorm copied to clipboard

ttl example

Open berlinguyinca opened this issue 6 years ago • 5 comments

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

berlinguyinca avatar Mar 03 '19 00:03 berlinguyinca

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

eandersson avatar Mar 05 '19 05:03 eandersson

thanks this would be awesome!

On Mon, Mar 4, 2019 at 9:25 PM Erik Olof Gunnar Andersson < [email protected]> wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eandersson/amqpstorm/issues/69#issuecomment-469542943, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA_7MAUMJtACIRV73JeWonetFF-DS-2ks5vTf-zgaJpZM4bas98 .

--

Lead Developer - Fiehnlab, UC Davis

gert wohlgemuth

work: http://fiehnlab.ucdavis.edu/staff/wohlgemuth

phone: 530 665 9477

coding blog: http://codingandmore.blogspot.com

linkedin: http://www.linkedin.com/profile/view?id=28611299&trk=tab_pro

berlinguyinca avatar Mar 05 '19 06:03 berlinguyinca

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')

eandersson avatar Mar 08 '19 03:03 eandersson

sadly still doesn't work. The second I specify any form of properties, it stops sending messages. If i keep the properties out/None it works fine.

On Thu, Mar 7, 2019 at 7:01 PM Erik Olof Gunnar Andersson < [email protected]> wrote:

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')

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eandersson/amqpstorm/issues/69#issuecomment-470786980, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA_7POcDEyIv5Ebu_KOYP9kNFz6CVqvks5vUdKAgaJpZM4bas98 .

--

Lead Developer - Fiehnlab, UC Davis

gert wohlgemuth

work: http://fiehnlab.ucdavis.edu/staff/wohlgemuth

phone: 530 665 9477

coding blog: http://codingandmore.blogspot.com

linkedin: http://www.linkedin.com/profile/view?id=28611299&trk=tab_pro

berlinguyinca avatar Mar 08 '19 04:03 berlinguyinca

ok belay this, was a coding error on my side, for some reason my TTL got set to 0, due to a logic error. TTL works fine now.

thanks for your help!

On Thu, Mar 7, 2019 at 8:50 PM Gert Wohlgemuth [email protected] wrote:

sadly still doesn't work. The second I specify any form of properties, it stops sending messages. If i keep the properties out/None it works fine.

On Thu, Mar 7, 2019 at 7:01 PM Erik Olof Gunnar Andersson < [email protected]> wrote:

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')

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eandersson/amqpstorm/issues/69#issuecomment-470786980, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA_7POcDEyIv5Ebu_KOYP9kNFz6CVqvks5vUdKAgaJpZM4bas98 .

--

Lead Developer - Fiehnlab, UC Davis

gert wohlgemuth

work: http://fiehnlab.ucdavis.edu/staff/wohlgemuth

phone: 530 665 9477

coding blog: http://codingandmore.blogspot.com

linkedin: http://www.linkedin.com/profile/view?id=28611299&trk=tab_pro

--

Lead Developer - Fiehnlab, UC Davis

gert wohlgemuth

work: http://fiehnlab.ucdavis.edu/staff/wohlgemuth

phone: 530 665 9477

coding blog: http://codingandmore.blogspot.com

linkedin: http://www.linkedin.com/profile/view?id=28611299&trk=tab_pro

berlinguyinca avatar Mar 08 '19 04:03 berlinguyinca