我想使用Redis来调用service服务上的服务操作。
我创建了一个简单的DTO作为消息请求,并按照演示页面注册消息服务:
var messageService = m_Container.Resolve<RedisMqServer>();
messageService.RegisterHandler<SubscribeAddressRequest>(x => ServiceController.ExecuteMessage(x) );
messageService.Start();ServiceStack实际上接收到了这些消息,但我得到了以下错误(来自容器):
No component for supporting the service ServiceStack.Messaging.IMessage was found.这很奇怪,为什么ServiceStack要求将依赖项作为IMessage注入?我没有为IMessage注册任何提供者,所以我知道这会失败,但是我没有看到任何提供者。我正在登记下列类型:
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();
})
);发布于 2013-10-01 13:41:12
我发现了问题的原因,这是因为我的IoC容器(Castle )使用动态函数将RequestFilter和ResponseFilter注入到RedisMqServer上,目的是从容器中解析IMessage (当使用TypedFactoryFacility时)。
这是因为委托工厂是TypedFactoryFacility的一部分(我通常使用接口工厂)。
为此,我在使用类型化工厂设施时禁用了Castle委托工厂的自动启用功能:
发布于 2013-09-27 16:49:48
看起来这是你正在使用的容器的一个问题,我不知道它为什么要这样做,它可能与国际奥委会的自动引导扫描过程有关,但它不是你想要从国际奥委会解决的问题。为了帮助调查,RegisterHandler回调中的类型为IMessage<T>,例如:
messageService.RegisterHandler<SubscribeAddressRequest>(x // <- IMessage<T>https://stackoverflow.com/questions/19053334
复制相似问题