ASP.NET Core Integration¶
ServiceBus.AspNetCore.Rabbit extends the messaging infrastructure provided by ServiceBus.Core.Rabbit and enables RPC-style communication between applications using RabbitMQ as the transport layer.
Unlike traditional publish/subscribe communication, RPC introduces a request/response interaction model.
Why RPC?¶
Publish/Subscribe is ideal for:
- events;
- notifications;
- asynchronous workflows;
- integration messaging.
However, some scenarios require a response to be returned to the caller.
Examples include:
- validation services;
- business calculations;
- lookup services;
- application integration endpoints.
Communication Model¶
The ASP.NET Core integration layer allows an application to publish a request message through RabbitMQ and receive a response generated by an ASP.NET Core application.
graph LR
Client
RabbitMQ
ASPNET["ASP.NET Core"]
Client --> RabbitMQ
RabbitMQ --> ASPNET
Components¶
The RPC implementation is built around the following contracts:
| Component | Responsibility |
|---|---|
| IAsyncRestPublisher | Sends requests |
| IRestHostSubscriber | Receives requests |
| RestHostSubscriberBound | RabbitMQ implementation |
| ASP.NET Core | Executes application logic |
Relationship With Publish/Subscribe¶
The RPC model does not replace publish/subscribe messaging.
Instead, it complements it.
graph TD
PublishSubscribe["Publish / Subscribe"]
RPC["RPC"]
PublishSubscribe --> Events
RPC --> Requests
Use:
- Publish/Subscribe for event-driven communication.
- RPC when a response is required.