我可以向制作人发送消息到队列('test.queue')(另外我也可以收到相同的消息) 但我无法通过consumer.receive()方法接收来自回复目的地('confirm')的回复消息。 没有错误。但消费者没有收到任何消息。请让我离开它。 代码如下: -
class Program
{
private const String URI = "tcp://localhost:61616";
private const String DESTINATION = "test.queue";
static void Main(String[] args)
{
ConnectionFactory connectionFactory = new ConnectionFactory(URI);
connectionFactory.ClientId = connectionFactory.ClientIdGenerator.GenerateId(); ;
IMessageProducer prod;
String s = String.Empty;
while (s.ToLower() != "exit")
{
s = Console.ReadLine();
ISession ses = connectionFactory.CreateConnection().CreateSession();
prod = ses.CreateProducer();
IMessage msg=ses.CreateTextMessage(s);
NmsDestinationAccessor destinationResolver = new NmsDestinationAccessor();
IDestination destination = destinationResolver.ResolveDestinationName(ses, DESTINATION);
IDestination replyDestination = destinationResolver.ResolveDestinationName(ses, "confirm");
IMessageConsumer consumer = ses.CreateConsumer(replyDestination);
prod.Send(destination, msg);
IMessage im= consumer.Receive();
ses.Commit();
Console.WriteLine(im.ToString());
}
}
}
答案 0 :(得分:2)
我不是一名activeMQ专家,但我知道在大多数JMS实现中(我认为NMS几乎遵循1:1)你需要在你的连接上调用Start()以允许开始消费