Configuring Connection Details
SolacePubSub+ Connection Details
The Spring Cloud Stream Binder for PubSub+ uses Spring Boot Auto-Configuration for the Solace Java API to configure its session. In the application.yml
, this typically is configured as follows:
solace: java: host: tcp://localhost:55555 msg-vpn: default client-username: default client-password: default
For more information and options to configure the PubSub+ session, see Spring Boot Auto-Configuration for the Solace Java API.
Preventing Message Loss when Publishing to Topic-to-Queue Mappings
If the connector is publishing to a topic that is subscribed to by a queue, messages may be lost if they are rejected. For example, if the queue ingress is shutdown.
To prevent message loss, configure the reject-msg-to-sender-on-discard with the including-when-shutdown flag.
Amazon SQS Connection Details
We presume that you are familiar with the Spring Cloud AWS Credentials, however he steps that follow help you to connect to AWS services without in-depth knowledge. The connector can find these credentials automatically, or you can specify them manually.
Automatic Credential Discovery
By default, the Spring Cloud AWS starter automatically configures a DefaultCredentialsProvider
, which looks for AWS credentials in this order:
- Java System Properties—
aws.accessKeyId
andaws.secretAccessKey
-
Environment Variables—
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
-
Web Identity Tokens—The credentials from system properties or environment variables
-
Credential Profiles Files—The default location is at
~/.aws/credentials
, which is shared by all AWS SDKs and the AWS CLI. -
Amazon EC2 Container Services—The credentials delivered through the Amazon EC2 container service if the
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
environment variable is set and and security manager has permission to access the variable. -
Instance Profile Credentials—These credentials are delivered through the Amazon EC2 metadata service.
Manual Credential Discovery
Alternatively, you can instead provide the necessary credentials through the application. You can use the Spring Cloud AWS authentication libraries are configurable using several properties as described in the Configuring Spring Cloud AWS credentials. You can set the cloud.aws.credentials.xxx
as well as cloud.aws.region.xxx
can be set in application.yml
. The following is an example:
spring: cloud: aws: # SqsTemplate configuration credentials: access-key: <aws credentials/access key> #Specifies the access key secret-key: <aws credentials/secret key> #Specifies the secret key region: static: us-east-1 # A static value for region used by auto-configured AWS clients (e.g., `eu-west-1`) as AWS credentials are valid in a context of a regions auto: false
In addition to authentication credentials the AWS client libraries also require setting a property for the AWS cloud region using "spring.cloud.aws.region.xxx" properties. AWS credentials are valid in a context of a region.
For example, this is how you can configure the us-east-2
region:
spring: cloud: aws: # SqsTemplate configuration ... region: static: us-east-1
For more information about AWS regions, see AWS Regions.
Connecting to Multiple Systems
To connect to multiple systems of a same type, use the multiple binder syntax.
For example:
spring: cloud: stream: binders: # 1st solace binder in this example solace1: type: solace environment: solace: java: host: tcp://localhost:55555 # 2nd solace binder in this example solace2: type: solace environment: solace: java: host: tcp://other-host:55555 # The only sqs binder sqs1: type: sqs # Add `environment` property map here if you need to customize this binder. # But for this example, we'll assume that defaults are used. # The only sqs binder sqs2: type: sqs # Add `environment` property map here if you need to customize this binder. # But for this example, we'll assume that defaults are used. # Required for internal use undefined: type: undefined bindings: input-0: destination: <input-destination> binder: sqs1 output-0: destination: <output-destination> binder: solace1 # Reference 1st solace binder input-1: destination: <input-destination> binder: sqs2 output-1: destination: <output-destination> binder: solace2 # Reference 2nd solace binder
The configuration above defines two binders of type solace
and of type sqs
, which are then referenced within the bindings.
Each binder above is configured independently under spring.cloud.stream.binders.<bindername>.environment.
.
-
When connecting to multiple systems, all binder configuration must be specified using the multiple binder syntax for all binders. For example, under the
spring.cloud.stream.binders.<binder-name>.environment
. -
Do not use single-binder configuration (for example,
solace.java.*
at the root of yourapplication.yml
) while using the multiple binder syntax.