- Notifications
You must be signed in to change notification settings - Fork141
A modern .NET framework for communication over RabbitMq
License
pardahlman/RawRabbit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Looking for documentation of 1.x?Click here
RawRabbit
is a modern .NET framework for communication overRabbitMQ. The modular design and middleware oriented architecture makes the client highly customizable while providing sensible default for topology, routing and more. Documentation for version 2.x of the is currently found under/docs
.
RawRabbit
is configured withRawRabbitOptions
, an options object that makes it possible to register client configuration, plugins as well as override internal services
varclient=RawRabbitFactory.CreateSingleton(newRawRabbitOptions{ClientConfiguration=newConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("rawrabbit.json").Build().Get<RawRabbitConfiguration>(),Plugins= p=>p.UseProtobuf().UsePolly(c=>c.UsePolicy(queueBindPolicy,PolicyKeys.QueueBind).UsePolicy(queueDeclarePolicy,PolicyKeys.QueueDeclare).UsePolicy(exchangeDeclarePolicy,PolicyKeys.ExchangeDeclare)),DependencyInjection= ioc=>ioc.AddSingleton<IChannelFactory,CustomChannelFactory>()});
Set up strongly typed publish/subscribe in just a few lines of code.
varclient=RawRabbitFactory.CreateSingleton();awaitclient.SubscribeAsync<BasicMessage>(async msg=>{Console.WriteLine($"Received:{msg.Prop}.");});awaitclient.PublishAsync(newBasicMessage{Prop="Hello, world!"});
RawRabbits
request/response (RPC
) implementation uses thedirect reply-to feature for better performance and lower resource allocation.
varclient=RawRabbitFactory.CreateSingleton();client.RespondAsync<BasicRequest,BasicResponse>(async request=>{returnnewBasicResponse();});varresponse=awaitclient.RequestAsync<BasicRequest,BasicResponse>();
Unlike many other clients,basic.ack
,basic.nack
andbasic.reject
are first class citizen in the message handler
varclient=RawRabbitFactory.CreateSingleton();awaitclient.SubscribeAsync<BasicMessage>(async msg=>{if(UnableToProcessMessage(msg)){returnnewNack(requeue:true);}ProcessMessage(msg)returnnewAck();});
In addition to the basic acknowledgements, RawRabbit also support delayed retries
varclient=RawRabbitFactory.CreateSingleton();awaitclient.SubscribeAsync<BasicMessage>(async msg=>{try{ProcessMessage(msg)returnnewAck();}catch(Exceptione){returnRetry.In(TimeSpan.FromSeconds(30));}});
Add or change properties in theIPipeContext
to tailor calls for specific type of messages. This makes it possible to modifly the topology features for calls, publish confirm timeout, consumer concurrency and much more
awaitsubscriber.SubscribeAsync<BasicMessage>(received=>{receivedTcs.TrySetResult(received);returnTask.FromResult(true);}, ctx=>ctx.UseSubscribeConfiguration(cfg=>cfg.Consume(c=>c.WithRoutingKey("custom_key").WithConsumerTag("custom_tag").WithPrefetchCount(2).WithNoLocal(false)).FromDeclaredQueue(q=>q.WithName("custom_queue").WithAutoDelete().WithArgument(QueueArgument.DeadLetterExchange,"dlx")).OnDeclaredExchange(e=>e.WithName("custom_exchange").WithType(ExchangeType.Topic))));
About
A modern .NET framework for communication over RabbitMq
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.