How to connect to pre-provisioned queue in solace using spring cloud stream ?

chatumoh
chatumoh Member Posts: 7
edited April 2023 in Connectors & Integrations #1

I am using @StreamListner, created input binding of type SubscribableChannel & trying to connect to a pre-provisioned queue and used similar configurations as suggested in previous comment but i am not able to bind consumer with queue .

Getting error - "EL1008E: Property or field 'isAnonymous' cannot be found on object of type 'com.solace.spring.cloud.stream.binder.provisioning.ExpressionContextRoot' - maybe not public or not valid?" .

Did try providing queue-name-expression as well as string literal as suggested in blog post https://solace.com/blog/custom-name-for-queues-spring-cloud-stream-binder/ nothing seems to work i keep in getting above error or SpelExpression error i.e. Caused by: org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'rparen())' .

Answers

  • giri
    giri Member, Administrator, Employee Posts: 116 admin

    Hi @chatumoh, Can you share the application configuration snippet around the solace binding configuration?

  • chatumoh
    chatumoh Member Posts: 7
    edited April 2023 #3

    @giri

    Below is the solace binder configuration which I am using in my sprint boot app.

    I gave it a try using queueNameExpression passed an SpEL expression and a hard coded literal but no luck. I am using spring-cloud-starter-stream-solace v3.4


    spring:
     cloud:
      stream:
       binders:
        solace-broker:  
         type: solace 
         environment: 
          solace:
           java: 
            host: tcps://host.company.com:55443
            msgVpn: <<vpnName>>
            clientUsername: <<username>>
            clientPassword: <<password>>
            connectRetries: 3 
            connectRetriesPerHost: 0 
            reconnectRetries: 3
            apiProperties:
             ssl_trust_store: '<<trust_store>>'
       bindings:
        inputChannel:
         destination: queueName
         group: mygroup
         binder: solace-broker
       solace: 
        bindings:
         inputChannel:
          consumer:
           provisionSubscriptionsToDurableQueue: false
           provisionDurableQueue: false
           queue-name-prefix: ''
           #queueNameExpression: "(properties.solace.queueNamePrefix.trim()) + (properties.solace.useGroupNameInQueueName ? group?.trim() + '-' : '')) + (properties.solace.useDestinationEncodingInQueueName ? 'plain' + '-' : '') + destination.trim().replaceAll('[*>]', '-')"
           #queueNameExpression: "'queueName'"
           useFamiliarityInQueueName: false
           useDestinationEncodingInQueueName: false
           useGroupNameInQueueName: false
           queue-additional-subscriptions: "'topic/group/>'"  
    
  • marc
    marc Member, Administrator, Moderator, Employee Posts: 959 admin

    Hi @chatumoh,

    Any reason you're using @StreamListener ? That way of defining a listener was deprecated quite a while ago now. I'm not sure, but that could be causing the issue with the queueNameExpression property not working.

    If you can, I would suggest moving to use Spring Cloud Function to define your message handlers. Here is an example that @giri made which shows a custom queue using them: https://github.com/SolaceSamples/solace-samples-spring/tree/master/cloud-stream-custom-queue-names.

    Note for lowercase-in-0 all he had to do we define the properties here: https://github.com/SolaceSamples/solace-samples-spring/blob/master/cloud-stream-custom-queue-names/src/main/resources/application.yaml#L47:L49

  • chatumoh
    chatumoh Member Posts: 7
    edited April 2023 #5

    @marc

    I was able to connect to pre-provisioned queue after downgrading solace binder dependency to v3.2 with @StreamListener in SCST version earlier than v3.1. My microservice app is already connecting to Kafka broker using @StreamListener annotation & earlier scst version, i am adding solace as additional messaging source to read from

    As below consumer properties to disable SCST default approach of connecting to queue were deprecated since v3.3 I changed queueNameExpression and kept just the destination name in SpEL expression as well as tried just providing queueName as literal queueNameExpression: '''queuename''' but still getting same error with SCST solace binder v3.4 and v3.3

    provisionSubscriptionsToDurableQueue, queueNamePrefix, useFamiliarityInQueueName, useDestinationEncodingInQueueName, useGroupNameInQueueName