[rabbitmq-discuss] able to get Msg in debug line but Cannot Get it to Asp.net Page

tamer hatoum tamer84hatoum at gmail.com
Sat Jun 28 07:23:05 BST 2014



I am using RabbitMQ to get real time data. I make the connection and am 
getting data successfully. I am able to print it in the Debug line, but its 
not updating my Label.

here is my code:

private void InitRabbit(){

    factory.UserName = this.user;
    factory.Password = this.password;
    factory.HostName = this.host;
    factory.VirtualHost = "/";

    try
    {
        using (IConnection connection = factory.CreateConnection())
        {
            using (IModel channel = connection.CreateModel())
            {
                channel.ExchangeDeclare(realTimeExchange, "topic");
                string queueName = channel.QueueDeclare();
                StringBuilder sb = new StringBuilder();
                sb.Append("QEH").Append(".").Append("QEH").Append(".*");
                channel.QueueBind(queueName, realTimeExchange, sb.ToString());
                Console.WriteLine("Waiting for messages");
                QueueingBasicConsumer consumer = new QueueingBasicConsumer(channel);
                channel.BasicConsume(queueName, true, consumer);
                while (true)
                {
                    BasicDeliverEventArgs e = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
                    Console.WriteLine(Encoding.ASCII.GetString(e.Body));
                    string msg = Encoding.ASCII.GetString(e.Body);
                    JavaScriptSerializer ser = new JavaScriptSerializer();
                    Alerts alert = ser.Deserialize<Alerts>(msg);
                    updatealert(alert); //for getting the Alerts which is my internal class
                }
            }
            rabbitrunning = true;
        }
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine("Rabbit not running : " + ex.Message);
    }}

Here is my updatealert function:

private void updatealert(Alerts alert){
    alertext.Text = "Count " + alert.CarName;
    System.Diagnostics.Debug.WriteLine("publish : " + alert.CarName);//its writting the message correctly but its not updating my Alertext label. }

Here is the update panel structure:

<asp:ScriptManager ID="ScriptManager1"  runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
    <ContentTemplate>
        <legend>UpdatePanel</legend>
         <asp:Label ID="alertext" runat="server" Text="change" ></asp:Label>
         <asp:Label ID="Label1" runat="server" Text="change" ></asp:Label>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
    </Triggers></asp:UpdatePanel><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Get Real Data" />

How do I change the label text while rabbitMQ is updating the content?

*UPDATES : After Long Trail and error I found that the rabbit is sending a 
lot of messages per second so the Update panel is not updating fast , so I 
tried to put the Update panel job in other thread but I have not succeeded 
, is there any advice how to update the panel with handling very fast 
process ?*

Regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140627/3e9b2602/attachment.html>


More information about the rabbitmq-discuss mailing list