我想使用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