2019-08-16 09:47:57 +00:00
|
|
|
|
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
|
2022-02-09 08:19:56 +00:00
|
|
|
|
#pragma warning disable CA1822 // Mark members as static - not supported yet by Tapeti
|
2019-08-16 09:47:57 +00:00
|
|
|
|
public async Task<QuoteResponseMessage> HandleQuoteRequest(QuoteRequestMessage message)
|
|
|
|
|
{
|
2022-02-09 08:19:56 +00:00
|
|
|
|
var quote = message.Amount switch
|
2019-08-16 09:47:57 +00:00
|
|
|
|
{
|
2022-02-09 08:19:56 +00:00
|
|
|
|
1 =>
|
2019-08-16 09:47:57 +00:00
|
|
|
|
// Well, they asked for it... :-)
|
2022-02-09 08:19:56 +00:00
|
|
|
|
"'",
|
|
|
|
|
2 => "\"",
|
|
|
|
|
_ => new string('\'', message.Amount)
|
|
|
|
|
};
|
2019-08-16 09:47:57 +00:00
|
|
|
|
|
|
|
|
|
// Just gonna let them wait for a bit, to demonstrate async message handlers
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
|
|
|
|
|
return new QuoteResponseMessage
|
|
|
|
|
{
|
|
|
|
|
Quote = quote
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-02-09 08:19:56 +00:00
|
|
|
|
#pragma warning restore CA1822
|
2019-08-16 09:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|