Skip to content

Commit

Permalink
updating
Browse files Browse the repository at this point in the history
  • Loading branch information
tgwalker93 committed Aug 15, 2023
1 parent 798870d commit b6f6df4
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 215 deletions.
36 changes: 20 additions & 16 deletions messaging/messaging.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const amqp = require('amqplib/callback_api');
const amqp = require('amqplib');

const CONN_URL = 'amqps://hsmwnpfw:[email protected]/hsmwnpfw';
let ch = null;
amqp.connect(CONN_URL, function(err, conn){
conn.createChannel(function(err, channel){
ch = channel;
})
})
const CONN_URL = process.env.CLOUDAMQP_URL;

const publishToQueue = async (queueName, data) => {
ch.sendToQueue(queueName, new Buffer.from(data));
}
(async () => {
try {
const connection = await amqp.connect(CONN_URL);
const channel = await connection.createChannel();

process.on('exit', (code) =>{
ch.close();
console.log('Closing rabbitmq channel');
});
const publishToQueue = (queueName, data) => {
const message = Buffer.from(data);
channel.sendToQueue(queueName, message);
};

module.exports = {publishToQueue}
process.on('beforeExit', async (code) => {
await channel.close();
console.log('Closing RabbitMQ channel');
});

module.exports = { publishToQueue };
} catch (error) {
console.error('Error:', error);
}
})();
72 changes: 72 additions & 0 deletions newrelic_agent.log

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions package-lock.json

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

Loading

0 comments on commit b6f6df4

Please sign in to comment.