Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A modern .NET framework for communication over RabbitMq

License

NotificationsYou must be signed in to change notification settings

pardahlman/RawRabbit

Repository files navigation

Looking for documentation of 1.x?Click here

RawRabbit

Build StatusDocumentation StatusNuGetGitHub releaseSlack Status

Quick introduction

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.

Configure, enrich and extend

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>()});

Publish/Subscribe

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!"});

Request/Response

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>();

Ack, Nack, Reject and Retry

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));}});

Granular control for each call

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

Stars

Watchers

Forks

Packages

No packages published

Contributors19


[8]ページ先頭

©2009-2025 Movatter.jp