Skip to content

Commit

Permalink
Docs - describe customization in message pump (#83)
Browse files Browse the repository at this point in the history
* Docs - describe customization in message pump

* pr-sug: update index page

* pr-sug: update index page

* pr-sug: add back arrows to doc pages
  • Loading branch information
stijnmoreels authored Mar 13, 2020
1 parent aa43334 commit 4bf1735
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/features/message-pumps/customization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: "Message Pump Customization"
layout: default
---

# Customize Message Pumps

While the message processing is handled by the `IMessageHandler<>` implementations, the message pump controls in what format the message is received.
We allow several customizations while implementing your own message pump.

## Control Custom Deserialization

When inheriting from an `...MessagePump` type, there's a way to control how the incoming raw message is being deserialized.
Based on the message type of the registered message handlers, the pump determines if the incoming message can be deserialized to that type.

```csharp
public class OrderMessagePump : MessagePump
{
public OrderMessagePump(
IConfiguration configuration,
IServiceProvider serviceProvider,
ILogger<OrderMessagePump> logger)
: base(configuration, serviceProvider, logger)
{
}

public override bool TryDeserializeToMessageFormat(string message, Type messageType, out object? result)
{
if (messageType == typeof(Order))
{
result = JsonConvert.DeserializeObject<Order>(message);
return true;
}
else
{
result = null;
return false;
}
}
}
```

[&larr; back](/)
2 changes: 2 additions & 0 deletions docs/features/message-pumps/service-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ We provide templates to get started easily:

- Azure Service Bus Queue Worker Template ([docs](https://templates.arcus-azure.net/features/servicebus-queue-worker-template))
- Azure Service Bus Topic Worker Template ([docs](https://templates.arcus-azure.net/features/servicebus-topic-worker-template))

[&larr; back](/)
2 changes: 2 additions & 0 deletions docs/features/service-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ This information can be acces in a more simplified way:
MessageContext messageContext = ...
Encoding encoding = messageContext.GetMessageEncodingProperty();
```

[&larr; back](/)
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Coming soon!

- Support for using message pumps for the following brokers:
- Azure Service Bus ([docs](features/message-pumps/service-bus))
- Azure Service Bus Extensions ([docs](features/service-bus))
- Support for exposing TCP health probes to periodically check liveness/readiness of the host ([docs](features/tcp-health-probe))
- Customize message pumps ([docs](features/message-pumps/customization))

# License
This is licensed under The MIT License (MIT). Which means that you can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the web application. But you always need to state that Codit is the original author of this web application.
Expand Down

0 comments on commit 4bf1735

Please sign in to comment.