2

I could send messages to Queue('test.queue') with the producer(Also i could recieve the same at the other end) But i could not recieve reply msg from reply destination('confirm') with the consumer.receive() method. No error.but consumer does not recieve any msg.Please get me out of it. Code has been given below:-

    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());
        }
    }
}
Tamilmaran
  • 1,257
  • 1
  • 10
  • 21

1 Answers1

2

Im not a activeMQ specialist but I know in most JMS implementations (which I think NMS pretty much follows 1:1) you need to call Start() on your connection to allow consuming to begin

Fen
  • 933
  • 5
  • 13
  • This is correct, without a call to start() on the Connection a consumer will not receive any messages. – Tim Bish Apr 19 '12 at 20:42