You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Chenyuancun <ch...@hotmail.com> on 2013/01/20 14:18:00 UTC
Re: Browsing sent messages on a topic as RSS
Date: Sun, 20 Jan 2013 04:55:22 -0800 (PST)
From: wonderland <po...@126.com>
To: users@activemq.apache.org
Message-ID: <13...@n4.nabble.com>
In-Reply-To:
<13...@n4.nabble.com>
References:
<13...@n4.nabble.com>
Subject:
Re: Browsing sent messages on a topic as RSS
MIME-Version:
1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding:
7bit
X-SA-Exim-Connect-IP: 192.168.236.139
X-SA-Exim-Mail-From: powerwonderland@126.com
X-SA-Exim-Scanned: No (on
joe.nabble.com); SAEximRunCond expanded to false
hi,
I see you
question,perhaps you can help me the problem I meet. I have
some problem when
I want to use ActiveMQ on ASP.NET project.
I have sucessful using
Apache.NMS and Apache.NMS.ActiveMQ in C#Form
project;but when I want to use
ActiveMQ on webapplicaiton/ASP.NET projcet, I
meet a problem.
Webapplicaiton receives message from ActiveMQ's producer,but it doesn't
work.
When program run the ' ITextMessage msg = (ITextMessage)message;'
throws an
exception; what's wrong? I couldn't find out the problem because I
am a green
hand.
I want to ActiveMQ's producer exchange message with
web
server(webapplication/ASP.NET web server),and web client get the
message
from web server. so I use ActiveMQ in Webapplication just as in
C#Form
application.
I would appreciate any advice that you could give
me.
using System;
using System.Collections.Generic;
using
System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebControls;
using Apache.NMS;
using
Apache.NMS.ActiveMQ;
namespace WebActiveMQ
{
public partial
class _Default : Page
{
private MQ m_mq;
private IMessageConsumer m_consumer;
private delegate void
ShowNoteMsgDelegate(string msg);
private void
consumer_listener(IMessage message)
{
string
strMsg;
try
{
Label.Text =
"1";
ITextMessage msg =
(ITextMessage)message;
Label.Text = "2";
Label.Text = msg.Text;
strMsg = msg.Text;
ShowMessage(strMsg);
}
catch (System.Exception
ex)
{
m_consumer.Close();
}
}
private void ShowMessage(string msg)
{
string strText = "[" +
DateTime.Now.ToString("yyyy/MM/dd
HH:mm:ss.fff") + "]:" + msg + "\r\n" +
TextBox.Text;
if (strText.Length > 10000)
{
TextBox.Text = strText.Substring(0, 10000);
}
else
{
TextBox.Text =
strText;
}
}
protected void
Page_Load(object sender, EventArgs e)
{
try
{
m_mq = new MQ();
m_mq.uri = "tcp://127.0.0.1:61616/";
m_mq.Start();
}
catch (System.Exception
ex)
{
}
m_consumer =
m_mq.CreateConsumer(true, "Hello,World");
m_consumer.Listener += new MessageListener(consumer_listener);
}
}
}