Spring Cloud Stream + Microservice Pub/Sub

bensabat
bensabat Member Posts: 6

Hello,

I am creating a microservice through spring cloud stream. My idea is to have a publisher application send messages through a queue to the microservice, which will then process data, and send out the processed data to a consumer application through a queue. I am having an issue with understanding how to configure the spring cloud stream processor to do this through the application.yaml file and using binding. I have set up the spring cloud stream application with the uppercase function example, and I connect successfully through the try me tab on the solace console. I need guidance on how to get the microservice to receive from a queue (for example from a spring boot sender application) and get the microservice to send to a queue (for example to a spring boot receiver application). Could someone please provide an example of how I would go about doing something like this?

Comments

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 954 admin

    Hi @bensabat,
    Welcome to the Solace Community! That's awesome that you're using the Spring Cloud Stream binder and already have it working with the uppercase function example.

    One thing to keep in mind with Solace is that our best practice when using guaranteed messaging is to publish to topics and consume from queues which have topic subscriptions. And this is exactly what our Spring Cloud Stream binder does. So whenever the binder consumes it does so from a queue that subscribes to desired topics, and whenever it publishes it publishes to a topic (with the exception of publishing to an error queue).

    So if you check out this config for the cloud-stream-processor sample you'll see that it has an input binding and an output binding. The input binding convertFtoC-in-0 has a destination and a group which will be used as part of the durable queue name and the destination and queueAdditionalSubscriptions will be added to that queue as topic subscriptions. Then on the output binding convertFtoC-out-0 the destination is actually a topic that output messages will be published to.

    So to send messages to this app you could publish to the sensor/temperature/fahrenheit topic, and note that you can also use Solace topic wildcards to specify your topic. Then to receive messages from that app you would subscribe to the sensor/temperature/celsius topic. The cloud-stream-source and cloud-stream-sink apps in that repo should be configured to do just that if you need an example :)

    If you're new to Solace I'd definitely check out @Aaron's video on Solace topics.

    Hope that helps!

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 954 admin

    Also I should be releasing a new Spring Cloud Stream codelab next week that will go into much more details than the current one! I'll try to remember to respond here when it's available but also check https://codelabs.solace.dev next week!

  • bensabat
    bensabat Member Posts: 6

    Thank you for the clarification @marc . Looking forward to going over that new codelab that is coming out!

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 954 admin

    FYI, new codelab released yesterday ;)
    Spring Cloud Stream - Beyond the Basics