<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
code
        {font-family:"Courier New";}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Hi,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>I&#8217;ve just started to look at RabbitMQ. I&#8217;m
wondering whether the following would be an idiomatic use of RabbitMQ from the
.NET API:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
color="#2b91af" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#2B91AF'>Routing</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>.Listen(<font
color="#a31515"><span style='color:#A31515'>&quot;queue1&quot;</span></font>, <font
color="#a31515"><span style='color:#A31515'>&quot;#&quot;</span></font>, <font
color=blue><span style='color:blue'>new</span></font> <font color="#2b91af"><span
style='color:#2B91AF'>ConsoleAlert</span></font>());<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
color="#2b91af" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#2B91AF'>Routing</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>.Listen(<font
color="#a31515"><span style='color:#A31515'>&quot;queue1&quot;</span></font>, <font
color="#a31515"><span style='color:#A31515'>&quot;news.#&quot;</span></font>, <font
color=blue><span style='color:blue'>new</span></font> <font color="#2b91af"><span
style='color:#2B91AF'>EmailAlert</span></font>());<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in'><font size=2 color="#2b91af"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#2B91AF'>Routing</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>.Listen(<font color="#a31515"><span
style='color:#A31515'>&quot;queue2&quot;</span></font>, <font color="#a31515"><span
style='color:#A31515'>&quot;email.#&quot;</span></font>, <font color=blue><span
style='color:blue'>new</span></font> <font color="#2b91af"><span
style='color:#2B91AF'>ConsoleAlert</span></font>());<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Each call to Listen sets up a thread where the
connection and channel are maintained. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>public</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>static</span></font> <font color=blue><span
style='color:blue'>void</span></font> Listen(<font color=blue><span
style='color:blue'>string</span></font> queue, <font color=blue><span
style='color:blue'>string</span></font> routing, <font color="#2b91af"><span
style='color:#2B91AF'>IRabbitListener</span></font> alert)<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
color="#2b91af" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#2B91AF'>ThreadPool</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>.QueueUserWorkItem(RunThis,
<font color=blue><span style='color:blue'>new</span></font> <font
color="#2b91af"><span style='color:#2B91AF'>AlertState</span></font>(queue,
routing, alert));<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>private</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>static</span></font> <font color=blue><span
style='color:blue'>void</span></font> RunThis(<font color=blue><span
style='color:blue'>object</span></font> state)<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
color=blue face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>var</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> alertState = state <font
color=blue><span style='color:blue'>as</span></font> <font color="#2b91af"><span
style='color:#2B91AF'>AlertState</span></font>;<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=blue><span style='color:blue'>using</span></font> (<font
color="#2b91af"><span style='color:#2B91AF'>IConnection</span></font> conn = <font
color=blue><span style='color:blue'>new</span></font> <font color="#2b91af"><span
style='color:#2B91AF'>ConnectionFactory</span></font>().CreateConnection(<font
color="#a31515"><span style='color:#A31515'>&quot;localhost&quot;</span></font>))<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color=blue><span style='color:blue'>using</span></font>
(<font color="#2b91af"><span style='color:#2B91AF'>IModel</span></font> channel
= conn.CreateModel())<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=blue><span style='color:blue'>var</span></font> sub = <font
color=blue><span style='color:blue'>new</span></font> <font color="#2b91af"><span
style='color:#2B91AF'>Subscription</span></font>(channel, alertState.Queue, <font
color="#a31515"><span style='color:#A31515'>&quot;topic&quot;</span></font>,
alertState.Routing);<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=blue><span style='color:blue'>foreach</span></font> (<font
color="#2b91af"><span style='color:#2B91AF'>BasicDeliverEventArgs</span></font>
e <font color=blue><span style='color:blue'>in</span></font> sub)<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:1.0in;text-indent:.5in;text-autospace:
none'><font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New"'>{<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
alertState.Alert.OnMessage(e.Exchange, e.RoutingKey, <font color="#2b91af"><span
style='color:#2B91AF'>Encoding</span></font>.UTF8.GetString(e.Body));<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sub.Ack(e);<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Given that .NET processes are more heavy weight than
erlang&#8217;s is this the preferred way to set up many clients? <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Have I missed something in the .NET API for handling
this type of case?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Thanks,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Sam<o:p></o:p></span></font></p>

</div>

<!--[object_id=#SID=010500000000000515000000677f29c6df91f4655643ca63e4060000#]--><FONT face=Tahoma size=2><FONT color=#0000ff>
<P><FONT face="Times New Roman" color=#000000 size=1></FONT>&nbsp;</P>
<P><FONT face=a color=#000000 size=1>The information transmitted is the property of Gazprom Marketing &amp; Trading Ltd and is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Statements and opinions expressed in this e-mail may not represent those of the company. Any review, retransmission, dissemination and other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer. </FONT></P>
<P><FONT face=a color=#000000 size=1>Registered office: Gazprom Marketing &amp; Trading Ltd, Gazprom House, <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:address w:st="on"><st1:Street w:st="on">60 Marina Place</st1:Street>, <st1:City w:st="on">Hampton</st1:City></st1:address> Wick, <st1:City w:st="on">Kingston</st1:City> upon <st1:place w:st="on"><st1:City w:st="on">Thames</st1:City>, <st1:PostalCode w:st="on">KT1 4BH</st1:PostalCode></st1:place>. Registered in <st1:place w:st="on"><st1:country-region w:st="on">England</st1:country-region></st1:place> No. 3768267</FONT></P></FONT></FONT></body>

</html>