通过 RabbitMQ 发送文件 [英] Send files through RabbitMQ

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

问题描述

通过 RabbitMQ 发送大小约为 1Mb 的文件是个好主意吗?我想以 json 格式发送消息,其中包含与文件对应的二进制字段.

Is it a good idea to send files with size about 1Mb through RabbitMQ? I want to send message in json format with binary fields corresponding to the files.

以及如何使用 spring-amqp 正确地做到这一点?只需通过下一个类发布对象?

And how to do it properly using spring-amqp? Just by publishing object with next class?

class Message {
    String field1;
    byte[] fileField1;
    byte[] fileField2;
}

推荐答案

我建议不仅要阅读那些发布的链接,还要自己做一些实验.我要关心的是服务级别和客户端级别的性能.

I would suggest not only reading those links that were posted but also, doing some of your own experimentation. The thing I would be concerned about is performance at the service level and at the client level.

您可能需要考虑让服务器托管文件/数据,并允许rabbitmq 将消息发送给带有消息ID 的消费者.因此,当您的消费者收到消息时,它会向请求实际消息有效负载的服务发送 HTTP GET 请求.这样 RabbitMQ 就保持轻量级.如果需要,您可以随时添加消费者和服务器.

You might want to consider having a server host the files/data and allow rabbitmq just send the message to the consumer with the id of the message in it. So when your consumer gets the message, it sends an HTTP GET request to a service that requests the actual message payload. That way RabbitMQ stays lightweight. You can always add consumers and servers if you need.

这是我未经实验的意见.您可能会发现它仍然以 1MB 的有效负载快速点亮.这就是为什么我会说要自己尝试并找出答案.

That's my opinion without experimenting. You might find that it's still lighting fast with 1MB payloads. That's why I would say to experiment and find out for yourself.

希望对您有所帮助!

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

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