RabbitMQ (rabbit)
Deployment, connections, protocol mappings and reliability boundaries for the RabbitMQ messaging project.
RabbitMQ.Client integrates topic switches and message queues, suitable for applications that use routing and work queues to distribute tasks. See publish/subscribe and delivery for public concepts, and see Message Queues for cross-project comparison and complete calling examples.
source code directory
messaging/rabbit
NuGet package
Zongsoft.Messaging.RabbitMQ
provider and connection driver name
RabbitMQ
Deployment and Connection
Append the implementation package to the existing host's Deployment checklist, retaining the manifest and running dependencies. Broker address, account and topic permissions are provided by the operating environment.
[plugins zongsoft messaging rabbit]
nuget:Zongsoft.Messaging.RabbitMQSource: framework/messaging/rabbit/samples/Program.cs (excerpt; see source for context).
using var queue = new RabbitQueue("RabbitMQ",
Configuration.RabbitConnectionSettingsDriver.Instance.GetSettings("RabbitMQ", $"server=127.0.0.1;port=5672;client=Zongsoft.Messaging.RabbitMQ.Sample-{Guid.NewGuid():N};username=program;password=xxxxxx;"));Discussions currently does not have a business process that integrates this queue, so the project's existing interactive client is used. The queue is constructed directly here, and the topic is passed in by the subscribe / produce command. xxxxxx in the RabbitMQ sample is the local test password placeholder value, which needs to be adjusted according to the isolation environment before running.
Subscription Entry in the Example
Source: framework/messaging/rabbit/samples/Program.cs (excerpt; see source for context).
executor.Command("subscribe", async (context, cancellation) =>
{
if(context.Arguments.IsEmpty)
throw new CommandException("Missing the topics for subscribe.");
for(int i = 0; i < context.Arguments.Count; i++)
{
var subscriber = await queue.SubscribeAsync(context.Arguments[i], Handler.Instance, cancellation);
if(subscriber == null)
context.Output.WriteLine(CommandOutletColor.DarkRed, $"Failed to subscribe topic: {context.Arguments[i]}");
else
context.Output.WriteLine(CommandOutletColor.DarkGreen, $"The subscription to the '{subscriber.Topic}' topic was successful.");
}
});executor and Handler.Instance come from the same Program.cs. The client keeps the interactive loop, and the close command releases the queue it created directly. If the shared queue is obtained from the application provider instead, ownership needs to be handled according to the provider's agreement.
Protocol Mapping
This implementation uses topic exchange; Group configures the switch, and Queue specifies the queue. Topics and tags participate in routing, and consumption uses manual ACK. The Group here cannot be understood according to the semantics of Kafka consumer groups.
First Integration
Prepare the required permissions for test accounts, switches and queues, and check the connected virtual hosts.
Use the RabbitMQ provider to create named queues and verify topic routing and message arrival.
Confirm after the business is submitted, and then check for processing failures, disconnections, reconnections and duplicate messages.
Asynchronous business processing uses a public handler contract, and the asynchronous lambda cannot be handed over to the synchronous delegate subscription overload. The queue obtained by the provider may be shared, and the consumer only releases the subscription resources it owns; see Message Queues for a complete example.
Reliability Boundary
🚨 Manual ACK only covers the consumer confirmation process. Durable queues, message persistence, publication acknowledgment, and Broker high availability need to be verified separately; one option cannot be generalized as a complete reliability guarantee.
The fault experiment needs to distinguish between publishing results, Broker acceptance, business commit and message confirmation, see Reliable Delivery and Message Storage.
Project Resources
Last updated