Skip to content

Commit

Permalink
fix bug and change sout to log
Browse files Browse the repository at this point in the history
  • Loading branch information
Lovelcp committed Nov 20, 2017
1 parent d18c2f3 commit ce6430a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
@@ -1,6 +1,8 @@
package com.wooyoo.blog.spring_boot.rabbitmq.delay.queue;

import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
Expand All @@ -11,6 +13,7 @@
@Component
public class ProcessReceiver implements ChannelAwareMessageListener {
public static CountDownLatch latch;
private static Logger logger = LoggerFactory.getLogger(ProcessReceiver.class);

public static final String FAIL_MESSAGE = "This message will fail";

Expand Down Expand Up @@ -38,7 +41,7 @@ public void onMessage(Message message, Channel channel) throws Exception {
*/
public void processMessage(Message message) throws Exception {
String realMessage = new String(message.getBody());
System.out.println("Received <" + realMessage + ">");
logger.info("Received <" + realMessage + ">");
if (Objects.equals(realMessage, FAIL_MESSAGE)) {
throw new Exception("Some exception happened");
}
Expand Down
Expand Up @@ -41,7 +41,7 @@ public void testDelayQueuePerQueueTTL() throws InterruptedException {
public void testFailMessage() throws InterruptedException {
ProcessReceiver.latch = new CountDownLatch(6);
for (int i = 1; i <= 3; i++) {
rabbitTemplate.convertAndSend(QueueConfig.DELAY_QUEUE_PER_QUEUE_TTL_NAME, ProcessReceiver.FAIL_MESSAGE);
rabbitTemplate.convertAndSend(QueueConfig.DELAY_PROCESS_QUEUE_NAME, ProcessReceiver.FAIL_MESSAGE);
}
ProcessReceiver.latch.await();
}
Expand Down

0 comments on commit ce6430a

Please sign in to comment.