AMQP
The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware
- JavaScript
- Python
Comming soon
We are releasing new Python features every week
Network Connection needs
This integration needs network access to the server where the service is running.
See the Network access page for details about how to achieve that.
Credential configuration
To configure this credential, you need to fill the credential configuration form with the RabbitMQ connection parameters:
host
, port
, username
, password
and vhost
.
If you check the Use promise API
option, you'll be able to use the library using promises; otherwise, the credential will
use the callback API. You can only use one of both ways.
In the extra options field, you can include any of the parameters you found here.
Here is an example of a filled credential configuration form in YepCode:
AMQP Snippets available in editor
The title is the triggering text for YepCode to autocomplete the script.
- JavaScript
- Python
Integration
const amqpConnection = await yepcode.integration.amqp('credential-slug')
const amqp = require('amqplib');
amqp.connect({
hostname: 'localhost',
username: 'guest',
password: 'guest',
port: '5672',
vhost: '/'
}).then(connection => {
// Your code here
}).catch(console.error);
const amqp = require('amqplib/callback_api');
amqp.connect({
hostname: 'localhost',
username: 'guest',
password: 'guest',
port: '5672',
vhost: '/'
},
(error, connection) => {
if (error) {
console.error(error);
}
// Your code here
}
);
Publisher (Promise)
const queue = "queueName";
const publisher = (connection) => {
return connection
.createChannel()
.then((channel) => {
return channel.assertQueue(queue).then((ok) => {
return channel.sendToQueue(
queue,
Buffer.from("Your message here")
);
});
})
.catch((error) => console.error(error));
};
Publisher (async/await)
const queue = "queueName";
const publisher = async (connection) => {
try {
const channel = await connection.createChannel();
await channel.assertQueue(queue);
channel.sendToQueue(queue, Buffer.from("Your message here"));
} catch (error) {
console.error(error);
}
};
Publisher (Callback)
const queue = "queueName";
const publisher = (connection) => {
connection.createChannel((error, channel) => {
if (error != null) console.error(error);
channel.assertQueue(queue);
channel.sendToQueue(queue, Buffer.from("Your message here"));
});
};
Comming soon
We are releasing new Python features every week