Looking for ttl setup on each message in spring cloud stream

manzarul
manzarul Member Posts: 20 ✭✭✭

i am able to set ttl on queue persistence message , using solace cloud broker GUI, but this settings is applied on each message with uniform value, is there any way keep this value in application.yaml or properties file and during message published time it will be applied for each messages.
In solace doc it's says you can pass ttl for each message at run time , but can't find an example with spring cloud stream or spring boot application.

Tagged:

Best Answer

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 959 admin
    #2 Answer ✓

    Hi @manzarul,

    You're correct that it can currently only be set on the header of each message. Unfortunately time to live isn't a setting exposed via JCSMPProperties that our Spring Boot apps can easily set. If you feel strongly that this should be allowed please feel free to open an enhancement via github requesting it :)

    Note there is a whole list of properties that can be set under solace.java.apiProperties here.

Answers

  • manzarul
    manzarul Member Posts: 20 ✭✭✭

    We can use like below fn :

    -- application.yaml 
    
    spring:  
      cloud: 
        function: 
          definition: mySupplier
        stream:
          poller:
            fixed-delay: 5000
          bindings:
            mySupplier-in-0:
              destination: test-q
              group: nonexclusive
            mySupplier-out-0:
              destination: test/topic/abc
    
    -- code
    
    @Bean
        Supplier<Message<String>> mySupplier(){
            return () -> {
                return MessageBuilder.withPayload("Welcome to solace world!").setHeader("solace_timeToLive", 13000L).build();
            };
        }
    
    
  • marc
    marc Member, Administrator, Moderator, Employee Posts: 959 admin
    #4 Answer ✓

    Hi @manzarul,

    You're correct that it can currently only be set on the header of each message. Unfortunately time to live isn't a setting exposed via JCSMPProperties that our Spring Boot apps can easily set. If you feel strongly that this should be allowed please feel free to open an enhancement via github requesting it :)

    Note there is a whole list of properties that can be set under solace.java.apiProperties here.

  • manzarul
    manzarul Member Posts: 20 ✭✭✭

    Thanks , we can mark this thread as complete.