![]() IBusControl will allow us to start and stop our bus using the generic host. The generic host exposes provides a IHostedService interface we can easily implement to manage our MassTransit service. I am using SpreadsheetLight here, it’s a simple library to manage excel files. We’ll simply add our DbContext in the constructor so we can save the generated file. You just need to implement IConsumer for you message. \Model\Model.csprojĬreating a consumer for our message is really simple. As for how to consumer RabbitMQ messages from an Android device, I don't have any input there. ![]() You can also send raw JSON messages if the envelope structure used by default is unnecessary. dotnet add package MassTransit dotnet add package dotnet add package MassTransit.RabbitMQ dotnet add package dotnet add package dotnet add package Microsoft.EntityFrameworkCore dotnet add package dotnet add package SpreadsheetLight dotnet add reference. MassTransit uses JSON by default for messages, the structure of which is documented on the web site. Let’s start again by adding all the dependencies we’ll need for our background service. This will allow us to easily change how we want to deploy it in the future and facilitates dependency injection. For our background service host, we’ll use the generic host for dotnet. We can now set-up the consumer of our message on the service side. We’ll just create a simple “Request” class with an Id and a File property. dotnet new sln dotnet new console –-name Service dotnet sln add Service dotnet new web -name Web dotnet sln add Web dotnet new classlib -name Message dotnet sln add Message dotnet new classlib -name Model dotnet sln add Model Assuming we have dotnet installed, we just open a folder in powershell and get started. We first need to set-up our solution and create the projects we’ll need. That will generate an excel file that we can then download afterwards, once the service completes. I’m going to setup a dotnet Web API that will publish a message to a MassTransit service over RabbitMQ. The application I’m going to try and set up is really just a ‘Hello world’ for this stack. Just select the image in Container Station and you have a RabbitMQ instance running. RabbitMQ is actually available as a docker image from DockerHub as well. Our hosting is going to be in docker using one of the dotnet containers available on DockerHub. ![]() For background services, I’m opting for MassTransit, as it seems like an obvious alternative to NServiceBus. I’ve opted for a MySQL database, since my NAS has that pre-installed and use RabbitMQ as a broker for my services. All of those aren’t new, free and/or open-source, so I get the chance to play around with an entirely new stack. The stack I am most familiar with has a SQL Server database that we are using as a broker for NServiceBus with the website hosted in IIS. I had to reconsider some of my usual choices. Given the context I will try to go for free and lightweight software that should mirror what I’m used to working with. Since it supports docker it should be able to run dotnet even though I can’t install dotnet directly on the NAS.
0 Comments
Leave a Reply. |