Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

java - Can message grouping do what message segmentation does?

I'm working on a microservice in java that puts messages on a queue. Since I use JMS, message segmentation isn't possible to use to handle big messages. I was wondering, does message grouping also allow me to handle big messages? By big messages I mean messages bigger than the MaxMsgLength.

question from:https://stackoverflow.com/questions/65945044/can-message-grouping-do-what-message-segmentation-does

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

JMS itself has no support for "message segmentation." However, JMS implementations can implement functionality which goes beyond the specification. For example, ActiveMQ Artemis supports arbitrarily large messages whereby it takes a single, large message and breaks it up into chunks which it streams over the wire and onto disk so that the message is never held in memory at once. Of course, all this is done behind the scenes. The client application just works with the JMS API like it normally would.

Now, if you wanted to break the large message up manually and send it as many smaller, individual JMS messages then I could see where message grouping would help in reassembling the message because each message in the group would be consumed serially by a single consumer. However, it's also possible that the consumer might fail part-way through consuming the whole group so you'll need to ensure you consume all the messages in the group before you acknowledge any of them otherwise you risk losing pieces of the large message which you can never get back. In any case, the consumer will have to know how to reassemble the message once it gets all the pieces together but that could be as simple as appending the bytes of each message in order into a buffer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...