2 A basic shopping cart microservice

 

This chapter covers

  • A first iteration of an implementation of the shopping cart microservice
  • Creating HTTP endpoints with ASP.NET MVC
  • Implementing a request from one microservice to another
  • Implementing a simple event feed for a microservice

In chapter, 1 we looked at how microservices work and how they can be characterized. You also set up a simple technology stack—C#, ASP.NET, and the ASP.NET MVC framework—that lets you create microservices easily, and you saw a basic shopping cart microservice. In this chapter, you’ll implement the four main parts of this microservice using the same technology stack:

  1. A basic HTTP-based API allowing clients to retrieve a cart, delete it, and add items to it. Each of these methods will be visible as an HTTP endpoint, such as http://myservice/add/{item_number}.
  2. A call from one service to another for more information. In this case, the shopping cart microservice will ask the product catalog microservice for product information based on the item_number of the item being added to the cart.
  3. 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.
  4. The domain logic for implementing the behavior of the shopping cart.

2.1 Overview of the Shopping Cart microservice

 
 
 

2.1.1 Components of the Shopping Cart microservice

 
 
 
 

2.2 Implementing the Shopping Cart microservice

 
 
 
 

2.2.1 Creating an empty project

 
 

2.2.2 The Shopping Cart microservice’s API for other services

 
 

2.2.3 Fetching product information

 
 

2.2.4 Parsing the product response

 
 
 

2.2.5 Adding a failure-handling policy

 
 

2.2.6 Implementing a basic event feed

 
 

2.3 Running the code

 
 
 
 

Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest