Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinLemon112 committed Nov 9, 2023
1 parent c99fe8e commit 3094739
Show file tree
Hide file tree
Showing 429 changed files with 833,350 additions and 984,313 deletions.
4 changes: 2 additions & 2 deletions src/notification/NotiInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
export interface RabbitMQServiceConfig {
host: string; // RabbitMQ server host
port: number; // RabbitMQ server port
username: string; // RabbitMQ username
password: string; // RabbitMQ password
username: "luminosityleds"; // RabbitMQ username
password: "Lumi-123"; // RabbitMQ password
exchange: string; // RabbitMQ exchange
queue: string; // RabbitMQ queue
routingKey: string; // RabbitMQ routing key
Expand Down
4 changes: 2 additions & 2 deletions src/notification/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default {
rabbitmq: {
hostname: 'localhost', // RabbitMQ server hostname
port: 5672, // Default RabbitMQ port
username: process.env.RABBITMQ_USERNAME ?? "", // RabbitMQ username
password: process.env.RABBITMQ_PASSWORD ?? "", // RabbitMQ password
username: process.env.RABBITMQ_USERNAME, // RabbitMQ username
password: process.env.RABBITMQ_PASSWORD, // RabbitMQ password
vhost: '/', // Virtual host (default is '/')
heartbeat: 10, // Heartbeat interval in seconds
},
Expand Down
15 changes: 7 additions & 8 deletions src/notification/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import config from './config'; // Import the RabbitMQ configuration
// Access the RabbitMQ configuration values
const rabbitmqConfig = config.rabbitmq;


async function connectToRabbitMQ() {
try {

const connection: amqplib.Connection = await amqplib.connect({
hostname: rabbitmqConfig.hostname,
port: rabbitmqConfig.port,
Expand All @@ -21,16 +19,17 @@ async function connectToRabbitMQ() {
// Channel for communication
const channel: amqplib.Channel = await connection.createChannel();

// Publish a message to a queue
// Declare a durable queue
const queueName = 'myQueue';
await channel.assertQueue(queueName);
const message = 'Hello, RabbitMQ!';
channel.sendToQueue(queueName, Buffer.from(message));
await channel.assertQueue(queueName, { durable: true });

// Purge the queue (clear existing messages)
await channel.purgeQueue(queueName);

// Function to send some messages before consuming the queue
const sendMessages = (channel: amqplib.Channel) => {
for (let i = 0; i < 10; i++) {
channel.sendToQueue('myQueue', Buffer.from(`message ${i}`));
channel.sendToQueue(queueName, Buffer.from(`message ${i}`));
}
}

Expand All @@ -55,4 +54,4 @@ async function connectToRabbitMQ() {
}

// Call the function to connect to RabbitMQ
connectToRabbitMQ();
connectToRabbitMQ();
1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/acorn

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/ts-node

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/ts-node-cwd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/ts-node-esm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/ts-node-script

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/ts-node-transpile-only

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/notification/node_modules/.bin/ts-script

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3094739

Please sign in to comment.