<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
        LINE-HEIGHT: 1.5; FONT-FAMILY: ËÎÌå; COLOR: #000000; FONT-SIZE: 10.5pt
}
</STYLE>
<META name=GENERATOR content="MSHTML 8.00.7601.17785"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi guys,</DIV>
<DIV> </DIV>
<DIV>I am quite new to RabbitMq and now try to learn it from the tutorial. I
installed the windows version and the LINUX version (CentOS 5.5) of RabbitMQ
2.8.2. The Erlang version is R14B03 in Linux. In Windows, everything is fine.
But in CENTOS5.5, after sending the message, the program cannot exit and always
stuck. Hence, the receiver also cannot get the message. Can you point
out how to debug it? Thanks a lot!</DIV>
<DIV> </DIV>
<DIV><SPAN><A
href="http://www.rabbitmq.com/tutorials/tutorial-one-java.html">http://www.rabbitmq.com/tutorials/tutorial-one-java.html</A></SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>
<DIV class=highlight><PRE><DIV style="BACKGROUND-COLOR: transparent" id=LC1 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.ConnectionFactory</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC2 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.Connection</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC3 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.Channel</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC4 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC5 class=line><SPAN class=kd>public</SPAN> <SPAN class=kd>class</SPAN> <SPAN class=nc>Send</SPAN> <SPAN class=o>{</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC6 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC7 class=line> <SPAN class=kd>private</SPAN> <SPAN class=kd>final</SPAN> <SPAN class=kd>static</SPAN> <SPAN class=n>String</SPAN> <SPAN class=n>QUEUE_NAME</SPAN> <SPAN class=o>=</SPAN> <SPAN class=s>"hello"</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC8 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC9 class=line> <SPAN class=kd>public</SPAN> <SPAN class=kd>static</SPAN> <SPAN class=kt>void</SPAN> <SPAN class=nf>main</SPAN><SPAN class=o>(</SPAN><SPAN class=n>String</SPAN><SPAN class=o>[]</SPAN> <SPAN class=n>argv</SPAN><SPAN class=o>)</SPAN> <SPAN class=kd>throws</SPAN> <SPAN class=n>Exception</SPAN> <SPAN class=o>{</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC10 class=line>          </DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC11 class=line> <SPAN class=n>ConnectionFactory</SPAN> <SPAN class=n>factory</SPAN> <SPAN class=o>=</SPAN> <SPAN class=k>new</SPAN> <SPAN class=n>ConnectionFactory</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC12 class=line> <SPAN class=n>factory</SPAN><SPAN class=o>.</SPAN><SPAN class=na>setHost</SPAN><SPAN class=o>(</SPAN><SPAN class=s>"localhost"</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC13 class=line> <SPAN class=n>Connection</SPAN> <SPAN class=n>connection</SPAN> <SPAN class=o>=</SPAN> <SPAN class=n>factory</SPAN><SPAN class=o>.</SPAN><SPAN class=na>newConnection</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC14 class=line> <SPAN class=n>Channel</SPAN> <SPAN class=n>channel</SPAN> <SPAN class=o>=</SPAN> <SPAN class=n>connection</SPAN><SPAN class=o>.</SPAN><SPAN class=na>createChannel</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC15 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC16 class=line> <SPAN class=n>channel</SPAN><SPAN class=o>.</SPAN><SPAN class=na>queueDeclare</SPAN><SPAN class=o>(</SPAN><SPAN class=n>QUEUE_NAME</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>false</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>false</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>false</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>null</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC17 class=line> <SPAN class=n>String</SPAN> <SPAN class=n>message</SPAN> <SPAN class=o>=</SPAN> <SPAN class=s>"Hello World!"</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC18 class=line> <SPAN class=n>channel</SPAN><SPAN class=o>.</SPAN><SPAN class=na>basicPublish</SPAN><SPAN class=o>(</SPAN><SPAN class=s>""</SPAN><SPAN class=o>,</SPAN> <SPAN class=n>QUEUE_NAME</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>null</SPAN><SPAN class=o>,</SPAN> <SPAN class=n>message</SPAN><SPAN class=o>.</SPAN><SPAN class=na>getBytes</SPAN><SPAN class=o>());</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC19 class=line> <SPAN class=n>System</SPAN><SPAN class=o>.</SPAN><SPAN class=na>out</SPAN><SPAN class=o>.</SPAN><SPAN class=na>println</SPAN><SPAN class=o>(</SPAN><SPAN class=s>" [x] Sent '"</SPAN> <SPAN class=o>+</SPAN> <SPAN class=n>message</SPAN> <SPAN class=o>+</SPAN> <SPAN class=s>"'"</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC20 class=line> </DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC21 class=line> <SPAN class=n>channel</SPAN><SPAN class=o>.</SPAN><SPAN class=na>close</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC22 class=line> <SPAN class=n>connection</SPAN><SPAN class=o>.</SPAN><SPAN class=na>close</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC23 class=line> <SPAN class=o>}</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC24 class=line><SPAN class=o>}</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" class=line><SPAN class=o></SPAN> </DIV><DIV style="BACKGROUND-COLOR: transparent" class=line><SPAN class=o></SPAN> </DIV><DIV style="BACKGROUND-COLOR: transparent" class=line><SPAN class=o><DIV class=highlight><PRE><DIV style="BACKGROUND-COLOR: transparent" id=LC1 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.ConnectionFactory</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC2 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.Connection</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC3 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.Channel</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC4 class=line><SPAN class=kn>import</SPAN> <SPAN class=nn>com.rabbitmq.client.QueueingConsumer</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC5 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC6 class=line><SPAN class=kd>public</SPAN> <SPAN class=kd>class</SPAN> <SPAN class=nc>Recv</SPAN> <SPAN class=o>{</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC7 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC8 class=line> <SPAN class=kd>private</SPAN> <SPAN class=kd>final</SPAN> <SPAN class=kd>static</SPAN> <SPAN class=n>String</SPAN> <SPAN class=n>QUEUE_NAME</SPAN> <SPAN class=o>=</SPAN> <SPAN class=s>"hello"</SPAN><SPAN class=o>;</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC9 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC10 class=line> <SPAN class=kd>public</SPAN> <SPAN class=kd>static</SPAN> <SPAN class=kt>void</SPAN> <SPAN class=nf>main</SPAN><SPAN class=o>(</SPAN><SPAN class=n>String</SPAN><SPAN class=o>[]</SPAN> <SPAN class=n>argv</SPAN><SPAN class=o>)</SPAN> <SPAN class=kd>throws</SPAN> <SPAN class=n>Exception</SPAN> <SPAN class=o>{</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC11 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC12 class=line> <SPAN class=n>ConnectionFactory</SPAN> <SPAN class=n>factory</SPAN> <SPAN class=o>=</SPAN> <SPAN class=k>new</SPAN> <SPAN class=n>ConnectionFactory</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC13 class=line> <SPAN class=n>factory</SPAN><SPAN class=o>.</SPAN><SPAN class=na>setHost</SPAN><SPAN class=o>(</SPAN><SPAN class=s>"localhost"</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC14 class=line> <SPAN class=n>Connection</SPAN> <SPAN class=n>connection</SPAN> <SPAN class=o>=</SPAN> <SPAN class=n>factory</SPAN><SPAN class=o>.</SPAN><SPAN class=na>newConnection</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC15 class=line> <SPAN class=n>Channel</SPAN> <SPAN class=n>channel</SPAN> <SPAN class=o>=</SPAN> <SPAN class=n>connection</SPAN><SPAN class=o>.</SPAN><SPAN class=na>createChannel</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC16 class=line><BR></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC17 class=line> <SPAN class=n>channel</SPAN><SPAN class=o>.</SPAN><SPAN class=na>queueDeclare</SPAN><SPAN class=o>(</SPAN><SPAN class=n>QUEUE_NAME</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>false</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>false</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>false</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>null</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC18 class=line> <SPAN class=n>System</SPAN><SPAN class=o>.</SPAN><SPAN class=na>out</SPAN><SPAN class=o>.</SPAN><SPAN class=na>println</SPAN><SPAN class=o>(</SPAN><SPAN class=s>" [*] Waiting for messages. To exit press CTRL+C"</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC19 class=line> </DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC20 class=line> <SPAN class=n>QueueingConsumer</SPAN> <SPAN class=n>consumer</SPAN> <SPAN class=o>=</SPAN> <SPAN class=k>new</SPAN> <SPAN class=n>QueueingConsumer</SPAN><SPAN class=o>(</SPAN><SPAN class=n>channel</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC21 class=line> <SPAN class=n>channel</SPAN><SPAN class=o>.</SPAN><SPAN class=na>basicConsume</SPAN><SPAN class=o>(</SPAN><SPAN class=n>QUEUE_NAME</SPAN><SPAN class=o>,</SPAN> <SPAN class=kc>true</SPAN><SPAN class=o>,</SPAN> <SPAN class=n>consumer</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC22 class=line> </DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC23 class=line> <SPAN class=k>while</SPAN> <SPAN class=o>(</SPAN><SPAN class=kc>true</SPAN><SPAN class=o>)</SPAN> <SPAN class=o>{</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC24 class=line> <SPAN class=n>QueueingConsumer</SPAN><SPAN class=o>.</SPAN><SPAN class=na>Delivery</SPAN> <SPAN class=n>delivery</SPAN> <SPAN class=o>=</SPAN> <SPAN class=n>consumer</SPAN><SPAN class=o>.</SPAN><SPAN class=na>nextDelivery</SPAN><SPAN class=o>();</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC25 class=line> <SPAN class=n>String</SPAN> <SPAN class=n>message</SPAN> <SPAN class=o>=</SPAN> <SPAN class=k>new</SPAN> <SPAN class=n>String</SPAN><SPAN class=o>(</SPAN><SPAN class=n>delivery</SPAN><SPAN class=o>.</SPAN><SPAN class=na>getBody</SPAN><SPAN class=o>());</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC26 class=line> <SPAN class=n>System</SPAN><SPAN class=o>.</SPAN><SPAN class=na>out</SPAN><SPAN class=o>.</SPAN><SPAN class=na>println</SPAN><SPAN class=o>(</SPAN><SPAN class=s>" [x] Received '"</SPAN> <SPAN class=o>+</SPAN> <SPAN class=n>message</SPAN> <SPAN class=o>+</SPAN> <SPAN class=s>"'"</SPAN><SPAN class=o>);</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC27 class=line> <SPAN class=o>}</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC28 class=line> <SPAN class=o>}</SPAN></DIV><DIV style="BACKGROUND-COLOR: transparent" id=LC29 class=line><SPAN class=o>}</SPAN></DIV></PRE></DIV></SPAN></DIV></PRE></DIV></DIV></SPAN></BODY></HTML>