How to trigger a solace supplier

VarunDamani
VarunDamani Member Posts: 14
edited July 2021 in PubSub+ Event Broker #1

I have a supplier function that will produce messages to a solace broker. By default, the supplier is called every second to generate messages. But in my case, I want to explicitly call the supplier based on an internal event. How do I do that?

Comments

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 638 admin

    How is your internal event generated / triggered? Do you have a callback handler or something in your application that gets called when this event occurs? Could you just build the Solace message and publish it from there when that occurs?

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    Hi @VarunDamani ,

    Without more details it's difficult to be specific. The typical pattern would be to have your supplier/producer subscribe to the event(s) that trigger an update. When it receives an event it can then process the update and send that.

  • VarunDamani
    VarunDamani Member Posts: 14
    edited July 2021 #4

    Hey @TomF and @Aaron , thanks for responding quickly.
    The internal event that I was referring to is the event generated by an Axon server. I have an event handler function that gets called when a specific axon event is generated. And when I get a particular Axon event, I need to produce an event on Solace

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

    Hi @VarunDamani,

    I noticed you said a Supplier function that is triggered every second by default...sounds like you might be using Spring Cloud Stream?

    If so you can checkout StreamBridge which allows you to send a message from wherever you need to. This project shows an example where the EndpointController class receives REST calls and sends using the send method in the MessageService class which uses StreamBridge in this way.

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

    Ah, after I posted the previous response I saw you actually included the "spring-cloud-stream" tag. You can checkout more about StreamBridge in the "Dynamic Publishing" section of this codelab as well.

  • VarunDamani
    VarunDamani Member Posts: 14

    Hi @marc , thanks for the suggestion and resource link. I will try it out.