我可以使用生产者将消息发送到队列('test.queue')(我也可以在另一端收到相同的消息)但是我无法使用消费者.receive()从回复目的地('确认')接收回复消息方法。没有错误。但消费者没有收到任何消息。请让我摆脱它。代码如下: -
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());
}
}
}