Question

I would like to use Redis to invoke a service operation on my Service Stack service.

I have created a simple DTO as the message request, and am registering the message service as per the demo pages:

        var messageService = m_Container.Resolve<RedisMqServer>();
        messageService.RegisterHandler<SubscribeAddressRequest>(x => ServiceController.ExecuteMessage(x) );
        messageService.Start();

ServiceStack actually receives these messages, but I get the following error (from my Container):

No component for supporting the service ServiceStack.Messaging.IMessage was found.

This is very odd, why is ServiceStack asking for a dependency to be injected as an IMessage? I have not registered any providers for an IMessage so I understand that this would fail, but I do not see any providers. I am registering the following types:

        string[] RedisHosts = new string[] { (string)ConfigurationManager.AppSettings["RedisHost"] };
        container.Register(
            Component.For<IRedisClientsManager>().ImplementedBy<PooledRedisClientManager>().DependsOn(new { poolSize = 1000, poolTimeOutSeconds = 1, readWriteHosts = RedisHosts }),
            Component.For<RedisMqServer>(),
            Component.For<IMessageQueueClient>().UsingFactoryMethod((k, c) =>
            {
                return k.Resolve<RedisMqServer>().CreateMessageQueueClient();
            })
        );
Was it helpful?

Solution 2

I have found the cause of the issue, which is that my IoC Container (Castle Windsor) is injecting the RequestFilter and ResponseFilter on a RedisMqServer with a dynamic Func with the aim of resolving an IMessage from the container (when using TypedFactoryFacility).

This is because of the delegate-factory which is part of the TypedFactoryFacility (I usually use interface-factories).

I got round this by disabling the automatic enabling of the Castle Windsor delegate-factory when using the Typed Factory Facility:

Remove components in Castle Windsor 3

OTHER TIPS

It looks like this is an issue with the Container you're using, I'm not sure why it's asking for this, it may have something to do with your IOC's auto bootstrap scanning process, but it's not something you'd want resolved from the IOC. To help with the investigation, the type in the RegisterHandler callback is of IMessage<T>, e.g:

messageService.RegisterHandler<SubscribeAddressRequest>(x // <- IMessage<T>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top