Redis ServiceStack MessageFactory发布
我已经在这里查看了ServiceStack消息与Redis文档: 它似乎很好地解释了基本原理。但我不太明白的是,通过MessageFactory发布时的差异和适用的用例:Redis ServiceStack MessageFactory发布,redis,messaging,servicestack,Redis,Messaging,servicestack,我已经在这里查看了ServiceStack消息与Redis文档: 它似乎很好地解释了基本原理。但我不太明白的是,通过MessageFactory发布时的差异和适用的用例: .CreateMessageProducer.Publish() 及 我计划查看代码,但想在此发布“官方”解释。以下是IMessageProducer和IMessageQueueClient的API: public interface IMessageProducer : IDisposable { void Pu
.CreateMessageProducer.Publish()
及
我计划查看代码,但想在此发布“官方”解释。以下是
IMessageProducer
和IMessageQueueClient
的API:
public interface IMessageProducer : IDisposable
{
void Publish<T>(T messageBody);
void Publish<T>(IMessage<T> message);
}
public interface IMessageQueueClient : IMessageProducer
{
void Publish(string queueName, byte[] messageBytes);
void Notify(string queueName, byte[] messageBytes);
byte[] Get(string queueName, TimeSpan? timeOut);
byte[] GetAsync(string queueName);
string WaitForNotifyOnAny(params string[] channelNames);
}
公共接口IMessageProducer:IDisposable
{
无效发布(T messageBody);
无效发布(IMessage消息);
}
公共接口IMessageQueueClient:IMessageProducer
{
无效发布(字符串queueName,字节[]messageBytes);
void Notify(字符串queueName,字节[]messageBytes);
字节[]Get(字符串queueName,TimeSpan?timeOut);
字节[]GetAsync(字符串queueName);
字符串WaitForNotifyOnAny(参数字符串[]信道名称);
}
基本上,MessageQueueClient
也是MessageProducer
,但除了发布到从队列中获取消息以及发布和订阅任何MQ主题之外,还包含其他细粒度方法
消息客户端和生产者上键入的
Publish
API具有相同的行为。感谢@mythz的解释。不确定这是否值得提出另一个SO问题,但IMessageProducer/IMessageFactory是否打算扩展以支持其他类型的发布者(如SignalR)?考虑将消息转发到其他消息传递系统的特定SS消息处理程序,该处理程序不需要考虑某些发布机制(例如连接性、IoC分辨率)。或者,您推荐另一种方法吗?ServiceStack的IMessageService API的设计是为了实现不可知性,但它们适用于RabbitMQ/MSMQ或更新的ServiceBus提供商等MQ代理。我认为信号器提供商在这里并不完美,我只会将信号器集成视为另一种IDependency
,并让您的服务明确发布到这一点。
public interface IMessageProducer : IDisposable
{
void Publish<T>(T messageBody);
void Publish<T>(IMessage<T> message);
}
public interface IMessageQueueClient : IMessageProducer
{
void Publish(string queueName, byte[] messageBytes);
void Notify(string queueName, byte[] messageBytes);
byte[] Get(string queueName, TimeSpan? timeOut);
byte[] GetAsync(string queueName);
string WaitForNotifyOnAny(params string[] channelNames);
}