From the course: Learning RabbitMQ: Efficient Message Queuing

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Publish to a RabbitMQ exchange

Publish to a RabbitMQ exchange

- [Instructor] We know how our sample application works, so let's add some code to send a message. First, let me double check if my service is running by navigating to localhost at port 15672. Now I see the RabbitMQ management UI, so I know it's running. To get started, add the RabbitMQ NuGet package to the project. I'll be using the command line, so it's dotnet add, specifying the WebApp project package RabbitMQ.Client. Now, if you're using Visual Studio or another IDE, you can of course also use the UI to add this package. Now in the BookingController, let's add a using statement using RabbitMQ.Client and using System.Text, which I'll be using later on. The first thing we need is a connection, and to get, that we need a connection factory. So var factory = new ConnectionFactory() and we'll need to tell this factory where our RabbitMQ instance is running. So I'll do this by setting the URI property, specifying…

Contents