You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ttn_amn <tt...@yahoo.com> on 2007/04/20 10:06:22 UTC

I can't send/receive message from Topic

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.
-- 
View this message in context: http://www.nabble.com/I-can%27t-send-receive-message-from-Topic-tf3611734s2354.html#a10093001
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: I can't send/receive message from Topic

Posted by ttn_amn <tt...@yahoo.com>.


James.Strachan wrote:
> 
> On 4/20/07, ttn_amn <tt...@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.


Re: I can't send/receive message from Topic

Posted by James Strachan <ja...@gmail.com>.
On 4/20/07, ttn_amn <tt...@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/