Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection publish callback not executed #473

Open
vilten opened this issue Nov 28, 2018 · 1 comment
Open

connection publish callback not executed #473

vilten opened this issue Nov 28, 2018 · 1 comment

Comments

@vilten
Copy link

vilten commented Nov 28, 2018

Hello,

when I tried prepare simple publish procedure, callback after publishing message is never executed.

var amqp = require('amqp')

var connection = amqp.createConnection({ host: 'localhost', port: 5672 })

// add this for better debuging
connection.on('error', function(e) {
console.log("Error from amqp: ", e)
})

// Wait for connection to become established.
connection.on('ready', function () {
console.log('Connected.')
connection.publish('my-queue', '', {}, _ => {
console.log('Not executed')
connection.end()
})
})

@lcjury
Copy link

lcjury commented Mar 20, 2019

callback is a function that will get called if the exchange is in confirm mode

You're forced to setup an exchange with the option {confirm: true} to use the callback:

connection.on('ready', function () {
    console.log('Connected.')
    connection.exchange('', {confirm: true}, function(exchange) {
        exchange.publish('my-queue', '', {}, _ => {
            console.log('Executed')
            connection.end()
        });
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants