I am planning to deploy my nodejs application as a webserver + worker combination in EB. The webserver will insert a json ( in request body ) into a SQS queue. Worker then reads the queue and do some works.
The problem is I need headers also in my worker. Is there any way to set headers to the request so that i can use it in worker ?
Yes, you can set json body and also message attributes. I have verified this. Here is a log of the headers I received from the SQS daemon on EB (my custom fields are "abc" and "def"):
2017-09-10 16:19:53,689; INFO ; headers received:
X-Aws-Sqsd-Attr-Abc: 205
X-Aws-Sqsd-Attr-Def: 2017-09-10T16:19:53.537679+00:00
X-Aws-Sqsd-Msgid: bfd25652-9923-4c4c-86f2-9fea9fa2fas
X-Aws-Sqsd-Receive-Count: 1
X-Aws-Sqsd-Path:
X-Aws-Sqsd-Queue: myqueue
Content-Length: 16
User-Agent: aws-sqsd/2.3
X-Aws-Sqsd-First-Received-At: 2017-09-10T16:19:53Z
X-Aws-Sqsd-Sender-Id: AIDAJP6NVOXNJ7HY7QYOM
X-Aws-Sqsd-Sent-At: 2017-09-10T16:19:53Z
Host: localhost
Content-Type: application/json
See the docs: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html#worker-daemon
I had trouble getting message attributes to come through, and it turned out (verified by an AWS support technician) that there is either an error in AWS implementation or in their documentation, because the problem was that I was using an underscore in my message attributes key names, which is supposedly supported but in practice makes HTTP headers fail to include message attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With