Instead of doing a manual cleanup of my local RabbitMQ cluster I decided to use the Management HTTP API and script the whole process.
I decided to use Postman and the collection runner data files support.
Let’s walk through the steps:
- I started by creating a new Collection inside Postman:
- Inside this collection I started adding DELETE requests to different objects(exchanges, queues,…) inside RabbitMQ
- I used variables (recognizable with the double mustaches {{variableName}}) inside the URLs.
- E.g. http://user:pw@localhost:15672/api/exchanges/%2F/{{exchange}}
- These variables should be replaced by values from a JSON data file.
- Create a JSON file containing a list of values. Unfortunately it is not possible to add the data file to your collection. So save it anywhere you want
- Here is how the data file looked like for the above request:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"exchange": "MassTransit.Courier.Contracts:RoutingSlip"}, | |
{"exchange": "MassTransit.Courier.Contracts:RoutingSlipActivityCompleted"}, | |
{"exchange": "MassTransit.Courier.Contracts:RoutingSlipCompleted"}, | |
{"exchange": "MassTransit.Scheduling:CancelScheduledMessage"}, | |
{"exchange": "MassTransit.Scheduling:CancelScheduledRecurringMessage"}, | |
{"exchange": "MassTransit.Scheduling:ScheduleRecurringMessage"}, | |
{"exchange": "MassTransit.Scheduling:ScheduleMessage"}, | |
{"exchange": "MassTransit.Scheduling:ScheduleMessage--Messages:ProcessSampleCommand--"}, | |
{"exchange": "MassTransit:Fault"}, | |
{"exchange": "MassTransit:Fault--Messages.Events:OrderCompleted--"}, | |
{"exchange": "MassTransit:Fault--Messages:ProcessSampleCommand--"}, | |
{"exchange": "Messages.Commands:HighPriorityCommand"}, | |
{"exchange": "Messages.Events:CartRemoved"}, | |
{"exchange": "Messages.Events:CartExpired"}, | |
{"exchange": "Messages.Events:CartItemAdded"}, | |
{"exchange": "Messages.Events:IDomainEvent"}, | |
{"exchange": "Messages.Events:OrderCompleted"}, | |
{"exchange": "Messages.Events:OrderConfirmedEvent"}, | |
{"exchange": "Messages.Events:OrderSubmitted"}, | |
{"exchange": "Messages:ProcessSampleCommand"} | |
] |
- Let’s now try to use the collection runner. Click on the Runner button at the top:
- Select the collection you want to run on the left.
- Also select a data file.
- Click on the big blue run button to execute the requests in the collection. Parameters will be replaced using the values you’ve provided in the data file.