-
-
Notifications
You must be signed in to change notification settings - Fork 364
RabbitMQ transport
RabbitMQ has native support for topic-based messaging, and Rebus will use that capability to implement pub/sub.
Therefore, the following configuration is enough for two Rebus instances to be able to communicate:
var subscriber = Configure.With(...)
.Transport(t = t.UseRabbitMq(connectionString, "my-subscriber"))
.Start();
var publisher = Configure.With(...)
.Transport(t = t.UseRabbitMq(connectionString, "my-publisher"))
.Start();
after which you may go
await subscriber.Subscribe<MyEvent>();
and then the subscriber will be subscribed to everything the publisher publishes like so:
await publisher.Publish(new MyEvent(...));
Since the subscriber will receive all types of events that it has subscribed to, it will need to be able to handle those events, so a slightly more full code example for the subscriber could look like this:
using (var activator = new BuiltInHandlerActivator())
{
// add handler for MyEvent
activator.Handle<MyEvent>(async message => {
// handle event in here
});
// configure subscriber
var subscriber = Configure.With(activator)
.Transport(t = t.UseRabbitMq(connectionString, "my-subscriber"))
.Start();
await subscriber.Subscribe<MyEvent>();
Console.WriteLine("Press ENTER to quit")
Console.ReadLine();
}
Depending in your type of application, you will probably need to rearrange how BuiltInHandlerActivator
is created and disposed.
Basic stuff
- Home
- Introduction
- Getting started
- Different bus modes
- How does rebus compare to other .net service buses?
- 3rd party extensions
- Rebus versions
Configuration
Scenarios
Areas
- Logging
- Routing
- Serialization
- Pub sub messaging
- Process managers
- Message context
- Data bus
- Correlation ids
- Container adapters
- Automatic retries and error handling
- Message dispatch
- Thread safety and instance policies
- Timeouts
- Timeout manager
- Transactions
- Delivery guarantees
- Idempotence
- Unit of work
- Workers and parallelism
- Wire level format of messages
- Handler pipeline
- Polymorphic message dispatch
- Persistence ignorance
- Saga parallelism
- Transport message forwarding
- Testing
- Outbox
- Startup/shutdown
Transports (not a full list)
Customization
- Extensibility
- Auto flowing user context extensibility example
- Back off strategy
- Message compression and encryption
- Fail fast on certain exception types
Pipelines
- Log message pipelines
- Incoming messages pipeline
- Incoming step context
- Outgoing messages pipeline
- Outgoing step context
Prominent application services