generated from arcus-azure/arcus.github.template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs - describe customization in message pump (#83)
* 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
1 parent
aa43334
commit 4bf1735
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
``` | ||
|
||
[← back](/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters