我想使用Redis在我的服务堆栈服务上调用服务操作。ServiceStack Redis消息传递 - 即时消息?
我创建了一个简单的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();
})
);
我已经找到了问题的原因,这是我的IoC容器(Castle Windsor)正在使用动态Func在RedisMqServer上注入RequestFilter和ResponseFilter,目的是解析容器中的IMessage(使用TypedFactoryFacility时)。我不知道为什么我没有注册任何IMessage。我现在需要禁用委托工厂,这在Castle Windsor 3中显得很困难:http://stackoverflow.com/questions/19115475/remove-components-in-castle-windsor-3 – James
我想我可以绕过它添加一个Func到容器,它只是返回传递的消息,但这是一个糟糕的解决方法来移除DelegateFactory。 – James