Skip to content

Commit cab93e2

Browse files
authored
docs(client-sqs): regarding multi-region SQS usage (#5838)
1 parent d998422 commit cab93e2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

UPGRADING.md

+28
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,34 @@ const region = "...";
645645
When using a custom `QueueUrl` in SQS operations that have this as an input parameter, in JSv2
646646
it was possible to supply a custom `QueueUrl` which would override the SQS Client's default endpoint.
647647

648+
#### Mutli-region messages
649+
650+
You should use one client per region in v3. The AWS Region is meant to be initialized at the client level and not changed between requests.
651+
652+
```ts
653+
import { SQS } from "@aws-sdk/client-sqs";
654+
655+
const sqsClients = {
656+
"us-east-1": new SQS({ region: "us-east-1" }),
657+
"us-west-2": new SQS({ region: "us-west-2" }),
658+
};
659+
660+
const queues = [
661+
{ region: "us-east-1", url: "https://sqs.us-east-1.amazonaws.com/{AWS_ACCOUNT}/MyQueue" },
662+
{ region: "us-west-2", url: "https://sqs.us-west-2.amazonaws.com/{AWS_ACCOUNT}/MyOtherQueue" },
663+
];
664+
665+
for (const { region, url } of queues) {
666+
const params = {
667+
MessageBody: "Hello",
668+
QueueUrl: url,
669+
};
670+
await sqsClients[region].sendMessage(params);
671+
}
672+
```
673+
674+
#### Custom endpoint
675+
648676
In JSv3, when using a custom endpoint, i.e. one that differs from the default public SQS endpoints, you
649677
should always set the endpoint on the SQS Client as well as the `QueueUrl` field.
650678

0 commit comments

Comments
 (0)