No customer received the message

Viewed 100

I am making a notification microservice for users. It is impossible to use the SignalR built into MassTransit due to the built-in microservice architecture. After accepting messages from the queue RabbitMq, it is called StartAsync:

public class MassTransitManager : IMassTransitManager
{
        public MassTransitManager(Func<string, Task<string>> processDelegateAsync)
        {
            ProcessDelegateAsync = processDelegateAsync;
        }

        public Func<string, Task<string>> ProcessDelegateAsync { get; set; }

        public async Task<string> StartAsync(string requestString)
        {
            string response;
            try
            {
                response = await ProcessMessageAsync(requestString);
            }
            catch (Exception exception)
            {
                response = exception.ToString();
            }

            return response;
        }

        private async Task<string> ProcessMessageAsync(string requestString)
        {
            if (ProcessDelegateAsync == null)
                throw new InvalidOperationException($"Not found delegate {nameof(ProcessDelegateAsync)}.");

            var result = await ProcessDelegateAsync(requestString);
            return result;
        }
}

MassTransitManager is in Class Library. Delegate created in Startup:

services.AddSingleton<IMassTransitManager, MassTransitManager>(provider =>
            {
                return new MassTransitManager(async serializedMessage =>
                {
                    var hubContext = provider.GetRequiredService<IHubContext<NoticeHub>>();

                    await hubContext.Clients.All.SendAsync("SendResponse", "Hi all.");

                    return "Hi man";
                });
            });

But no client receives this message. What can be the ways to solve this problem?

0 Answers
Related