Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env node
- var amqp = require('amqplib/callback_api');
- amqp.connect('amqp://miguel:miguel123@152.228.133.222:32777/mobile_app', function(error0, connection) {
- if (error0) {
- throw error0;
- }
- connection.createChannel(function(error1, channel) {
- if (error1) {
- throw error1;
- }
- var exchange = 'crowd_sensing_exchange';
- var severity = 'crowd_sensing';
- var JsonMsg={
- "user_id": "1",
- "device_id":"sabri test",
- "datetime":"10-22-2020 15:21:50",
- "location":{
- "lat":43.48,
- "lng":-1.49
- },
- "sensors":{
- "temperature":"sabri test connection"
- }
- }
- var msg = JSON.stringify(JsonMsg);
- channel.publish(exchange, severity, Buffer.from(msg));
- console.log(" [x] Sent %s: '%s'", severity, msg);
- });
- setTimeout(function() {
- connection.close();
- process.exit(0)
- }, 10000);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement