<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:宋体;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=ZH-CN link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Help please.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I declare the dead letter in producer side as following: <o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-indent:65.0pt;text-autospace:none'><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>channel.exchangeDeclare(</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#2A00FF'>"dead-exchange"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#2A00FF'>"direct"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>);</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
Map<String, Object> args = </span><b><span lang=EN-US style='font-size:
10.0pt;font-family:Consolas;color:#7F0055'>new</span></b><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> HashMap<String,
Object>();</span><span lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> args.put(</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#2A00FF'>"x-dead-letter-exchange"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#2A00FF'>"dead-exchange1"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>);</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> args.put(</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#2A00FF'>"x-dead-letter-routing-key"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#2A00FF'>"dead-exchange-routing-key"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
channel.queueDeclare(</span><i><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:#0000C0'>“myqueue”</span></i><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, args);</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> </span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
channel.queueDeclare(</span><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:#2A00FF'>"dead-exchange-routing-key"</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>null</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>);</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> String
message = </span><span lang=EN-US style='font-size:10.0pt;font-family:Consolas;
color:#2A00FF'>"Hello World!”</span><span lang=EN-US style='font-size:
10.0pt;font-family:Consolas;color:black'>;</span><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
channel.basicPublish(</span><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:#2A00FF'>""</span><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>,</span><i><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#0000C0'>“myqueue”</span></i><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>,
MessageProperties.</span><i><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:#0000C0'>PERSISTENT_TEXT_PLAIN</span></i><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>,
message.getBytes());<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:#1F497D'>and in conumser side:<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:#7F0055'><o:p> </o:p></span></b></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
QueueingConsumer consumer = </span><b><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:#7F0055'>new</span></b><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
QueueingConsumer(channel);</span><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
channel.basicConsume(</span><i><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:#0000C0'>QUEUE_NAME</span></i><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>, </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>,
consumer);</span><span lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>while</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'> (</span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>true</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>) {</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
QueueingConsumer.Delivery delivery = consumer.nextDelivery();</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> String
message = </span><b><span lang=EN-US style='font-size:10.0pt;font-family:Consolas;
color:#7F0055'>new</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:Consolas;color:black'> String(delivery.getBody());</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'>
channel.basicReject(delivery.getEnvelope().getDeliveryTag(), </span><b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:#7F0055'>false</span></b><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas;color:black'>);</span><span
lang=EN-US style='font-size:10.0pt;font-family:Consolas'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:10.0pt;font-family:Consolas;color:black'> }<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'>However, the dead letter message don’t show up in Rabbitmq
Management page. Can some help me?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thank you<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Tonglang Huang<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>