将EasyNetQ作为我们当前MQ通信库的替代品.
对于测试我试图简单地使用自定义命名策略将大量消息发布到交换.我的发布方法是下面的小测试方法>
public void PublishTest()
{
var advancedBus = RabbitHutch.CreateBus("host=localhost;virtualHost=Test;username=guest;password=guest;").Advanced;
var routingKey = "SimpleMessage";
// declare some objects
var queue = advancedBus.QueueDeclare("Q.TestQueue.SimpleMessage");
var exchange = advancedBus.ExchangeDeclare("E.TestExchange.SimpleMessage", ExchangeType.Direct);
var binding = advancedBus.Bind(exchange, queue, routingKey);
var message = new SimpleMessage() {Test = "HELLO"};
for (int i = 0; i < 100; i++)
{
advancedBus.Publish(exchange, routingKey, true, true, new Message<SimpleMessage>(message));
}
advancedBus.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
问题是即使你创建了Exchange和队列,并且绑定得当,发布也不会产生任何结果.没有消息到达队列.Rabbit MQ管理界面中的图形甚至不显示交换上的任何活动.我错过了什么吗?代码基本上直接来自文档.
如果即时通讯使用简单的总线,只是发布,就会创建一个交换,我可以通过管理界面看到正在发布的消息.由于简单总线使用高级API发布我认为这是一个我缺少的设置问题.
我希望有人能带来一些见解:-)
/托马斯
我正在尝试使用 Moq 来模拟代表,但到目前为止我所做的一切都是徒劳的。我做了一个小例子来说明如何设置:
1.代理类正在抽象WCF服务
public interface IServiceProxy
{
void FooService(ServiceProxy.FooServiceDelegate service);
}
public class ServiceProxy : IServiceProxy
{
private readonly EndpointAddress _fooServiceEndpoint;
public ServiceProxy(IConfiguration configuration)
{
_fooServiceEndpoint = new EndpointAddress(new Uri(configuration.WcfServiceEndpoint));
}
public delegate void FooServiceDelegate(IFooBar proxy);
public void FooService(FooServiceDelegate service)
{
Do<IFooBar>((service.Invoke), _fooServiceEndpoint);
}
private void Do<T>(UseServiceDelegate<T> f, EndpointAddress address)
{
UsingService<T>.Use(f.Invoke, address);
}
}
Run Code Online (Sandbox Code Playgroud)
2.服务定义
/// <summary>
/// This is the interface the WCF service exposes
/// </summary>
public interface IFooBar
{
string Hello(string name);
}
Run Code Online (Sandbox Code Playgroud)
3.以及使用代理的类
public …
Run Code Online (Sandbox Code Playgroud)