问题
In out current project we have been sending xml as textmessage using jms. I do not understand why are they not simply sending Objectmessage, why have the overhead of processing xml ?
so the question basically boils down to why use xml in jms ?
回答1:
It all boils down to a design decision on the message serialization format.
At first Objectmessage would appear to be the most efficient mechanism. However it would not work well in the following scenarios:
- Message validation (XML Schemas act as a form of message contract)
- Differences in software versions between sender and receiver (Message versioning)
- Communication with non-Java systems
Serializing the message in XML does not completely solve these problems, but some form of human readable message format enables debugging.
Finally, XML is not the only game in town. JSON is becoming popular as an XML alternative. Protocol Buffers is Google's messaging protocol and has a good overview on some of the problems and Google's solution.
回答2:
The main benefit of using XML in this situation is that you remove the dependency on having the same software stack at both ends of the communication.
I once came across a client who was exchanging data with a key supplier by creating a daily image of their SQL server database at one end, and restoring it at the other. Consequence: neither party could upgrade to a new verion of SQL server unless the other party also upgraded on the same day.
Further, as O'Connor also mentioned, XML makes it relatively painless to extend the message contents as requirements change, without everyone having to implement the change simultaneously.
来源:https://stackoverflow.com/questions/10368343/what-is-benefit-of-sending-xml-using-jms