通过 RabbitMQ 发送二进制文件 [英] Sending binary file through RabbitMQ

查看:31
本文介绍了通过 RabbitMQ 发送二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在指定一个使用 RabbitMQ 作为消息队列的设计.该消息将有一个 JSON 正文,特别是对于一条消息,我想添加一个小的二进制文件.

I'm spec'ing a design right now that uses RabbitMQ as a message queue. The message are going to have a JSON body, and for one message in particular I'd like to add a small binary file.

我想知道的是,二进制文件的数据应该是JSON消息的一部分,还是可以单独附加到消息中?

What I'd like to know is, should the binary file's data be part of the JSON message, or can it be appended to the message separately?

推荐答案

消息是一个单字节流,它也包含一个标头,但相关性较低.我建议你采取两种方法之一.您的 JSON 对象包含一个字段,该字段是二进制文件的字节流.或者,它提供了可以下载文件的地址.如果二进制文件很小,那么前者应该可以正常工作.否则你可能更喜欢后者.

The message is a single byte stream, it also contains a header but that is less relevant. I suggest that you take one of two approaches. Your JSON object contains a field that is the byte stream of the binary file. Alternatively it gives the address where the file can be downloaded. If the binary file is small then the former should work fine. Otherwise you may prefer the latter.

这篇关于通过 RabbitMQ 发送二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆