<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Times New Roman";}
h1
        {margin-top:17.0pt;
        margin-right:0cm;
        margin-bottom:16.5pt;
        margin-left:0cm;
        text-align:justify;
        text-justify:inter-ideograph;
        text-indent:0cm;
        line-height:240%;
        page-break-after:avoid;
        mso-list:l0 level1 lfo4;
        font-size:22.0pt;
        font-family:"Times New Roman";}
h3
        {margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        text-indent:0cm;
        line-height:12.0pt;
        page-break-after:avoid;
        mso-list:l0 level3 lfo4;
        font-size:10.0pt;
        font-family:Arial;
        font-weight:normal;}
h5
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        mso-para-margin-top:12.0pt;
        mso-para-margin-right:1.0gd;
        mso-para-margin-bottom:3.0pt;
        mso-para-margin-left:0cm;
        text-indent:0cm;
        line-height:12.0pt;
        mso-list:l0 level5 lfo4;
        font-size:11.0pt;
        font-family:"Times New Roman";
        font-weight:normal;}
p.MsoHeading7, li.MsoHeading7, div.MsoHeading7
        {margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:3.2pt;
        margin-left:0cm;
        text-align:justify;
        text-justify:inter-ideograph;
        text-indent:0cm;
        line-height:133%;
        page-break-after:avoid;
        mso-list:l0 level7 lfo4;
        font-size:12.0pt;
        font-family:"Times New Roman";
        font-weight:bold;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:9.0pt;
        font-family:宋体;}
p.heading7, li.heading7, div.heading7
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:20.0pt;
        margin-bottom:.0001pt;
        mso-para-margin-top:0cm;
        mso-para-margin-right:1.0gd;
        mso-para-margin-bottom:0cm;
        mso-para-margin-left:1.0gd;
        mso-para-margin-bottom:.0001pt;
        line-height:12.0pt;
        font-size:10.0pt;
        font-family:"Times New Roman";}
p.StyleHeading7Right1ch, li.StyleHeading7Right1ch, div.StyleHeading7Right1ch
        {margin-top:12.0pt;
        margin-right:10.0pt;
        margin-bottom:3.0pt;
        margin-left:0cm;
        mso-para-margin-top:12.0pt;
        mso-para-margin-right:1.0gd;
        mso-para-margin-bottom:3.0pt;
        mso-para-margin-left:0cm;
        text-indent:0cm;
        line-height:12.0pt;
        mso-list:l0 level7 lfo4;
        font-size:10.0pt;
        font-family:"Times New Roman";}
p.StyleHeading3TimesNewRomanBoldNotItalic, li.StyleHeading3TimesNewRomanBoldNotItalic, div.StyleHeading3TimesNewRomanBoldNotItalic
        {margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:3.0pt;
        margin-left:0cm;
        text-indent:0cm;
        line-height:12.0pt;
        page-break-after:avoid;
        mso-list:l0 level3 lfo4;
        font-size:10.0pt;
        font-family:Arial;
        font-weight:bold;}
/* Page Definitions */
@page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 126.65pt 72.0pt 126.65pt;
        layout-grid:15.6pt;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:-5;
        mso-list-template-ids:1262271446;}
@list l0:level1
        {mso-level-style-link:"Heading 1";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level2
        {mso-level-text:"%1\.%2";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level3
        {mso-level-style-link:"Heading 3";
        mso-level-text:"%1\.%2\.%3";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level4
        {mso-level-text:"%1\.%2\.%3\.%4";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level5
        {mso-level-style-link:"Heading 5";
        mso-level-text:"%1\.%2\.%3\.%4\.%5";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level6
        {mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level7
        {mso-level-style-link:"Heading 7";
        mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.%7";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level8
        {mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.%7\.%8";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
@list l0:level9
        {mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.%7\.%8\.%9";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        mso-level-legacy:yes;
        mso-level-legacy-indent:0cm;
        mso-level-legacy-space:7.2pt;
        margin-left:0cm;
        text-indent:0cm;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
</head>
<body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'>
<div class=Section1 style='layout-grid:15.6pt'>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>Hi Matthias,<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>I declare exchange and queue are durable, and met all what you said. Now
I post my code lines to below, <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>and the attachment is the wrapper class of rabbit API, if you have some
ideas in my code lines. Please let me know. <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>Thanks.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>//declare exchange<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 color="#339966" face=宋体><span lang=EN-US
style='font-size:9.0pt;color:#339966'>rabbitmqWrapper.ExchangeDeclare(Exchange.ExchangeName,
ExchangeType.Topic, false, true, false, false, false, null);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>//declare queue<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 color="#339966" face=宋体><span lang=EN-US
style='font-size:9.0pt;color:#339966'>rabbitmqWrapper.QueueDeclare(Queue.QueueName,
false, true, false, false, false, null);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>//bind queue<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 color="#339966" face=宋体><span lang=EN-US
style='font-size:9.0pt;color:#339966'>rabbitmqWrapper.QueueBind(quename,
exchangename,"test",false,null);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>//send message<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>private void SendMessage()<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>{<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'> string xml =
GetXml();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'> RabbitmqWrapper
wrapper =new RabbitmqWrapper();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'> wrapper.PublishMessage("wslinboundexchange",wslinboundque,"test",xml);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>}<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face=宋体><span lang=EN-US style='font-size:
10.5pt'>//function of RabbitmqWrapper class<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>public void PublishMessage(string
exchangeName,string queueName,string returnKey,string xml)<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>{<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>IConnection conn = new
ConnectionFactory().CreateConnection(this.rabbitmqHost);
using (IModel ch = conn.CreateModel())<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'> {<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
IBasicProperties props = ch.CreateBasicProperties();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
props.ContentType = "text/plain";<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
props.DeliveryMode = 2;<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
IStreamMessageBuilder b = new StreamMessageBuilder(ch);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
byte[] byptes = Encoding.UTF8.GetBytes(xml);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
b.WriteBytes(byptes);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>
ch.BasicPublish(exchangeName, returnKey,null,byptes);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'> }<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color="#339966" face=宋体><span lang=EN-US
style='font-size:10.5pt;color:#339966'>}<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>-----Original Message-----<br>
From: Matthias Radestock [mailto:matthias@lshift.net] <br>
Sent: 2009</span>年<span lang=EN-US>7</span>月<span lang=EN-US>29</span>日<span
lang=EN-US> 8:34<br>
To: Wilson Ke<br>
Cc: '<st1:PersonName w:st="on">rabbitmq-discuss@lists.rabbitmq.com</st1:PersonName>'<br>
Subject: Re: [rabbitmq-discuss] Durable queues and high availability (broker
failage)</span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><st1:City w:st="on"><st1:place w:st="on"><font size=1
face=宋体><span lang=EN-US style='font-size:9.0pt'>Wilson</span></font></st1:place></st1:City><span
lang=EN-US>,<o:p></o:p></span></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>Wilson Ke wrote:<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>> When I restart rabbitmq server,the durable queue had purge all<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>> messages. I want to remain these messages in the durable queue
after<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>> restart rabbitmq server,how can I do? Btw,I use<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>> deliverymode=2(persistent) to send messages to the queue.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>As long as the queues are marked as durable, are not exclusive or<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>auto-delete, and the messages are marked as persistent, then the queues<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>and messages should survive a broker restart.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>If all these conditions are met in your setup and the messages still<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>disappear then please post the code that creates the queues and the code<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>that sends the messages.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>Regards,<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=1 face=宋体><span lang=EN-US style='font-size:
9.0pt'>Matthias.<o:p></o:p></span></font></p>
</div>
</body>
</html>