activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ttn_amn <ttn_...@yahoo.com>
Subject Re: I can't send/receive message from Topic
Date Fri, 20 Apr 2007 11:04:28 GMT



James.Strachan wrote:
> 
> On 4/20/07, ttn_amn <ttn_amn@yahoo.com> wrote:
>>
>> I send message to topic when I monitor at Jconsole "QueueSize=0" but
>> "EnqueueCount=1". Message is returned from consumer.receive() is null
>> Please help me.
> 
> Could you show us your code?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

This is my code
Method Send
public string SendTextToTopic(string msg, string topic, string source, byte
priority)
        {
            string status = null;
            destination = null;
            producer = null;
            textMessage = null;
            try
            {
                //parameters are properties of message
                textMessage = CreateText(msg, source, MessageType.Text,
priority);
                destination = session.GetTopic(topic);
                producer = session.CreateProducer(destination);
                producer.Send(textMessage);
                NmsUtils.CloseMessageProducer(producer);
            }
            catch(Exception e)
            {
                return status = e.ToString();
            }

            return status;
        }

Method Receive
        public string ReceiveFromTopic(string topic, TimeSpan timeout)
        {
            string status = null;
            consumer = null;
            destination = null;
            textMessage = null;
            try
            {
                destination = session.GetTopic(topic);
                consumer = session.CreateConsumer(destination);
                IMessage m = consumer.Receive(timeout);
                textMessage = m as ITextMessage;
                Console.Write(textMessage.Text);
                NmsUtils.CloseMessageConsumer(consumer);
            }
            catch(NMSException e)
            {
                return status = e.ToString();
            }
            return status = "success";
        }

-- 
View this message in context: http://www.nabble.com/I-can%27t-send-receive-message-from-Topic-tf3611734s2354.html#a10097716
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message