Sending AWS SQS Messages
The AWS SQS connector allows you to send messages to an AWS SQS queue.
Sending messages
Before you start, you need to have an AWS account and an SQS queue created. To send messages to an SQS queue, you need to create a method that produces messages to the queue.
Then, your application can send Message<String>
to the prices channel.
It can use String
payloads as in the following snippet:
Or, you can send Message<Double>
, which affords the opportunity to
explicitly specify metadata on the outgoing message:
Serialization
When sending a Message<T>
, the connector converts the message into a AWS SQS Message.
How the message is converted depends on the payload type:
- If the payload is of type
SendMessageRequest
it is sent as is. - If the payload is of type
SendMessageRequest.Builder
, the queue url is set and sent. - If the payload is of type
software.amazon.awssdk.services.sqs.model.Message
it is usd to set the message body and attributes. - If the payload is of primitive types the paylaod is converted to String and the message attribute
_classname
is set to the class name of the payload. - If the payload is of any other object type, the payload is serialized (using the
JsonMapping
implementation discovered) and the message attribute_classname
is set to the class name of the payload.
If the message payload cannot be serialized to JSON, the message is nacked.
Outbound Metadata
When sending Messages
, you can add an instance of SqsOutboundMetadata
to influence how the message is handled by AWS SQS. For example, you
can configure the routing key, timestamp and headers:
Acknowledgement
By default, the Reactive Messaging Message
is acknowledged when the
send message request is successful. If the message is not sent successfully, the message is nacked.
Configuration Reference
Attribute (alias) | Description | Type | Mandatory | Default |
---|---|---|---|---|
credentials-provider | The credential provider to be used in the client | string | false | |
endpoint-override | The endpoint override | string | false | |
group.id | When set, sends messages with the specified group id | string | false | |
health-enabled | Whether health reporting is enabled (default) or disabled | boolean | false | true |
queue | The name of the SQS queue, defaults to channel name if not provided | string | false | |
queue.url | The url of the SQS queue | string | false | |
region | The name of the SQS region | string | false |