.NET Core Microservices – DShop

It’s been a while since I published the latest article, but it’s high time to finally get into the topic of microservices for real. Does open source, .NET Core, distributed system, Docker and other cool words sound good to you? If that’s the case, stick with me and let me guide you through the world (or at least part of it) of microservices. This is going to be the very first article (an introduction) of the upcoming series.


 

Foreword

A few months ago, I had an idea to publish a detailed course about implementing microservices in .NET Core. It turned out, that a friend of mine, Darek, thought of a similar concept – so we teamed up, created the distributed application (available on GitHub) and gave a few lectures (close to 10) during IT events and conferences, here in Poland. The idea of the recording a video course is still there (and sooner or later, it will be published), yet for now, we need to polish some remaining bits of the application.

Nevertheless, whether you are a microservice expert or beginner, read a book published by Microsoft and studied the eShopOnContainers repository (or not), let me introduce you the DShop (Distributed Shop), a brand new solution, containing over 15 repositories, including API Gateway + 8 microservices written totally from the scratch using the latest version of ASP.NET Core (2.1.1), hopefully, a starting point for some of you, who wanted to get into the world of microservices hype but had no idea where to start, or got stuck somewhere during the journey.

DShop

As before mentioned, DShop stands for an acronym of Distributed Shop, simple as that.
Why another online shop? For a single reason – this domain is usually understood by all of the people (including developers) at least at its very basic level – products, shopping carts, orders etc. If you’re into the world of DDD, these are also pretty good bounded contexts, that can be treated as separate microservices. And trust me – we (Piotr and Darek, the core developers behind the project) made everything as simple as possible (besides some generic reflection magic and other quirks), so you should be able to understand quite fast what’s going on, simply by looking at the domain models or application services (handlers).

Source

The whole idea behind DShop was to make it for you – the programmers, so that you can take a look at the code, play with it, validate your own ideas, copy our code and use it in your own projects, or point out our mistakes – whatever makes you a better software developers and provide the valuable content. Thus, you can download the whole source code from GitHub, just keep in mind that we update the repositories from time to time, fix bugs, refactor the code and extend some features – it’s an ongoing project.

Tech

One of our goals was to make the solution agnostic from cloud providers that offer some special services (e.g. Azure Service Bus or AWS Lambda). Basically, you can run DShop anywhere – on local machine, private server or in any cloud. Let’s have a glimpse, what technologies and tools are being used to make it work:

  • .NET Core – API Gateway and all microservices are written in C# and ASP.NET Core (2.1.1)
  • RabbitMQ – one of the most popular message buses out there and RawRabbit as client library
  • MongoDB – NoSQL databse to store the services data
  • Redis – extremely fast caching server, an ideal choice for distributed systems
  • Docker – containers are everywhere, so Dockerfile for each service and Docker compose on top of it
  • Travis CI – build service, free to use for open source projects hosted on GitHub
  • Docker Hub – Docker images repository, where DShop images are being published
  • Rancher – enterprise management for Kubernetes, open source and easy to use

There are of course some other tools or libraries being used e.g. Angular 6 for the web application (not finished yet), but let’s leave it for now, we’ll talk about them in the next posts.

Start

Each project has its own repository. We’ll discuss the solution structure in the upcoming articles, but these are the most important projects (besides the bash scripts, that were simply copied from the base DNC-DShop repository).

DShop projects

DShop projects

In order to start DShop you need to have RabbitMQ, MongoDB, and Redis up and running (not to mention the latest version of .NET Core SDK). You can also easily start these through Docker – just take a look at the following script.

Once the required services are available, you can start either one by one or via Docker all of the microservices (projects named DShop.Services.Xyz, a total number of 8) and the API Gateway (DShop.Api). You can also make use of this script that loops through each repository and starts the project – just keep in mind to put that into the root directory, where the remaining projects are (as shown on the screen above).

Assuming that everything is up and running, you shall find the DShop.rest file that uses REST Client extension for the VS Code – give it a try and send a few HTTP requests to the API.

That being said, I encourage you to explore the source code and play with it. Stay tuned, as in the next posts we’ll go through the particular microservices implementation, talk about the distributed systems pros & cons and many, many other concepts that sometimes are not clearly visible at the first glance.

Oh, and finally – check out the DevMentors.io and subscribe to our social media channels, if you want to know once the video course will be completed.

P.S.

If you know Polish, take a look at the following video that was recorded quite recently – here, we talk about the DShop and core aspects of microservices.

42 Comments .NET Core Microservices – DShop

  1. Pingback: .NET Core Microservices – DShop project - How to Code .NET

  2. Pingback: Dew Drop - July 5, 2018 (#2759) - Morning Dew

  3. tonymk

    Greate article! Looking forward to the continuation of the series. One request would be english subtitles on the video(s).

    Reply
  4. Pingback: The Morning Brew - Chris Alcock » The Morning Brew #2621

  5. Karthick Thoppe

    Good one; the Devil is in the details, will take a look at the code. Is Polyglot aspect of the Microservices in your agenda for the future articles? Also, can anyone contribute to your DShop project or is it purely for demo purposes & showcase?

    Thanks!

    Reply
    1. Piotr Gankiewicz

      I used to implement services in different technologies, however, in DShop, we wanted to focus purely on .NET Core. Speaking of contribution – feel free to submit any PRs, just please keep in mind that eventually, we are going to record video course about it, thus we’d like to introduce rather small adjustments (at least for now) :).

      Reply
  6. Radek Maziarka

    Thanks Piotrek for this great series of articles and repositories!

    I have a question regarding user authorization – how would you handle sharing user context between services? For example – we are removing user XYZ from Admin role by running an action in Identity service. How would other services know that this action took place?

    Reply
    1. Piotr Gankiewicz

      Hi Radek, thanks!

      It really depends on what’s the end goal – if other services really have to be aware of such behavior, Identity Service could simply publish an event such as ‘UserRoleChanged’. Sharing user context – again, this can be done via ICorrelationContext (which contains UserId property) being a metadata type attached to all of the messages that are being published. Nevertheless, since the API is responsible for dispatching the actions properly and ensuring that user has required claims there’s rarely a need to share such information :).

      Reply
  7. Pingback: .NET Core Microservices – theory, DShop solution structure | Piotr Gankiewicz

  8. Asad

    Hi,

    If you are going for micro service than each service should be a decouple components and should have its own UI as well . In your article there is no UI composition. If you modify your UI because a micro service changed than you need to test all of your UI which means you are testing all the micro services, second you are taking about gateway pattern, it means if you add and modify your micro service’s contract than you need to modify or deploy your gateway as well. You are not splitting monolithic application vertically and going for horizontally which I think is not a good approach.

    Reply
    1. Piotr Gankiewicz

      I disagree, why would each microservice have its own UI? It doesn’t make much sense – you create a single API Gateway and then a special application on top of that (mobile, web, desktop) that communicates only with this API. Microservices should be kept internally.

      Reply
  9. Pedro

    You guys rock! Thanks for your effort of writing sample microservices repository. Love from Manila Philippines.

    Reply
  10. Nehmia

    This is just amazing. I have been looking for a complete distributed sample application using .NET Core, Angular 6, Docker and Kubernetes. I tried to go through the Polish video overview, eventhough I don’t understand Polish at all, just to see the architecture diagram. One thing I would like to ask is why it was needed to go through two handlers for create/update commands. From the video I saw that the Gateway ‘Create’ API publishes to Product Handler and then this handler published to Product Storage Handler to call repository to create the Product. Couldn’t the API directly publish to the Storage Handler by passing the Product Handler? Because for GET requests, we’re directly calling the Storage Service from the API. Just wanted clarification on this since I might have misunderstood the architecture.

    I can’t wait for the English version of this.

    Thank you!!

    Reply
  11. Pingback: Friday Five: MVPs with Fresh Insights on .NET Core and More! – Microsoft MVP Award Program Blog

  12. Pingback: LAPS, Surface Peripherals, a GDPR Field Guide, an MVP Journey, and more on the Friday Five! – Microsoft MVP Award Program Blog

  13. Dragon

    Is really good help for me .I have been looking for the article of Microservice,but most of them are not helpless,untill I read the RawRabbit in somewhere,so I feel find it!
    Thanks!

    Reply
  14. Pingback: Distributed .NET Core – Teaser | Piotr Gankiewicz

  15. hp canada

    Dshop is a project of .NET which is very nicely explained in this blog about the whole process of D shop using Core Microservices. This is very effective for the .NET programmers.

    Reply
  16. hp canada

    Dshop is a project of .NET which is very nicely explained in this blog about the whole process of Dshop using Core Microservices. This is very effective for the .NET programmers.

    Reply
  17. Facebook customer service number

    Facebook provides the best conversation features such as Video calling, voice call, and chat. If you have the Facebook account then you can easily use these services. In case, you face some technical problems while using these Facebook services.

    Reply
  18. HP Printer Support

    HP brand is one of the most usable brands in the world. User buys HP laptop, desktop, and printers and sometimes a technical issue occurs in your HP device. Don’t worry, an HP support expert are sat there to provide you HP support

    Reply
  19. dialprintersupport

    We all live in a modern era, where technology has taken its entire place. Technology has made many lives easier and organized. There are numerous numbers of devices which are available in the market such as Desktops, Mobile Phones, Cameras, Laptops, Scanners and Printers. All these devices have made our life easier and let us connect to any part of the world within the time fraction.

    Reply
  20. HP TECH SUPPORT

    HP devices. Be it any question or any technical glitches, we’ve the simplest school specialists to assist you out with the problems. we have a tendency to skillful in breakdown any issue you may be facing along with your HP merchandise like laptops, printers, tablets, scanners, Omen, Envy, Omni book, Probook, Chromebook, Notebook different HP devices HP Tech Support

    Reply
  21. Hasilbertapa

    I ‘d mention that we site visitors are extremely lucky to live in a fantastic community with very many awesome people with interesting principles. I feel very happy to have seen your weblog and look forward to some more cool moments reading here. Thanks once again for all the details.

    Reply
  22. Sara Manuel

    HP brand is one of the most usable brands in the world.HP devices. Be it any question or any technical glitches, we’ve the simplest school specialists to assist you out with the problems.

    Reply
  23. Apple support phone number

    As we know today’s era is a digital era where people like to be in touch through a digital medium there are many social media platforms are available like facebook Instagram LinkedIn twitter with the help of which two people can interact with each other without making or seeing each other physically or if we talk about skype or video calling so through that medium we can even see each other while both the person are far away from each other

    Reply
  24. dialprintersupport

    I ‘d mention that we site visitors are extremely lucky to live in a fantastic community .If you need any kind of technical support for Canon Printer whether it is regarding setup installation or driver issues you are free to call at Canon Printer customer support number that stays available 24 7 for your assistance. Canon Printer Technical Support

    Reply
  25. kaspersky support number

    A micro service is a software development technique—a variant of the service-oriented architecture architectural style that structures an application as a collection of loosely coupled services. In a micro services architecture, services are fine-grained and the protocols are lightweight.

    Reply
  26. jonnmm

    Online Pharmacy Pills is a online medicine store where you can buy soma 500mg to over come the issue of muscle pain and discomfort. It works by helping to relax the muscles.

    if you are looking for free shipping all over USA for soma pills 500 mg and soma pills 350 mg then you have no need to wait and order from online pharmacy pills. Online pharmacy pills is a trust worthy online store.

    For better Living we have a best and fast relief from pain in muscles so you can buy soma pills 500 mh from your home we are shipping order at your with free shipping.

    if you want To buy soma pills from trusted online store, online pharmacy pills must be your first choice because online pharmacy pills providing free shipping on soma pills, tramadol, provigil etc.

    Reply
  27. jonnmm

    if you are looking for free shipping all over USA for soma pills 500 mg and soma pills 350 mg then you have no need to wait and order from online pharmacy pills. Online pharmacy pills is a trust worthy online store.

    Reply
  28. Brother printer support

    Brother Printer Support is a one stop solution for printer services. We are proud of delivering instant and highly effective services at any hour of day and also the issue is being rectified as well as corrected in real time right in front of you. We are available 24×7 at +1-888-621-0339.

    Brother Printer Support

    Reply
  29. Factory reset Hp laptop

    Hello, introduction to developing micro services-based applications and managing them using containers. It discusses architectural design and implementation approaches using .NET Core and Docker containers.if you want any help regrading factory reset hp laptop you can visit our site .

    Reply

Leave A Comment

Your email address will not be published. Required fields are marked *