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 SNS 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 connector auto-configures a DefaultCredentialsProvider which looks for AWS credentials in the following 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: 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 region. auto: false
For more information regarding AWS Region, see AWS Regions.
Manual Configuration
The Connector for Amazon SNS does not support manual connection configuration as the Amazon SNS provider is not known in advance.To establish a connection with the Amazon SNS, it is essential to acquire a connection factory via a JNDI lookup. See Configuring Connection Details for information on using JNDI.
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 sns binder sns1: type: sns # 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: sns1 output-0: destination: <output-destination> binder: solace1 # Reference 1st solace binder input-1: destination: <input-destination> binder: sns1 output-1: destination: <output-destination> binder: solace2 # Reference 2nd solace binder
The configuration above defines two binders of type solace
and one binder of type sns
, which are then referenced within the bindings.
If you provide the SNS topic name:
- If the SNS does not exist, the connector attempts to create the SNS and then returns its ARN.
-
If the SNS already exists, the connector returns the ARN for the existing SNS
You should be aware that if you only provide the SNS topic name, the account configured for the connector must have the necessary SNS create permissions, otherwise the creation process fails due to insufficient access.
For example, you can specify an ARN value as shown:
arn:aws:sns:us-east-2:123456789012:MyTopic
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.