문제

We are using InMemoryTransientMessageService to chain several one-way notification between services. We can not use Redis provider, and we do not really need it so far. Synchronous dispatching is enough.

We are experimenting problems when using a publish inside a service that is handling another publish. In pseudo-code:

FirstService.Method() _messageQueueClient.Publish(obj);

SecondService.Any(obj) _messageQueueClient.Publish(obj);

ThirdService.Any(obj)

The SecondMessage is never handled. In the following code of ServiceStack TransientMessageServiceBase, when the second message is processed, the service "isRunning" so it does not try to handled the second:

public virtual void Start()
    {
        if (isRunning) return;
        isRunning = true;

        this.messageHandlers = this.handlerMap.Values.ToList().ConvertAll(
            x => x.CreateMessageHandler()).ToArray();

        using (var mqClient = MessageFactory.CreateMessageQueueClient())
        {
            foreach (var handler in messageHandlers)
            {
                handler.Process(mqClient);
            }
        }

        this.Stop();
    }

I'm not sure about the impact of changing this behaviour in order to be able to nest/chain message publications. Do you think it is safe to remove this check? Some other ideas?

도움이 되었습니까?

해결책

After some tests, it seems there is no problem in removing the "isRunning" control. All nested publications are executed correctly.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top