Configuring 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.

Google Cloud Pub/Sub Connection Details

This documentation presumes that you are familiar with the Google Cloud Application Default Credentials (ADC). The Application Default Credentials (ADC) is a strategy used by the Google authentication libraries to automatically find credentials based on the application environment (local, Google Cloud, on-perm etc). Listing all possible authentication options is beyond the scope of this documentation.

The Google authentication libraries searches the application’s environment in Application Default Credentials (ADC) Search Order.

In addition to authentication credentials the Google Cloud Pub/Sub client libraries also requires spring.cloud.gcp.pubsub.project-id for establishing connection. The spring.cloud.gcp.pubsub.project-id value can be set in the application.yml file:

spring: 
  cloud:
    gcp:
      pubsub:
        project-id: gcp-pubsub-project-id   

For more information about other configurable properties and their defaults, see Spring Google Cloud Pub/Sub Configration.

The Pub/Sub API uses the GRPC protocol to send API requests to the Pub/Sub service. See GRPC Connection Settings for configuration options for customizing the GRPC behavior.

The rest of page describes the various ways to provide the authentication credentials.

Using Google Cloud CLI-Generated User Credentials

If the user credentials provided by using the Google Cloud CLI are already set up on the user’s system and application_default_credentials.json is in the default location, you can use samples/config/application.yml:

java -jar pubsubplus-connector-gcppubsub-<version>.jar --spring.config.additionallocation=file:samples/config/      

If the application_default_credentials.json is not in the default path, or if the user wants to explicitly configure a path, it can be configured in samples/config/application.yml or passed through CLI. The following are examples:

Using the spring.cloud.gcp.credentials.location in samples/config/application.yml:

spring:
  cloud:
    gcp:
      credentials:
        location: file:/path/to/gcloud/application_default_credentials.json

Using the spring.cloud.gcp.credentials.location property with the CLI: 

java -jar pubsubplus-connector-gcppubsub-<version>.jar --spring.config.additionallocation=
file:samples/config/ --spring.cloud.gcp.credentials.location
=file:/path/to/gcloud/application_default_credentials.json

Using the GOOGLE_APPLICATION_CREDENTIALS environment variable:

GOOGLE_APPLICATION_CREDENTIALS=/path/to/gcloud/application_default_credentials.json &&
java -jar pubsubplus-connector-gcppubsub-<version>.jar --spring.config.additionallocation=file:samples/config/

Using Service Account Key

Alternatively, user can also use the service account key with GOOGLE_APPLICATION_CREDENTIALS environment variable. For example:

GOOGLE_APPLICATION_CREDENTIALS=/path/to/gcloud/application_default_credentials.json &&
java -jar pubsubplus-connector-gcppubsub-<version>.jar --spring.config.additionallocation=
file:samples/config/

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 jms binder 
	 pubsub1:
          type: pubsub
          # The GCP Pub/Sub binder doesn't support multi-binder system. 
	   # The GCP Pub/Sub binder must be configured as it is configured in singlebinder configuration.
          
	 # Required for internal use 
	 undefined:
          type: undefined 
	 bindings:
          input-0:
            destination: <input-destination> 
	     binder: pubsub1
          output-0:
            destination: <output-destination>
            binder: solace1 # Reference 1st solace binder 
	   input-1:
            destination: <input-destination> 
	     binder: pubsub1
          output-1:
            destination: <output-destination>
            binder: solace2 # Reference 2nd solace binder

The configuration above defines two binders of the solace type and one binder of the pubsub type, which are then referenced within the bindings.

Note that each binder is configured independently under spring.cloud.stream.binders.<bindername>.environment..

When connecting to multiple systems, all solace binder configuration must be specified using the multiple binder syntax for all binders under the spring.cloud.stream.binders.<binder-name>.environment.

Do not use single-binder configuration (for example, solace.java.* at the root of your application.yml) while using the multiple binder syntax.

The Google Cloud Pub/Sub binder doesn't support multi-binder systems. The pubsub binder must be configured the same as in a single-binder configuration.