activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: .Net consumer is not at all receiving message
Date Sat, 25 Mar 2017 22:59:42 GMT
On 03/24/2017 07:39 AM, Logeshwaran wrote:
> Hi,
> I am new to ActiveMQ. I am just trying examples which is given by ActiveMQ.
>
> Producer is working fine but consumer is not at all receiving message
>   
> Following is my code
>
> using Apache.NMS;
> using Apache.NMS.Util;
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using System.Threading.Tasks;
>
> namespace ConsoleApplication1
> {
>      class Program
>      {
>          static void Main(string[] args)
>          {
>              try
>              {
>                  Uri connecturi = new Uri("tcp://localhost:61616");
>
>                  Console.WriteLine("About to connect to " + connecturi);
>                  IConnectionFactory factory = new
> NMSConnectionFactory(connecturi);
>
>                  using (IConnection connection = factory.CreateConnection())
>                  using (ISession session = connection.CreateSession())
>                  {
>                     
>                      IDestination destination =
> SessionUtil.GetDestination(session, "TestExample");
>                      Console.WriteLine("Using destination: " + destination);
>
>                      // Create a consumer and producer
>
>                      using (IMessageProducer producer =
> session.CreateProducer(destination))
>                      using (IMessageConsumer consumer =
> session.CreateConsumer(destination))
>                      {
>                          // Start the connection so that messages will be
> processed.
>                          connection.Start();
>                            producer.DeliveryMode =
> MsgDeliveryMode.Persistent;
>                          // Send a message
>                          ITextMessage request =
> session.CreateTextMessage("Hello World!");
>                          request.NMSCorrelationID = "abc";
>                          request.Properties["NMSXGroupID"] = "cheese";
>                          request.Properties["myHeader"] = "Cheddar";
>                          producer.Send(request);
>                          // Consume a message
>                         ITextMessage message = consumer.Receive() as
> ITextMessage;
>                         if (message == null)
>                          {
>                              Console.WriteLine("No message received!");
>                          }
>                          else
>                          {
>                              Console.WriteLine("Received message with ID:   "
> + message.NMSMessageId);
>                              Console.WriteLine("Received message with text: "
> + message.Text);
>                          }
>                      }
>                  }
>              }
>              catch (Exception e)
>              {
>                  Console.WriteLine(e.Message);
>              }
>          }
>      }
> }
> <http://activemq.2283324.n4.nabble.com/file/n4724094/QueueStatus.png>
> <http://activemq.2283324.n4.nabble.com/file/n4724094/waitingForResponse.png>
>
> Thanks in advance
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Net-consumer-is-not-at-all-receiving-message-tp4724094.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Have you checked that there isn't another consumer listening on that 
Queue stealing your messages?

-- 
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/


Mime
View raw message