Skip to content

Commit

Permalink
Updated README.md documenting headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
numinnex committed Aug 22, 2023
1 parent 9bd7c05 commit 77061e0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ var messages = await bus.PollMessagesAsync<Product>(new MessageFetchRequest<Prod
}, deserializer);
```
In version 0.0.6 an optional encryptor/decryptor parameter to `SendMessagesAsync` and `PollMessagesAsync` has been added.
```c#
Func<byte[], byte[]> encryptor = payload =>
{
//your encryption logic goes here...
}
await bus.SendMessagesAsync<Product>(streamId, topicId, Partitioning.PartitionId(partitionId), messages, serializer, encryptor);
```
As of version 0.0.7 optional headers has been added to `SendMessagesAsync`, You can create an header object with following code:
```c#
var headers = new Dictionary<HeaderKey, HeaderValue>();
headers.Add(new HeaderKey { Value = "key_1".ToLower() }, HeaderValue.String("test-value-1"));
headers.Add(new HeaderKey { Value = "key_2".ToLower() }, HeaderValue.Int32(69));
headers.Add(new HeaderKey { Value = "key_3".ToLower() }, HeaderValue.Float32(420.69f));
headers.Add(new HeaderKey { Value = "key_4".ToLower() }, HeaderValue.Bool(true));
headers.Add(new HeaderKey { Value = "key_5".ToLower() }, HeaderValue.Raw(byteArray));
headers.Add(new HeaderKey { Value = "key_6".ToLower() }, HeaderValue.Int128(new Int128(6969696969, 420420420)));
headers.Add(new HeaderKey { Value = "key7".ToLower() }, HeaderValue.Guid(Guid.NewGuid()));
```
and then simply pass them as argument to `SendMessagesAsync` function
```c#
await bus.SendMessagesAsync<Product>(streamId, topicId, Partitioning.PartitionId(partitionId), messages, serializer, encryptor, headers);
```

It is worth noting that every method will throw an `InvalidResponseException` when encountering an error.<br><br>
If you register `IMessageStream` in a dependency injection container, you will have access to interfaces
Expand Down

0 comments on commit 77061e0

Please sign in to comment.