Update: Did set my message listener before the start command and added
ackmode AutoAcknoweldge, but same result, stops after one message
slyfox wrote:
>
> Working fine in java but switched a client over to C#, producer worked,
> consumer works, just dies after 1 message:
>
> ##############################
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using System.Threading;
> using Apache.NMS;
> using Apache.NMS.ActiveMQ;
> using Apache.NMS.Util;
>
> namespace QuoteProvider
> {
> public class JMSQuoteProvider : IJMSQuoteSource
> {
> protected static AutoResetEvent semaphore = new
> AutoResetEvent(false);
> protected static ITextMessage message = null;
> protected static TimeSpan receiveTimeout =
> TimeSpan.FromSeconds(10);
>
> public event Action<IncomingQuote> QuoteArrived;
>
> public JMSQuoteProvider()
> {
> Thread JMSQuotes = new Thread(new ThreadStart(run));
> JMSQuotes.IsBackground = true;
> JMSQuotes.Priority = ThreadPriority.Normal;
> JMSQuotes.Start();
> }
>
> private void run()
> {
> Uri connecturi = new
> Uri("activemq:tcp://127.0.0.1:61616?consumer.dispatchAsync=true");
> IConnectionFactory factory = new
> NMSConnectionFactory(connecturi);
> using (IConnection connection = factory.CreateConnection())
> using (ISession session = connection.CreateSession())
> {
> IDestination destination = session.GetTopic("PX.UPDATE");
>
> using (IMessageConsumer consumer =
> session.CreateConsumer(destination))
> {
> connection.Start();
>
> consumer.Listener += new MessageListener(OnMessage);
>
> semaphore.WaitOne();
> if (message != null)
> {
> crack(message.Text.ToString());
> }
>
> }
> }
> }
>
> private void crack(String msg)
> {
> // crack logic //
>
> IncomingQuote tempQuote = new IncomingQuote(symbol, bid, ask,
> stamp);
> QuoteArrived(tempQuote);
> }
>
> protected static void OnMessage(IMessage receivedMsg)
> {
> message = receivedMsg as ITextMessage;
> semaphore.Set();
> }
>
> #region IJMSQuoteSource Members
>
> protected virtual void OnQuoteArrived(IncomingQuote quote)
> {
> if (QuoteArrived != null)
> QuoteArrived(quote);
> }
>
> #endregion
>
> }
> }
>
>
>
--
View this message in context:
http://old.nabble.com/My-NMS-topic-consumer-dies-after-1-message-tp27349478p27350879.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.