# -*- coding: utf-8 -*- """ !!! NOT READY FOR PRODUCTION !!! """ from taskmq import Producer # Declare the producer. producer = Producer(host='some.host.tld', user='******', password='', vhost='/') # Configure the producer. producer.config.serializer = 'json' producer.config.reply_exchange = None producer.config.reply_key = 'queue_1_replies' producer.config.reply_state = None producer.config.exchange = None producer.config.routing_key = 'queue_1' if __name__ == '__main__': # Call task using the default configuration. print producer.call('a_basic_task').__dict__ # Call a task with customs parameters, # - publish on the second queue # - and ask reply on the second print producer.call(task='a_basic_task', routing_key='queue_2', reply_key='queue_2_replies').__dict__
# -*- coding: utf-8 -*- import random from taskmq import Producer from . import config producer = Producer( host=config.BROKER_HOST, port=config.BROKER_PORT, user=config.BROKER_USER, password=config.BROKER_PASSWORD, vhost=config.BROKER_VHOST, reply_to='test_replies' ) while True: print 'send operation' producer.call( queue='tests', task='a_plus_b', args=[random.randint(0, 9), random.randint(0, 9)] )
# -*- coding: utf-8 -*- """ !!! NOT READY FOR PRODUCTION !!! """ from taskmq import Producer # Declare the producer. producer = Producer(host='some.host.tld', user='******', password='', vhost='/') # Configure the producer. producer.config.serializer = 'json' producer.config.reply_exchange = None producer.config.reply_key = 'queue_1_replies' producer.config.reply_state = None producer.config.exchange = None producer.config.routing_key = 'queue_1' if __name__ == '__main__': # Call task using the default configuration. print producer.call('a_basic_task').__dict__ # Call a task with customs parameters, # - publish on the second queue # - and ask reply on the second print producer.call( task='a_basic_task', routing_key='queue_2', reply_key='queue_2_replies' ).__dict__