concept event feed in category microservice

appears as: n event feed, event feed, The event feed
Microservices in .NET Core, Second Edition

This is an excerpt from Manning's book Microservices in .NET Core, Second Edition.

  • An event feed that the service will use to publish events to the rest of the system. By creating an event feed for the shopping cart, you’ll make it possible for other services (such as a recommendation engine) to update their own data and improve their capabilities.
  • A microservice can publish events to other microservices via an event feed, which is just an HTTP endpoint—at /events, for instance—to which that other microservice can make requests and from which it can get event data. Figure 5.8 shows the components in the Special Offers microservice. Once again, the microservice has the same standard set of components that you’ve seen several times already. In figure 5.8, the components involved in implementing the event feed are highlighted.

    Figure 5.8. The event feed in the Special Offers microservice is exposed to other microservices over HTTP and is based on the event store.
    ch05 fig 8 horsdal2

    The events published by the Special Offers microservice are stored in its database. The EventStore component has the code that reads events from that database and that writes them to the database. The domain model code can use EventStore to store the events it needs to publish. The Event Feed component is the implementation of the HTTP endpoint that exposes the events to other microservices: that is, the /events endpoint.

    The Event Feed component uses EventStore to read events from the database and then returns the events in the body of an HTTP response. Subscribers can use query parameters to control which and how many events are returned.

    Microservices in .NET Core: with examples in Nancy

    This is an excerpt from Manning's book Microservices in .NET Core: with examples in Nancy.

    Figure 2.9. The Shopping Cart microservice publishes events about changes to shopping carts to an event feed. The Recommendations and Shopper Tracking microservices subscribe to these events and react as events arrive.

    Collaboration based on events is asynchronous. That is, the microservice that publishes the events doesn’t call the microservices that subscribe to the events. Rather, the subscribers poll the microservice that publishes events for new events when they’re ready to process them. That polling is what I’ll call subscribing to an event feed. Although the polling is made out of synchronous requests, the collaboration is asynchronous because publishing events is independent of any subscriber polling for events.

    In figure 4.7, you can see the Loyalty Program microservice subscribing to events from the Special Offers microservice. Special Offers can publish events whenever something happens in its domain, such as every time a new special offer becomes active. Publishing an event, in this context, means storing the event in Special Offers. Loyalty Program won’t see the event until it makes a call to the event feed on Special Offers. When that happens is entirely up to Loyalty Program. It can happen right after the event is published or at any later point in time.

    Figure 4.7. The Loyalty Program microservice processes events from the Special Offers microservice when it’s convenient for Loyalty Program.

    As with the other types of collaboration, there are two sides to event-based collaboration. One side is the microservice that publishes events through an event feed, and the other is the microservices that subscribe to those events.