37
loading...
This website collects cookies to deliver better user experience
TranslateTextPipeModel
implements two interfaces:IInQueuePipeModel
IOutQueuePipeModel
DeserializeTranslateTextRequestStep
DeserializeApprovalTextResponseStep
PrepareApprovalTextRequestStep
TranslateTextPipeFactory
which is used inside TranslateTextService
to create complete pipeline. Moreover, in service, pipe model with queue name and input message is initiated:var pipeModel = new TranslateTextPipeModel
{
QueueName = queueName,
InMessage = message
};
TranslateTextFunction
TextApprovalFunction
TranslateTextService
. First function receives a message from “translate-text” service bus and at the end it puts a request for text approval on “approve-text-out” queue. With Azure Functions that return value, you can bind a function output binding to the return value. So if you want return value to be put on service bus, you have to specify following attribute:[return: ServiceBus("approve-text-out", Connection = "ServiceBus")]
IHostedService
interface to implement some background queue related tasks.IHostedService
interface, ServiceBusListener
for pipeline will be implemented. For each pipeline queue that delivers messages, message handler is going to be registered automatically. Thanks to that it's possible to define general flow for receiving messages and passing them into pipeline execution.OutServiceBusPipeStep
which will implement IOutQueuePipeStep
interface. Generic step implementation will contain three abstractions required to be overridden by the inheriting class:ServiceBusConnectionConfigKey
(property)OutQueueName
(property)CreateOutQueueMessage(TPipeModel pipeModel)
(function)ExecuteAsync
function from OutServiceBusPipeStep
will prepare message, create QueueClient
and based on the configuration passed through properties it will put a message on the queue.ServiceBusListenerBase<TPipeModel, TInQueueEnum>
class which implements IHostedService
interface. Implementing such interface it is required to implement following interface members:Task StartAsync(CancellationToken cancellationToken)
Task StopAsync(CancellationToken cancellationToken)
StartAsync
method will iterate through all queues that deliver messages for pipeline and for each and every queue, message handler will be registered. Message handler does nothing but receiving message, preparing pipe model, creating and executing pipeline.ServiceBusListenerBase
caught your attention?TranslateTextPipeInQueue
TranslateTextPipeOutQueue
TranslateTextPipeInQueue
, will be passed as TInQueueEnum
type into ServiceBusListenerBase
. Thanks to that, I’m able to iterate through its values and register message handler for defined queues.