public async Task StartListening(Func <EventMessage, Task> onMessageCallback) { _subscriberEventMessage = MakeSubscriberEventMessage(MessageBrokerSettings.MessageBrokerType); await _subscriberEventMessage.Initialize(MessageBrokerSettings.MessageBrokerConnectionString, EventMessageTopicName, EventMessageQueueName + "." + Environment.MachineName); _subscriberEventMessage.Subscribe(OnEventMessageReceived, onMessageCallback); }
private async Task OnEventMessageReceived(SubscriberBase subscriberEventMessage, MessageReceivedEventArgs messageReceivedEventArgs, Func <EventMessage, Task> onMessageCallback) { var message = messageReceivedEventArgs.Message; var eventMessage = MessageProcessor.DeserializeMessage(message); await onMessageCallback(eventMessage); await subscriberEventMessage.Acknowledge(messageReceivedEventArgs.AcknowledgeToken); }