celery add to broker without publishing -


i add message broker without broker publishing subscribers.

i want to, @ later date, tell broker publish message.

i want can set one-off predefined task can executed calling it.

an alternative have tried doesnt work do:

task = tasks.send_message.apply_async(['hello'], countdown=60) revoke(task.task_id, terminate=true)` 

but doesn't revoke task - task executes.

this can done rabbitmq dead-letter exchange extension. when publish task put on queue no consumers , declare consumer queue dead letter queue. when message ttl expires on original exchange dead letter consumer queue consumed.

to accomplish celery declare queue

from kombu import exchange, queue  dead_letter_options = {     'x-message-ttl': 60 * 10 * 1000, # 10 mins     'x-dead-letter-exchange': 'default',     'x-expires': (60 * 10 + 1) * 1000, }   celery_queues = (     queue('default', exchange('default'), routing_key='default'),     queue('wait',  exchange('wait', arguments=dead_letter_options ), routing_key='wait'), ) 

then call task , put on wait queue.

tasks.send_message.apply_async(['hello'], queue='wait') 

you can see example of general dead letter based countdown https://gist.github.com/dgouldin/3485236


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -