Package com.amazon.sqs.javamessaging
Class AmazonSQSMessagingClientWrapper
java.lang.Object
com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper
This is a JMS Wrapper of
SqsClient
. This class changes all
AwsServiceException
and SdkException
into
JMSException/JMSSecurityException.-
Constructor Summary
ConstructorsConstructorDescriptionAmazonSQSMessagingClientWrapper
(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient) AmazonSQSMessagingClientWrapper
(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoid
changeMessageVisibility
(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityRequest changeMessageVisibilityRequest) CallschangeMessageVisibility
and wrapsSdkException
.software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchResponse
changeMessageVisibilityBatch
(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest) CallschangeMessageVisibilityBatch
and wrapsSdkException
.software.amazon.awssdk.services.sqs.model.CreateQueueResponse
createQueue
(String queueName) CallscreateQueue
to create the queue with the default queue attributes, and wrapsSdkException
software.amazon.awssdk.services.sqs.model.CreateQueueResponse
createQueue
(software.amazon.awssdk.services.sqs.model.CreateQueueRequest createQueueRequest) CallscreateQueue
to create the queue with the provided queue attributes if any, and wrapsSdkException
void
deleteMessage
(software.amazon.awssdk.services.sqs.model.DeleteMessageRequest deleteMessageRequest) CallsdeleteMessage
and wrapsSdkException
.software.amazon.awssdk.services.sqs.model.DeleteMessageBatchResponse
deleteMessageBatch
(software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest deleteMessageBatchRequest) CallsdeleteMessageBatch
and wrapsSdkException
.software.amazon.awssdk.services.sqs.SqsClient
If one uses any other AWS SDK operations other than explicitly listed here, the exceptions thrown by those operations will not be wrapped asJMSException
.software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse
getQueueUrl
(String queueName) Gets the queueUrl of a queue given a queue name.software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse
getQueueUrl
(String queueName, String queueOwnerAccountId) Gets the queueUrl of a queue given a queue name owned by the provided accountId.software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse
getQueueUrl
(software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest getQueueUrlRequest) CallsgetQueueUrl
and wrapsSdkException
boolean
queueExists
(String queueName) Check if the requested queue exists.boolean
queueExists
(String queueName, String queueOwnerAccountId) Check if the requested queue exists.software.amazon.awssdk.services.sqs.model.ReceiveMessageResponse
receiveMessage
(software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest receiveMessageRequest) CallsreceiveMessage
and wrapsSdkException
.software.amazon.awssdk.services.sqs.model.SendMessageResponse
sendMessage
(software.amazon.awssdk.services.sqs.model.SendMessageRequest sendMessageRequest) CallssendMessage
and wrapsAmazonClientException
.
-
Constructor Details
-
AmazonSQSMessagingClientWrapper
public AmazonSQSMessagingClientWrapper(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient) throws jakarta.jms.JMSException - Parameters:
amazonSQSClient
- The AWS SDK Client for SQS.- Throws:
jakarta.jms.JMSException
- if the client is null
-
AmazonSQSMessagingClientWrapper
public AmazonSQSMessagingClientWrapper(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider) throws jakarta.jms.JMSException - Parameters:
amazonSQSClient
- The AWS SDK Client for SQS.- Throws:
jakarta.jms.JMSException
- if the client is null
-
-
Method Details
-
getAmazonSQSClient
public software.amazon.awssdk.services.sqs.SqsClient getAmazonSQSClient()If one uses any other AWS SDK operations other than explicitly listed here, the exceptions thrown by those operations will not be wrapped asJMSException
.- Returns:
- amazonSQSClient
-
deleteMessage
public void deleteMessage(software.amazon.awssdk.services.sqs.model.DeleteMessageRequest deleteMessageRequest) throws jakarta.jms.JMSException CallsdeleteMessage
and wrapsSdkException
. This is used to acknowledge single messages, so that they can be deleted from SQS queue.- Parameters:
deleteMessageRequest
- Container for the necessary parameters to execute the deleteMessage service method on SqsClient.- Throws:
jakarta.jms.JMSException
-
deleteMessageBatch
public software.amazon.awssdk.services.sqs.model.DeleteMessageBatchResponse deleteMessageBatch(software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest deleteMessageBatchRequest) throws jakarta.jms.JMSException CallsdeleteMessageBatch
and wrapsSdkException
. This is used to acknowledge multiple messages on client_acknowledge mode, so that they can be deleted from SQS queue.- Parameters:
deleteMessageBatchRequest
- Container for the necessary parameters to execute the deleteMessageBatch service method on SqsClient. This is the batch version of deleteMessage. Max batch size is 10.- Returns:
- The response from the deleteMessageBatch service method, as returned by SqsClient
- Throws:
jakarta.jms.JMSException
-
sendMessage
public software.amazon.awssdk.services.sqs.model.SendMessageResponse sendMessage(software.amazon.awssdk.services.sqs.model.SendMessageRequest sendMessageRequest) throws jakarta.jms.JMSException CallssendMessage
and wrapsAmazonClientException
.- Parameters:
sendMessageRequest
- Container for the necessary parameters to execute the sendMessage service method on SqsClient.- Returns:
- The response from the sendMessage service method, as returned by SqsClient
- Throws:
jakarta.jms.JMSException
-
queueExists
Check if the requested queue exists. This function callsGetQueueUrl
for the given queue name, returning true on success, false if it getsQueueDoesNotExistException
.- Parameters:
queueName
- the queue to check- Returns:
- true if the queue exists, false if it doesn't.
- Throws:
jakarta.jms.JMSException
-
queueExists
public boolean queueExists(String queueName, String queueOwnerAccountId) throws jakarta.jms.JMSException Check if the requested queue exists. This function callsGetQueueUrl
for the given queue name with the given owner accountId, returning true on success, false if it getsQueueDoesNotExistException
.- Parameters:
queueName
- the queue to checkqueueOwnerAccountId
- The AWS accountId of the account that created the queue- Returns:
- true if the queue exists, false if it doesn't.
- Throws:
jakarta.jms.JMSException
-
getQueueUrl
public software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl(String queueName) throws jakarta.jms.JMSException Gets the queueUrl of a queue given a queue name.- Parameters:
queueName
-- Returns:
- The response from the GetQueueUrl service method, as returned by SqsClient, which will include queue`s URL
- Throws:
jakarta.jms.JMSException
-
getQueueUrl
public software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl(String queueName, String queueOwnerAccountId) throws jakarta.jms.JMSException Gets the queueUrl of a queue given a queue name owned by the provided accountId.- Parameters:
queueName
-queueOwnerAccountId
- The AWS accountId of the account that created the queue- Returns:
- The response from the GetQueueUrl service method, as returned by SqsClient, which will include queue`s URL
- Throws:
jakarta.jms.JMSException
-
getQueueUrl
public software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl(software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest getQueueUrlRequest) throws jakarta.jms.JMSException CallsgetQueueUrl
and wrapsSdkException
- Parameters:
getQueueUrlRequest
- Container for the necessary parameters to execute the getQueueUrl service method on SqsClient.- Returns:
- The response from the GetQueueUrl service method, as returned by SqsClient, which will include queue`s URL
- Throws:
jakarta.jms.JMSException
-
createQueue
public software.amazon.awssdk.services.sqs.model.CreateQueueResponse createQueue(String queueName) throws jakarta.jms.JMSException CallscreateQueue
to create the queue with the default queue attributes, and wrapsSdkException
- Parameters:
queueName
-- Returns:
- The response from the createQueue service method, as returned by SqsClient. This call creates a new queue, or returns the URL of an existing one.
- Throws:
jakarta.jms.JMSException
-
createQueue
public software.amazon.awssdk.services.sqs.model.CreateQueueResponse createQueue(software.amazon.awssdk.services.sqs.model.CreateQueueRequest createQueueRequest) throws jakarta.jms.JMSException CallscreateQueue
to create the queue with the provided queue attributes if any, and wrapsSdkException
- Parameters:
createQueueRequest
- Container for the necessary parameters to execute the createQueue service method on SqsClient.- Returns:
- The response from the createQueue service method, as returned by SqsClient. This call creates a new queue, or returns the URL of an existing one.
- Throws:
jakarta.jms.JMSException
-
receiveMessage
public software.amazon.awssdk.services.sqs.model.ReceiveMessageResponse receiveMessage(software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest receiveMessageRequest) throws jakarta.jms.JMSException CallsreceiveMessage
and wrapsSdkException
. Used bySQSMessageConsumerPrefetch
to receive up to minimum of (numberOfMessagesToPrefetch
,10) messages from SQS queue into consumer prefetch buffers.- Parameters:
receiveMessageRequest
- Container for the necessary parameters to execute the receiveMessage service method on SqsClient.- Returns:
- The response from the ReceiveMessage service method, as returned by SqsClient.
- Throws:
jakarta.jms.JMSException
-
changeMessageVisibility
public void changeMessageVisibility(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws jakarta.jms.JMSException CallschangeMessageVisibility
and wrapsSdkException
. This is used to for negative acknowledge of a single message, so that messages can be received again without any delay.- Parameters:
changeMessageVisibilityRequest
- Container for the necessary parameters to execute the changeMessageVisibility service method on SqsClient.- Throws:
jakarta.jms.JMSException
-
changeMessageVisibilityBatch
public software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchResponse changeMessageVisibilityBatch(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest) throws jakarta.jms.JMSException CallschangeMessageVisibilityBatch
and wrapsSdkException
. This is used to for negative acknowledge of messages in batch, so that messages can be received again without any delay.- Parameters:
changeMessageVisibilityBatchRequest
- Container for the necessary parameters to execute the changeMessageVisibilityBatch service method on SqsClient.- Returns:
- The response from the changeMessageVisibilityBatch service method, as returned by SqsClient.
- Throws:
jakarta.jms.JMSException
-