Skip to content

Commit 4298de4

Browse files
committed
refactor: Comment out RabbitMQ integration and related code
1 parent 63635c2 commit 4298de4

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

index.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import cors from "@fastify/cors";
88
import fastifyStatic from "@fastify/static";
99
import fastifyRedis from "@fastify/redis";
1010
import fastifyPostgres from "@fastify/postgres";
11-
import fastifyRabbit from "fastify-rabbitmq";
11+
// import fastifyRabbit from "fastify-rabbitmq";
1212
import { fileURLToPath } from "node:url";
1313
import { dirname, join } from "node:path";
1414
import crypto from "node:crypto";
@@ -26,7 +26,7 @@ const schema = {
2626
"CACHE_HOST",
2727
"CACHE_PORT",
2828
"DB_URL",
29-
"MQ_URL",
29+
// "MQ_URL",
3030
],
3131
properties: {
3232
PORT: {
@@ -47,9 +47,9 @@ const schema = {
4747
DB_URL: {
4848
type: "string",
4949
},
50-
MQ_URL: {
51-
type: "string",
52-
},
50+
// MQ_URL: {
51+
// type: "string",
52+
// },
5353
},
5454
};
5555

@@ -79,9 +79,9 @@ await fastify.register(fastifyPostgres, {
7979
connectionString: fastify.config.DB_URL,
8080
});
8181

82-
await fastify.register(fastifyRabbit, {
83-
connection: fastify.config.MQ_URL,
84-
});
82+
// await fastify.register(fastifyRabbit, {
83+
// connection: fastify.config.MQ_URL,
84+
// });
8585

8686
await fastify.register(fastifyStatic, {
8787
root: join(__dirname, "dist"),
@@ -101,7 +101,7 @@ fastify.get("/readiness", async (request, reply) => {
101101
try {
102102
let redisStatus = { status: "disconnected", message: "" };
103103
let dbStatus = { status: "disconnected", message: "" };
104-
let rabbitStatus = { status: "disconnected", message: "" };
104+
// let rabbitStatus = { status: "disconnected", message: "" };
105105

106106
// Redis 상태 확인
107107
try {
@@ -131,31 +131,31 @@ fastify.get("/readiness", async (request, reply) => {
131131
}
132132

133133
// RabbitMQ 상태 확인
134-
try {
135-
if (fastify.rabbitmq.ready) {
136-
rabbitStatus = {
137-
status: "connected",
138-
message: "RabbitMQ is connected and operational.",
139-
};
140-
} else {
141-
rabbitStatus.message = "RabbitMQ is not connected.";
142-
}
143-
} catch (error) {
144-
rabbitStatus.message = `RabbitMQ connection check failed: ${error.message}`;
145-
}
134+
// try {
135+
// if (fastify.rabbitmq.ready) {
136+
// rabbitStatus = {
137+
// status: "connected",
138+
// message: "RabbitMQ is connected and operational.",
139+
// };
140+
// } else {
141+
// rabbitStatus.message = "RabbitMQ is not connected.";
142+
// }
143+
// } catch (error) {
144+
// rabbitStatus.message = `RabbitMQ connection check failed: ${error.message}`;
145+
// }
146146

147147
// 모든 상태가 정상일 때
148148
if (
149149
redisStatus.status === "connected" &&
150-
dbStatus.status === "connected" &&
151-
rabbitStatus.status === "connected"
150+
dbStatus.status === "connected"
151+
// rabbitStatus.status === "connected"
152152
) {
153153
reply.send({
154154
status: "ok",
155155
message: "The server is ready.",
156156
redis: redisStatus,
157157
database: dbStatus,
158-
rabbitmq: rabbitStatus,
158+
// rabbitmq: rabbitStatus,
159159
});
160160
} else {
161161
// 하나라도 비정상일 때
@@ -164,7 +164,7 @@ fastify.get("/readiness", async (request, reply) => {
164164
message: "The server is not fully ready. See details below.",
165165
redis: redisStatus,
166166
database: dbStatus,
167-
rabbitmq: rabbitStatus,
167+
// rabbitmq: rabbitStatus,
168168
});
169169
}
170170
} catch (unexpectedError) {
@@ -1244,26 +1244,26 @@ async function releaseSeats(socketId, seats, areaName) {
12441244
}
12451245

12461246
// RabbitMQ 메시지 전송 로직
1247-
async function sendMessageToQueue(roomName, message) {
1248-
const queueName = `queue:${roomName}`;
1249-
try {
1250-
// 큐 선언 (존재하지 않을 경우 생성)
1251-
await fastify.rabbitmq.queueDeclare({ queue: queueName, durable: true });
1247+
// async function sendMessageToQueue(roomName, message) {
1248+
// const queueName = `queue:${roomName}`;
1249+
// try {
1250+
// // 큐 선언 (존재하지 않을 경우 생성)
1251+
// await fastify.rabbitmq.queueDeclare({ queue: queueName, durable: true });
12521252

1253-
// Publisher 생성
1254-
const publisher = fastify.rabbitmq.createPublisher({
1255-
confirm: true, // 메시지가 성공적으로 전송되었는지 확인
1256-
maxAttempts: 3, // 최대 재시도 횟수
1257-
});
1253+
// // Publisher 생성
1254+
// const publisher = fastify.rabbitmq.createPublisher({
1255+
// confirm: true, // 메시지가 성공적으로 전송되었는지 확인
1256+
// maxAttempts: 3, // 최대 재시도 횟수
1257+
// });
12581258

1259-
// 메시지 전송
1260-
await publisher.send(queueName, JSON.stringify(message));
1259+
// // 메시지 전송
1260+
// await publisher.send(queueName, JSON.stringify(message));
12611261

1262-
fastify.log.info(`Message sent to queue "${queueName}": ${message}`);
1263-
} catch (error) {
1264-
fastify.log.error(`Failed to send message to queue "${queueName}":`, error);
1265-
}
1266-
}
1262+
// fastify.log.info(`Message sent to queue "${queueName}": ${message}`);
1263+
// } catch (error) {
1264+
// fastify.log.error(`Failed to send message to queue "${queueName}":`, error);
1265+
// }
1266+
// }
12671267

12681268
// 공통 로직: 클라이언트가 Room을 떠날 때 처리
12691269
async function handleClientLeave(socket, roomName) {

0 commit comments

Comments
 (0)