Laravel RabbitMQ可以从另一种编程语言中消耗消息吗?

发布于 2025-02-14 02:12:06 字数 350 浏览 0 评论 0原文

我已经阅读了这篇文章生产者/消费者的语言不同的语言生产者的消息即使生产者使用不同的编程语言,但是如何使用Laravel实施该东西。例如,我有一个生产者使用nodejs和laravel作为消费者,我使用作为驱动程序

I have read this post Different language for producer / consumer, they say it's possible to consume messages from producers even though the producers are in different programming languages, but how to implement that thing using laravel. For example i have a producer using nodejs and laravel as a consumer, i use laravel-queue-rabbitmq as driver

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

汐鸠 2025-02-21 02:12:06

是的,您可以为生产者 /完善者提供不同的语言。这是使用RabbitMQ在服务之间进行异步交流的主要目的之一。

您可以在官方文档上找到node.js和php的示例。

如果您更喜欢使用Laravel库,那也很好。只需阅读并遵循提供的读书说明即可。

Yes, you can have different languages for producer / consummer. It's one of the main purpose of using Rabbitmq to communicate asynchronously between services.

You can find example if both Node.js and PHP on the official documentation.

If you prefer to use a Laravel library instead, it's fine too. Just read and follow README instructions provided.

他不在意 2025-02-21 02:12:06

我想扩展上一个答案。虽然可以由任何生产者创建该消息(用任何语言编写),但Laravel队列将特定的有效负载写入消息主体,例如

{
"uuid": "d3bb48e4-cd10-42bc-90e3-8b80c381a342",
"displayName": "App\\Jobs\\UpdateSearchTableJob",
"job": "Illuminate\\Queue\\CallQueuedHandler@call",
"maxTries": null,
"maxExceptions": null,
"failOnTimeout": false,
"backoff": null,
"timeout": null,
"retryUntil": null,
"data": {
    "commandName": "App\\Jobs\\UpdateSearchTableJob",
    "command": "O:29:\"App\\Jobs\\UpdateSearchTableJob\":1:{s:7:\"\u0000*\u0000data\";a:2:{s:10:\"type\";s:5:\"user\";s:2:\"id\";s:3:\"123\";}}"
},
"id": "02f7d3f2-9234-4d6c-97f4-01c301774560"

}

此有效负载特定于Laravel Jobs。
因此,如果您想在Laravel应用程序中使用此作业,则需要在生产该事件的(非laravel/non-PHP)应用程序中反向工程载荷。

I want to extend on the previous answer. While the message can be created by any producer (written in any language), the laravel queue writes a specific payload into the message body, like

{
"uuid": "d3bb48e4-cd10-42bc-90e3-8b80c381a342",
"displayName": "App\\Jobs\\UpdateSearchTableJob",
"job": "Illuminate\\Queue\\CallQueuedHandler@call",
"maxTries": null,
"maxExceptions": null,
"failOnTimeout": false,
"backoff": null,
"timeout": null,
"retryUntil": null,
"data": {
    "commandName": "App\\Jobs\\UpdateSearchTableJob",
    "command": "O:29:\"App\\Jobs\\UpdateSearchTableJob\":1:{s:7:\"\u0000*\u0000data\";a:2:{s:10:\"type\";s:5:\"user\";s:2:\"id\";s:3:\"123\";}}"
},
"id": "02f7d3f2-9234-4d6c-97f4-01c301774560"

}

This payload is specific to Laravel jobs.
So if you want to consume this job in a Laravel application, you would need to reverse-engineer this payload in your (non-Laravel/non-PHP) application that produces the event.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文