<HTML><HEAD><TITLE>Mail</TITLE>
<META name=GENERATOR 
content="KsDHTMLEDLib.ocx, FreeWare HTML Editor 1.164.2, ?Kurt Senfer">
<META content="text/html; charset=GB2312" http-equiv=Content-Type></HEAD>
<BODY style="FONT-SIZE: 9pt; FONT-FAMILY: ����" leftMargin=5 topMargin=5 #ffffff>
<DIV>Hi Tom</DIV>
<DIV> </DIV>
<DIV>I run the test in my computer, and I got all the messages form 0 to 
9.</DIV>
<DIV>but i comment the statement </DIV>
<DIV> </DIV>
<DIV>if (!StringUtils.isEmpty(message)) </DIV>
<DIV> </DIV>
<DIV>Is the static method "isEmpty"  wrong?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; PADDING-RIGHT: 0px; MARGIN-RIGHT: 0px">
  <DIV 
  style="FONT-SIZE: 9pt; FONT-VARIANT: normal; BACKGROUND: #e4e4e4; FONT-WEIGHT: normal; FONT-STYLE: normal; LINE-HEIGHT: normal; font-color: black"><B>From: 
  </B><A href="mailto:tom.reineke@googlemail.com">Tom Reineke</A> </DIV>
  <DIV 
  style="FONT-SIZE: 9pt; FONT-VARIANT: normal; FONT-WEIGHT: normal; FONT-STYLE: normal; LINE-HEIGHT: normal"><B>To: 
  </B><A href="mailto:rabbitmq-discuss@googlegroups.com">rabbitmq-discuss</A> 
  </DIV>
  <DIV 
  style="FONT-SIZE: 9pt; FONT-VARIANT: normal; FONT-WEIGHT: normal; FONT-STYLE: normal; LINE-HEIGHT: normal"><B>Sent: 
  </B>2013-12-04, 23:26:47</DIV>
  <DIV 
  style="FONT-SIZE: 9pt; FONT-VARIANT: normal; FONT-WEIGHT: normal; FONT-STYLE: normal; LINE-HEIGHT: normal"><B>Subject: 
  </B>[rabbitmq-discuss] Basic question on message delivery problem</DIV>
  <DIV><BR></DIV>
  <DIV></DIV>
  <DIV></DIV>
  <DIV>
  <DIV dir=ltr>Hi, 
  <DIV><BR></DIV>
  <DIV>I seem to have a very basic problem when setting up RabbitMQ and would be 
  grateful for any help. Ich have the following class:</DIV>
  <DIV><BR></DIV>
  <DIV>
  <DIV>public class RabbitTest {</DIV>
  <DIV><BR></DIV>
  <DIV><SPAN class=Apple-tab-span style="WHITE-SPACE: pre"></SPAN>private final 
  static ConnectionFactory factory = new ConnectionFactory();</DIV>
  <DIV>        private final static String MAIL_QUEUE_NAME = 
  "mailQueue";</DIV>
  <DIV>        private static Connection connection;</DIV>
  <DIV>        private static Channel channel;</DIV>
  <DIV>        private static QueueingConsumer 
  consumer;</DIV>
  <DIV><BR></DIV>
  <DIV><SPAN class=Apple-tab-span style="WHITE-SPACE: pre"></SPAN>public static 
  void main(final String[] args) throws IOException, KeyManagementException, 
  NoSuchAlgorithmException,  URISyntaxException, InterruptedException 
  {</DIV>
  <DIV>        factory = new ConnectionFactory();</DIV>
  <DIV><SPAN class=Apple-tab-span 
  style="WHITE-SPACE: pre"></SPAN>factory.setHost("localhost");</DIV>
  <DIV>        connection = factory.newConnection();</DIV>
  <DIV>        channel = connection.createChannel();</DIV>
  <DIV>        channel.queueDeclare(MAIL_QUEUE_NAME, true, 
  false, false, null);</DIV>
  <DIV>        consumer = new 
  QueueingConsumer(channel);</DIV>
  <DIV>        channel.basicConsume(MAIL_QUEUE_NAME, false, 
  consumer);</DIV>
  <DIV>        new Thread() {</DIV>
  <DIV>            @Override</DIV>
  <DIV>            public void run() {</DIV>
  <DIV>                while (true) 
  {</DIV>
  <DIV>                    try 
  {</DIV>
  <DIV>                    
      // The processor stops here until something</DIV>
  <DIV>                    
      // is in the queue. It does not continue with the next</DIV>
  <DIV>                    
      final QueueingConsumer.Delivery delivery = consumer</DIV>
  <DIV>                    
              .nextDelivery();</DIV>
  <DIV>                    
      final String message = new String(delivery.getBody());</DIV>
  <DIV>                    
      if (!StringUtils.isEmpty(message)) {</DIV>
  <DIV>                    
          System.out.println("########## message 
  #############");</DIV>
  <DIV>                    
          System.out.println(message);</DIV>
  <DIV>                    
      }</DIV>
  <DIV>                    } 
  catch (final Exception e) {</DIV>
  <DIV><BR></DIV>
  <DIV>                    
  }</DIV>
  <DIV>                }</DIV>
  <DIV>            }</DIV>
  <DIV>        }.start();</DIV>
  <DIV><BR></DIV>
  <DIV>        for (int i = 0; i < 10; i++) {</DIV>
  <DIV>            createMailTask("message " + 
  i);</DIV>
  <DIV>        }</DIV>
  <DIV><BR></DIV>
  <DIV>        Thread.sleep(10000);</DIV>
  <DIV>        channel.close();</DIV>
  <DIV>        connection.close();</DIV>
  <DIV>    }</DIV>
  <DIV><BR></DIV>
  <DIV>    public static void createMailTask(final String 
  amqpMessage)</DIV>
  <DIV>            throws IOException {</DIV>
  <DIV>        final Channel ch = 
  connection.createChannel();</DIV>
  <DIV>        ch.queueDeclare(MAIL_QUEUE_NAME, true, false, 
  false, null);</DIV>
  <DIV>        ch.basicPublish("", MAIL_QUEUE_NAME,</DIV>
  <DIV>                
  MessageProperties.PERSISTENT_TEXT_PLAIN, amqpMessage.getBytes());</DIV>
  <DIV>        ch.close();</DIV>
  <DIV>    }</DIV>
  <DIV>}</DIV>
  <DIV><BR></DIV>
  <DIV>I would have assumed that I get a log output for each of the 10 messages; 
  instead I only get:</DIV>
  <DIV><BR></DIV>
  <DIV>[Thread-0] INFO de.apt.utils.APTMailUtil - ########## message 
  #############</DIV>
  <DIV>[Thread-0] INFO de.apt.utils.APTMailUtil - message 2</DIV>
  <DIV>[Thread-0] INFO de.apt.utils.APTMailUtil - ########## message 
  #############</DIV>
  <DIV>[Thread-0] INFO de.apt.utils.APTMailUtil - message 5</DIV>
  <DIV>[Thread-0] INFO de.apt.utils.APTMailUtil - ########## message 
  #############</DIV>
  <DIV>[Thread-0] INFO de.apt.utils.APTMailUtil - message 8</DIV></DIV>
  <DIV><BR></DIV>
  <DIV>Can you tell me where the problem is in my 
code?</DIV></DIV></DIV></BLOCKQUOTE></BODY></HTML>