【问题标题】:AMQPException Library error: table too large for bufferAMQPException 库错误:表对于缓冲区来说太大
【发布时间】:2021-02-15 15:26:48
【问题描述】:

我在 Symfony 应用程序中使用 messenger 组件来处理来自 rabbitmq 的消息。

当我发送 2-3mb 的消息并且我的处理程序发生错误时,尝试将消息发送回 rabbit 的中间件会引发以下类型的异常:

AMQPException 库错误:表对于缓冲区来说太大

我在这个链接中发现了类似的错误:

https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/10

https://github.com/alanxz/rabbitmq-c/issues/224

https://github.com/php-amqp/php-amqp/issues/131

但我没有看到提供的任何解决方案或解决方法!

【问题讨论】:

  • 发送 2-3Mb 的消息对我来说有点像反模式。消息应该很小,具有必要的信息(例如 ids)以在使用消息时恢复获取数据。通过消息队列发送尽可能多的数据是相当不切实际的。

标签: php symfony rabbitmq symfony-messenger


【解决方案1】:

我找到了一种解决方法:当消息被重定向回队列(稍后重试)时,会添加一个巨大的标记 在我的序列化程序中,在“编码”方法中,我过滤了标记:

$allStamps = [];
        foreach ($envelope->all() as $stampKey => $stamps) {
            if ($stampKey  === 'Symfony\Component\Messenger\Stamp\ErrorDetailsStamp') {
                // this header could be huge and drasticaly increase a size of a message
                continue;
            }
            $allStamps = array_merge($allStamps, $stamps);
        }

        return [
            'body' => serialize($messageBody),
            'headers' => [
                // store stamps as a header - to be read in decode()
                'stamps' => serialize($allStamps),
            ],
        ];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-20
    • 1970-01-01
    • 2013-06-15
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多