1
0
mirror of synced 2024-11-25 04:03:09 +01:00
Tapeti/Examples/03-FlowRequestResponse/ReceivingMessageController.cs

33 lines
925 B
C#
Raw Normal View History

using System.Threading.Tasks;
using Messaging.TapetiExample;
using Tapeti.Annotations;
namespace _03_FlowRequestResponse
{
[MessageController]
[DynamicQueue("tapeti.example.03")]
public class ReceivingMessageController
{
// No publisher required, responses can simply be returned
public static async Task<QuoteResponseMessage> HandleQuoteRequest(QuoteRequestMessage message)
{
2022-02-09 09:19:56 +01:00
var quote = message.Amount switch
{
2022-02-09 09:19:56 +01:00
1 =>
// Well, they asked for it... :-)
2022-02-09 09:19:56 +01:00
"'",
2 => "\"",
_ => new string('\'', message.Amount)
};
// Just gonna let them wait for a bit, to demonstrate async message handlers
await Task.Delay(1000);
return new QuoteResponseMessage
{
Quote = quote
};
}
}
}