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

Unable to use assertQueueErrorHandler: Channel ended #413

Closed
buffcode opened this issue Apr 5, 2022 · 2 comments
Closed

Unable to use assertQueueErrorHandler: Channel ended #413

buffcode opened this issue Apr 5, 2022 · 2 comments
Labels

Comments

@buffcode
Copy link

buffcode commented Apr 5, 2022

I am trying to (re-)configure a queue and add a dead letter exchange. Therefore I added assertQueueErrorHandler: forceDeleteAssertQueueErrorHandler as implemented by #348.

Unfortunately this still crashes, as the channel is closed as soon as the queue assertion fails:

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'node_messages' in vhost '/': received the value 'node_messages_delays' of type 'longstr' but current is none"
    at ConfirmChannel.C.accept (/var/www/instances/x/node-server/dist/node-server.js:79609:17)
    at Connection.mainAccept (/var/www/instances/x/node-server/dist/node-server.js:60998:33)
    at Socket.go (/var/www/instances/x/node-server/dist/node-server.js:61412:48)
    at Socket.emit (events.js:400:28)
    at Socket.emit (domain.js:475:12)
    at emitReadable_ (internal/streams/readable.js:555:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Unhandled rejection Error: Channel ended, no reply will be forthcoming
    at rej (/var/www/instances/x/node-server/dist/node-server.js:79388:7)
    at ConfirmChannel.C._rejectPending (/var/www/instances/x/node-server/dist/node-server.js:79394:42)
    at ConfirmChannel.C.toClosed (/var/www/instances/x/node-server/dist/node-server.js:79358:8)
    at Connection.C._closeChannels (/var/www/instances/x/node-server/dist/node-server.js:61328:18)
    at Connection.C.toClosed (/var/www/instances/x/node-server/dist/node-server.js:61335:8)
    at Connection.C.onSocketError (/var/www/instances/x/node-server/dist/node-server.js:61289:10)
    at Connection.emit (events.js:400:28)
    at Connection.emit (domain.js:475:12)
    at Socket.go (/var/www/instances/x/node-server/dist/node-server.js:61415:12)
    at Socket.emit (events.js:400:28)
    at Socket.emit (domain.js:475:12)
    at emitReadable_ (internal/streams/readable.js:555:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Is this feature subject to a specific RabbitMQ version (3.7.28) or configuration?

Queue configuration
      {
        exchange: exchangeQueue,
        queueOptions: {
          durable: true,
          deadLetterExchange: `${queueName}_delays`,
        },
        routingKey: queueName,
        queue: queueName,
        createQueueIfNotExists: true,
        assertQueueErrorHandler: forceDeleteAssertQueueErrorHandler,
      },
@underfisk
Copy link
Contributor

@buffcode Be sure that your queue is empty in RMQ because otherwise the configurations are different and that might cause this. If your instance is already brand new then just provide us a repo to replicate this

@Fgruntjes
Copy link

Fgruntjes commented Jun 8, 2022

@buffcode it has been a while, but we are experiencing the same issue. The answer of @underfisk does not really change the situation, the whole point of the feature is to recreate the queue whenever some configurations change. That is currently not possible because the channel has already been closed.

We are registering the handlers ourselves, so we can do this with a new connection object.

config.assertQueueErrorHandler = async (
    channel: Channel,
    queueName: string,
    queueOptions: QueueOptions | undefined,
    error: AmqpError
) => {
    const newChannel = connection.managedChannel;
    if (error.code === 406) {
        //406 == preconditions failed
        await newChannel.deleteQueue(queueName);
        const { queue } = await newChannel.assertQueue(queueName, queueOptions);
        return queue;
    }
    throw error;
};

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

No branches or pull requests

3 participants