|
@@ -1,39 +0,0 @@
|
1
|
|
-package kr.co.swh.lecture.opensource.rabbitmq;
|
2
|
|
-
|
3
|
|
-import com.rabbitmq.client.Channel;
|
4
|
|
-import com.rabbitmq.client.Connection;
|
5
|
|
-import com.rabbitmq.client.ConnectionFactory;
|
6
|
|
-
|
7
|
|
-/**
|
8
|
|
- * <pre>
|
9
|
|
- * kr.co.swh.lecture.opensource.rabbitmq
|
10
|
|
- * EmitLogTopic.java
|
11
|
|
- *
|
12
|
|
- * 설명 :
|
13
|
|
- * </pre>
|
14
|
|
- *
|
15
|
|
- * @since : 2020. 6. 21.
|
16
|
|
- * @author : tobby48
|
17
|
|
- * @version : v1.0
|
18
|
|
- */
|
19
|
|
-public class EmitLogTopic {
|
20
|
|
-
|
21
|
|
- private static final String EXCHANGE_NAME = "news.new";
|
22
|
|
-
|
23
|
|
- public static void main(String[] argv) throws Exception {
|
24
|
|
- ConnectionFactory factory = new ConnectionFactory();
|
25
|
|
- factory.setHost("dev-swh.ga");
|
26
|
|
- try (Connection connection = factory.newConnection();
|
27
|
|
- Channel channel = connection.createChannel()) {
|
28
|
|
-
|
29
|
|
- channel.exchangeDeclare(EXCHANGE_NAME, "topic");
|
30
|
|
-
|
31
|
|
- String routingKey = "naver";
|
32
|
|
- String message = "뉴스다";
|
33
|
|
-
|
34
|
|
- channel.basicPublish(EXCHANGE_NAME, routingKey, null, message.getBytes("UTF-8"));
|
35
|
|
- System.out.println(" [x] Sent '" + routingKey + "':'" + message + "'");
|
36
|
|
- }
|
37
|
|
- }
|
38
|
|
- //..
|
39
|
|
-}
|