Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Declaring message sources and publishing events in the integration layer

Pragya Keshap answered on February 18, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Publishing events in the composite service
  • Adding configuration for publishing events

  • Declaring message sources and publishing events in the integration layer

    0

    To be able to publish events to different topics, we need to declare one MessageChannel per topic in a Java interface and also declare that we want to use it with an EnableBinding annotation. Let's us see how to do this:

    We declare our message channels in the MessageSources interface in the ProductCompositeIntegration class and ask Spring to inject an instance of it in the constructor, as follows:

    When we want to publish an event on a topic, we use the injected messageSources object. For example, to send a delete event for a product, we can use the outputProducts() method to get a message channel for the product's topic and then use its send() method to publish an event.

    To create the message that contains the event, we can use the built-in MessageBuilder class, as follows: 

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 18 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.