-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
39 deletions.
There are no files selected for viewing
78 changes: 39 additions & 39 deletions
78
src/main/java/shop/geeksasangchat/rabbitmq/Tut5Receiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
// } | ||
// } | ||
// } | ||
//} |