I am using beanstalk to put messages in the tube and i want to consume it from the new EC2 instance that i will launch at runtime. I am able to put message in the tube but i am not able to consume it by any means.
I performed the below steps to test:
file: producer.py
#!/usr/bin/env python
import greenstalk
import json
import sys
beanstalkTube = 'tube-name'
beanstalkHost = 'host'
beanstalkPort = 11301
client = greenstalk.Client((beanstalkHost, beanstalkPort))
client.use(beanstalkTube)
client.put('message 1')
file: consumer.py
#!/usr/bin/env python
import greenstalk
import json
import sys
beanstalkTube = 'tube-name'
beanstalkHost = 'host'
beanstalkPort = 11301
client = greenstalk.Client((beanstalkHost, beanstalkPort))
client.use(beanstalkTube)
job = client.reserve()
print("job_id:"+job.id)
print("job_body:"+job.body)
One more thing i want to know is how should i use the beanstalk to pass message to the newly created EC2 spot instance via shell script
You will
use
a tube to put in a message. Reading from the tube(s), youwatch
one (or more) tubes and the server will return a message when you callreserve
to get one