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.

Validate user IDs

Validate user IDs

- [Instructor] When we receive a message from RabbitMQ, we don't know by default which user or application published this message. This is where validated user IDs come into play. When publishing a message to RabbitMQ, you can add a user ID. This is the username your application used to connect with RabbitMQ. If the user ID doesn't match the username used to connect to RabbitMQ, the message will be refused. This means that RabbitMQ validates the user ID in the message. That way, a consumer can be sure that the message originated from a specific user. Adding a user ID to your message is easy. Just set the UserId property of the BasicProperties object. In this case, I'll set it to WebApp, which is the user ID we used to connect. Now, in the Backoffice, I'll display this user ID on the console. So, var userId = eventArgs.BasicProperties.UserId And then here, I'll just output it to the console. Okay, let's run our…

Contents