Reputation: 47
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
Upvotes: 1
Views: 465
Reputation: 35169
You will use
a tube to put in a message.
Reading from the tube(s), you watch
one (or more) tubes and the server will return a message when you call reserve
to get one
Jobs will only be reserved from tubes on the watch list, which initially contains a single tube, default. You can add tubes to the watch list with
watch
and remove them withignore
. For convenience, it can be set with thewatch
argument when creating a Client. https://greenstalk.readthedocs.io/en/stable/quickstart.html#consuming-jobs
Upvotes: 1