Skip to content

Commit

Permalink
Merge pull request #198 from cemremengu/2.0
Browse files Browse the repository at this point in the history
Added starter documentation for publish and consume operations
  • Loading branch information
pardahlman authored Mar 10, 2017
2 parents 460913c + 7f4e4d8 commit 53d6f4e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
23 changes: 22 additions & 1 deletion docs/operations/publish.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Publish

Bah
It just isn’t feasible to have a multi-line, complex expression just to perform a simple publish (or any other operation for that matter).
This is where extension methods come to the rescue. It turns out that it is dead simple to create a publish signature that very much resembles the 1.x way of doing things.

First get the `Publish` operation package to enrich the BusClient with Publishing capabilities

```nuget
PM> Install-Package RawRabbit.Operations.Publish
```

then you can

```csharp

var message = new BasicMessage { Prop = "Hello, world!" };

await publisher.PublishAsync(message, ctx => ctx
.UsePublisherConfiguration(cfg => cfg
.OnExchange("custom_exchange")
.WithRoutingKey("custom_key")
));
```
37 changes: 36 additions & 1 deletion docs/operations/subscribe.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# Subscribe
# Subscribe

The extension methods again come to the rescue! Subscriptions again very much resembles the 1.x way of doing things with a cleaner separation of concerns.

## BasicConsume

First get the `Subscribe` operation package to enrich the BusClient with subscription/consuming capabilities

```nuget
PM> Install-Package RawRabbit.Operations.Subscribe
```

then you can

```csharp

await _rabbitBus.BasicConsumeAsync(async args =>
{
await
Task.Run(() => MyTask());

return new Ack();

}, ctx => ctx
.UseConsumerConfiguration(cfg => cfg
.Consume(c => c
.WithRoutingKey("custom_routing_key")
.OnExchange("custom_exchange")
.WithPrefetchCount(100)
)
.FromDeclaredQueue(q => q
.WithName("custom_queue_name")
))
);
```

0 comments on commit 53d6f4e

Please sign in to comment.