Solace Community is getting a facelift!

On March 3rd we will be starting the process of migrating Solace Community to a new platform. As a result, Solace Community will go in to a temporary read-only state. You will still be able to come onto Solace Community and search through posts to find answers, but you won't be able to ask questions, post comments, or react in any way.

We hope to have the migration complete by Wednesday March 5th (or sooner), so please keep an eye out!

Custom Queue Names when using Spring Cloud Stream binder for Solace PubSub+

giri
giri Member, Administrator, Employee Posts: 116 admin
edited September 2022 in General Discussions #1

The Spring Expression Language (SpEL for short) is a powerful expression language that supports querying and manipulating an object graph at runtime. In Solace Binder, we can use the SpEL to specify queue name expressions to generate custom queue names.

Not all properties present in the application configuration are available for use while constructing a SpEL expression. Here is a list of supported context variables available for use in the expression.

The properties.solace and properties.spring throws open all the properties defined spring.cloud.stream.bindings.<binder_name>.consumer and spring.cloud.stream.solace.bindings.<binder_name>.consumer for use in the SpEL expression.

Consider an example configuration.

spring:
  cloud:
    function:
      definition: uppercase
    stream:
      bindings:
        uppercase-in-0:
          destination: manualackqueue
          binder: solace-broker
          group: myconsumergroup
          consumer:
            concurrency: 1
            max-attempts: 3
        uppercase-out-0:
          destination: uppercase/topic
          binder: solace-broker
      binders:
        solace-broker:
          type: solace
          environment:
            solace:
              java:
                host: 'tcp://xxxx:55554'
                msgVpn: default
                clientUsername: default
                clientPassword: default
                connectRetries: -1
                reconnectRetries: -1
      solace:
        bindings:
          uppercase-in-0:
            consumer:
              provisionDurableQueue: true
              queueNamePrefix: QNAME
              errorMsgTtl: 10000
              queueNameExpression: "'QUEUE-' + \
                properties.solace.queueNamePrefix.toString() + '-' + \
                properties.spring.concurrency.toString() + '-' + \
                properties.spring.maxAttempts.toString() + '-' + \
                properties.solace.errorMsgTtl.toString() + '-' + \
                (properties.solace.provisionDurableQueue ? 'AUTO' : 'MANUAL')" 

This will produce the following custom queue name:

QUEUE-QNAME-1-3-10000-AUTO

Note: Custom properties are not supported in the SpEL expression.

For more information on custom names for queues and error queues, refer to this blog Custom Name for your Queues when using Spring Cloud Stream Binder for Solace PubSub+

This Month's Leaders

This Week's Leaders