You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Logeshwaran <lo...@msystechnologies.com> on 2017/03/24 11:39:47 UTC
.Net consumer is not at all receiving message
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.
Re: .Net consumer is not at all receiving message
Posted by Clebert Suconic <cl...@gmail.com>.
61616 is an Artemis port. Can u try a build from master if it's Artemis ?
On Sat, Mar 25, 2017 at 6:59 PM Timothy Bish <ta...@gmail.com> wrote:
> 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/
>
> --
Clebert Suconic
Re: .Net consumer is not at all receiving message
Posted by Timothy Bish <ta...@gmail.com>.
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/