Solace spring cloud stream - pubsub

Options
akg17
akg17 Member Posts: 76


I was going through this post and got to know how can i work with topic,

i can have many queues subscribing to one topic and each get message right ?

i can have one queue subscribing to many topic as well right ?

Topic subscription on Queues makes it persist,

but.. if the application is scaling up and down with many instances, i was expecting that my each service along with all their instances consume same message and it is published for all of them, for example their are some configuration or cache that needs to be delivered to each instance as well.. How do i accomplish this functionality.

Comments

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 494 admin
    Options

    i can have many queues subscribing to one topic and each get message right ?

    Correct! You can check further in the Solace Docs as well

    i can have one queue subscribing to many topic as well right ?

    That is also correct. When you configure subscriptions on the queue you can add multiple topics to the subscriptions

    You can also read more about promotion and demotion in this blog post https://solace.com/blog/message-promotion-demotion/

    If you are looking to cache the last value to the consumer, you have the option to using LVQ (last value queue) or SolCache. We have a couple of posts in the community about this you can start here https://solace.community/discussion/1190/help-with-setting-up-appropriate-endpoints. Depending on your use-case, you have the option of either binding multiple consumers to a queue (you will have round-robin delivery of messages to the consumers if your queue is a non-exclusive queue) or have multiple queues subscribing to your topic of choice and your instances will bind to the queues. Hope this helps, and more information on your use-case would affect what choice you decide to go with

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    edited February 2022 #3
    Options

    Hi @akg17,

    There are a few options. I would suggest checking out the "Communication Models and How To Choose" section of this codelab. Especially the Consumer Groups part if you're scaling instances of the same microservice: https://codelabs.solace.dev/codelabs/spring-cloud-stream-beyond/index.html?index=..%2F..index#2

  • akg17
    akg17 Member Posts: 76
    Options

    Use case is I have to publish some data to a topic .

    and there are 10 services each must consume a copy of message, this i could achieve having topic subscription. one topic and 10 queues each subscribing to same topic but...

    Problem comes when i scale up and down the micro-service since this data or cache is required for each instance of micro-service only one consumes.

    I need to make sure each service along with its instance could consume it.. No idea how to do it,

    solace cache stores the last value but does this allow to consume message to all consumers including with instances.

  • nram
    nram Member, Employee Posts: 80 Solace Employee
    Options

    @akg17 , If the new application instances (as part of scaling up) need to get a copy of the message, they you will need a queue for each instance. One option is to pre-provision & setup the right topic subscriptions (eg: Queue "<QueueName>-<AppName>-<InstanceId>" with topic subscription "mytopic/broadcast/>"). This may is not an elegant solution though and will break at some point.


    Another option is to use dynamic / temporary endpoint that the application instance can provision and manage as long as the client profile allows. The Temp Queue will be deleted (after a delay) when the client disconnects. Pls see link below.


    More frequent use-case with multiple queue consumers is to have message delivered to only one connected consumer. Depending on the Queue AccessType, messages are either round robin'ed to connected clients (horizontal scaling) or to only one connected client until it stops processing (high availability).