Skip to content

Commit

Permalink
#16 refactor: 5번 리시버 주석처리
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaktmchl committed Nov 2, 2022
1 parent bd121ee commit 2c650f0
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/main/java/shop/geeksasangchat/rabbitmq/Tut5Receiver.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
package shop.geeksasangchat.rabbitmq;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.util.StopWatch;

//TODO: rabbitmq 5번 튜토리얼 Consumer 코드임, 구독 및 수신 로컬 스프링에서는 테스트 성공.
public class Tut5Receiver {

@RabbitListener(queues = "chatting-room-queue-test2")
public void receive1(String in) throws InterruptedException {
receive(in, 1);
}

@RabbitListener(queues = "chatting-room-queue-test2")
public void receive2(String in) throws InterruptedException {
receive(in, 2);
}

public void receive(String in, int receiver) throws
InterruptedException {
System.out.println("===============Received 5번 튜토리얼 소비자<" + in + ">");
StopWatch watch = new StopWatch();
watch.start();
System.out.println("instance " + receiver + " [x] Received '"
+ in + "'");
doWork(in);
watch.stop();
System.out.println("instance " + receiver + " [x] Done in "
+ watch.getTotalTimeSeconds() + "s");
}

private void doWork(String in) throws InterruptedException {
for (char ch : in.toCharArray()) {
if (ch == '.') {
Thread.sleep(1000);
}
}
}
}
//package shop.geeksasangchat.rabbitmq;
//
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.util.StopWatch;
//
////TODO: rabbitmq 5번 튜토리얼 Consumer 코드임, 구독 및 수신 로컬 스프링에서는 테스트 성공.
//public class Tut5Receiver {
//
// @RabbitListener(queues = "chatting-room-queue-test2")
// public void receive1(String in) throws InterruptedException {
// receive(in, 1);
// }
//
// @RabbitListener(queues = "chatting-room-queue-test2")
// public void receive2(String in) throws InterruptedException {
// receive(in, 2);
// }
//
// public void receive(String in, int receiver) throws
// InterruptedException {
// System.out.println("===============Received 5번 튜토리얼 소비자<" + in + ">");
// StopWatch watch = new StopWatch();
// watch.start();
// System.out.println("instance " + receiver + " [x] Received '"
// + in + "'");
// doWork(in);
// watch.stop();
// System.out.println("instance " + receiver + " [x] Done in "
// + watch.getTotalTimeSeconds() + "s");
// }
//
// private void doWork(String in) throws InterruptedException {
// for (char ch : in.toCharArray()) {
// if (ch == '.') {
// Thread.sleep(1000);
// }
// }
// }
//}

0 comments on commit 2c650f0

Please sign in to comment.