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