Class SQSConnectionFactory

java.lang.Object
com.amazon.sqs.javamessaging.SQSConnectionFactory
All Implemented Interfaces:
jakarta.jms.ConnectionFactory, jakarta.jms.QueueConnectionFactory

public class SQSConnectionFactory extends Object implements jakarta.jms.ConnectionFactory, jakarta.jms.QueueConnectionFactory
A ConnectionFactory object encapsulates a set of connection configuration parameters for SqsClient as well as setting numberOfMessagesToPrefetch.

The numberOfMessagesToPrefetch parameter is used to size of the prefetched messages, which can be tuned based on the application workload. It helps in returning messages from internal buffers(if there is any) instead of waiting for the SQS receiveMessage call to return.

If more physical connections than the default maximum value (that is 50 as of today) are needed on the connection pool, ClientOverrideConfiguration needs to be configured.

None of the createConnection methods set-up the physical connection to SQS, so validity of credentials are not checked with those methods.

  • Constructor Details

    • SQSConnectionFactory

      public SQSConnectionFactory(ProviderConfiguration providerConfiguration)
      Creates a SQSConnectionFactory that uses SqsClientBuilder.standard() for creating SqsClient connections. Every SQSConnection will have its own copy of SqsClient.
    • SQSConnectionFactory

      public SQSConnectionFactory(ProviderConfiguration providerConfiguration, software.amazon.awssdk.services.sqs.SqsClient client)
      Creates a SQSConnectionFactory that uses the provided SqsClient connection. Every SQSConnection will use the same provided SqsClient.
    • SQSConnectionFactory

      public SQSConnectionFactory(ProviderConfiguration providerConfiguration, software.amazon.awssdk.services.sqs.SqsClientBuilder clientBuilder)
      Creates a SQSConnectionFactory that uses the provided SqsClientBuilder for creating AmazonSQS client connections. Every SQSConnection will have its own copy of AmazonSQS client created through the provided builder.
  • Method Details

    • createConnection

      public SQSConnection createConnection() throws jakarta.jms.JMSException
      Specified by:
      createConnection in interface jakarta.jms.ConnectionFactory
      Throws:
      jakarta.jms.JMSException
    • createConnection

      public SQSConnection createConnection(String awsAccessKeyId, String awsSecretKey) throws jakarta.jms.JMSException
      Specified by:
      createConnection in interface jakarta.jms.ConnectionFactory
      Throws:
      jakarta.jms.JMSException
    • createContext

      public jakarta.jms.JMSContext createContext()
      Specified by:
      createContext in interface jakarta.jms.ConnectionFactory
    • createContext

      public jakarta.jms.JMSContext createContext(String userName, String password)
      Specified by:
      createContext in interface jakarta.jms.ConnectionFactory
    • createContext

      public jakarta.jms.JMSContext createContext(String userName, String password, int sessionMode)
      Specified by:
      createContext in interface jakarta.jms.ConnectionFactory
    • createContext

      public jakarta.jms.JMSContext createContext(int sessionMode)
      Specified by:
      createContext in interface jakarta.jms.ConnectionFactory
    • createConnection

      public SQSConnection createConnection(software.amazon.awssdk.auth.credentials.AwsCredentials awsCredentials) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • createConnection

      public SQSConnection createConnection(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider awsCredentialsProvider) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • createQueueConnection

      public jakarta.jms.QueueConnection createQueueConnection() throws jakarta.jms.JMSException
      Specified by:
      createQueueConnection in interface jakarta.jms.QueueConnectionFactory
      Throws:
      jakarta.jms.JMSException
    • createQueueConnection

      public jakarta.jms.QueueConnection createQueueConnection(String userName, String password) throws jakarta.jms.JMSException
      Specified by:
      createQueueConnection in interface jakarta.jms.QueueConnectionFactory
      Throws:
      jakarta.jms.JMSException