Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the endpoint for boto3 SQS

Our application uses amazon's SQS for message queues and we use elasticMQ for testing/staging; elasticMQ is a message queue server that is fully compatible with SQS. Since the majority of our application is in java, we can run embedded elasticMQ in our tests or staging, switch over our queue endpoints to point to elasticMQ and voila, everything works very nicely and we don't touch our production queues.

That being said, we have some of our application written in python - which uses boto3 for SQS requests. Since elasticMQ can also be run as a standalone application I was wondering if it was possible to switch the endpoint from the default url (sqs.region.amazonaws.com:80) to something else (localhost:9324) in boto3. I've scoured the documentation and SO but haven't been able to identify if what I'd like to do is even possible.

like image 654
cscan Avatar asked Apr 16 '16 16:04

cscan


People also ask

How do I find my queue URL on Boto3?

To get the queue URL, use the `` GetQueueUrl `` action. `` GetQueueUrl `` requires only the QueueName parameter. be aware of existing queue names: If you provide the name of an existing queue along with the exact names and values of all the queue's attributes, CreateQueue returns the queue URL for the existing queue.

Can you set priorities in SQS?

Priority: Use separate queues to provide prioritization of work. Scalability: Because message queues decouple your processes, it's easy to scale up the send or receive rate of messages — simply add another process. Resiliency: When part of your system fails, it doesn't need to take the entire system down.

How do I change the message attribute in SQS?

To encode a single Amazon SQS message attributeEncode the transport type ( String or Binary ) of the value (1 byte). The logical data types String and Number use the String transport type. The logical data type Binary uses the Binary transport type. For the String transport type, encode 1.


1 Answers

You can pass in the endpoint_url to the client / resource constructor.

import boto3

sqs = boto3.resource('sqs')
emq = boto3.resource('sqs', endpoint_url="http://www.foo.com")

docs

like image 68
Jordon Phillips Avatar answered Sep 28 '22 00:09

Jordon Phillips