<font face="trebuchet ms,sans-serif">Putting back the list.<br></font><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><br></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif">Any chance to have a proper stack trace of the exception?</font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><br></font><div class="gmail_quote">On Tue, Jul 5, 2011 at 23:46, Demiss Zike <span dir="ltr"><<a href="mailto:habtdemis@gmail.com">habtdemis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">My bad, please ignore my last response. It compiles well but gives me the following run time error:<div><br></div><div>
Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'RabbitMQ.Events.BasicDeliverEventArgs' to type 'System[]'.</div><div><div></div><div class="h5">
<div><br><div><br></div><div><br><br><div class="gmail_quote">On Tue, Jul 5, 2011 at 4:35 PM, Demiss Zike <span dir="ltr"><<a href="mailto:habtdemis@gmail.com" target="_blank">habtdemis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It does and take in a byte[] and initializes a Measurement object.<div><div></div><div><br><br><div class="gmail_quote">On Tue, Jul 5, 2011 at 4:18 PM, Simone Busoli <span dir="ltr"><<a href="mailto:simone.busoli@gmail.com" target="_blank">simone.busoli@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font face="trebuchet ms,sans-serif">Doesn't m2 in your code below contain the deserialized message?<br></font><br>
<div class="gmail_quote"><div><div></div><div>On Tue, Jul 5, 2011 at 23:15, Demiss Zike <span dir="ltr"><<a href="mailto:habtdemis@gmail.com" target="_blank">habtdemis@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>Hello,<div><br></div><div>I'm using c#. I have a serializable class called Measurement and want to send an object of it. I serialized an object of Measurement and captured the serialized object as byte[] and published it. My question is how can I capture the published message (so that I can deserialize and use it)? </div>
<div><br></div><div>I've included codes on both ends:</div><div><br></div><div><div>public void publish(byte[] _serializedMsg)</div><div>{</div><div><span style="white-space:pre-wrap">                </span>// publisher code</div>
<div><span style="white-space:pre-wrap">        </span> ConnectionFactory factory = new ConnectionFactory();</div><div> factory.HostName = "localhost";<span style="white-space:pre-wrap">        </span></div>
<div><span style="white-space:pre-wrap">                </span></div><div> using (IConnection connection = factory.CreateConnection())</div><div> using (IModel channel = connection.CreateModel()) {</div>
<div> channel.ExchangeDeclare("logs", "fanout");</div><div><span style="white-space:pre-wrap">                        </span></div><div> channel.BasicPublish("logs", queue, null, _serializedMsg);</div>
<div> Console.WriteLine(" Message sent ");</div><div> }</div><div>}</div></div><div><br></div><div><br></div><div><br></div><div><div>public void subscribe(string queue)</div><div><span style="white-space:pre-wrap">        </span>{</div>
<div><span style="white-space:pre-wrap">                </span>// subscriber code</div><div><span style="white-space:pre-wrap">                </span>ConnectionFactory factory = new ConnectionFactory();</div><div>
factory.HostName = "localhost";</div><div> using (IConnection connection = factory.CreateConnection())</div><div> using (IModel channel = connection.CreateModel()) {</div><div>
channel.ExchangeDeclare("logs", "fanout");</div>
<div><br></div><div><span style="white-space:pre-wrap">        </span> string queue1 = channel.QueueDeclare();</div><div><span style="white-space:pre-wrap">                        </span></div><div> channel.QueueBind(queue1, "logs", "");</div>
<div> QueueingBasicConsumer consumer = new QueueingBasicConsumer(channel);</div><div> channel.BasicConsume(queue1, true, consumer);</div><div><br></div><div> Console.WriteLine(" Waiting for messages. To exit press CTRL+C");</div>
<div> while(true) {</div><div> BasicDeliverEventArgs ea =</div><div> (BasicDeliverEventArgs)consumer.Queue.Dequeue();</div><div><span style="white-space:pre-wrap">                </span></div>
<div> byte[] body = ea.Body;</div><div><span style="white-space:pre-wrap">                                </span></div><div><span style="white-space:pre-wrap">                </span>Measurement m2 = new Measurement(20, 23323, 3.3);</div>
<div><span style="white-space:pre-wrap">                </span>m2 = BinarySerialization.BinaryDeSerialize( body );</div><div><span style="white-space:pre-wrap">                </span> </div><div> Console.WriteLine(" Message received: ");</div>
<div><span style="white-space:pre-wrap">                                </span>Console.WriteLine("\nMeasurement ID: {0}", <a href="http://m2.id" target="_blank">m2.id</a>);</div><div><span style="white-space:pre-wrap">                                </span>Console.WriteLine("Measurement Time: {0}", m2.time);</div>
<div><span style="white-space:pre-wrap">                                </span>Console.WriteLine("Measurement Value: {0}", m2.value);</div><div> }</div><div> }</div><div>}<span style="white-space:pre-wrap">        </span></div>
</div><div><br></div><div><br></div><div>Thanks!</div><div>Demi</div><div><br></div><div><br></div><div><br></div><div><br></div>
<br></div></div>_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br></blockquote></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>
</div></div>
</div></div></blockquote></div><br></div>