Link Details

Link 872481 thumbnail
User 199388 avatar

By glamdring
via techblog.bozho.net
Published: Nov 02 2012 / 10:49

You have a system that has multiple components and they have to communicate. They do that either via internal web services or using a message queue. Normally, you would want to send (data transfer) objects from one component to another. In order to achieve these things you need to serialize the objects to some format that will then be deserialized on the other end. Many frameworks include XML and JSON serializers and they are used in many examples online. Therefore people are inclined to use JSON or XML for these purposes. And that's not a good idea.
  • 17
  • 1
  • 1264
  • 1866

Comments

Add your comment
User 203717 avatar

chudak replied ago:

0 votes Vote down Vote up Reply

This approach ignores testability, among other things. It is very easy to craft an xml or json message and drop it on a queue to test the message processing. If I'm using some kind of binary format that becomes quite a bit harder. Also, it is frequently the case that some 'internal' process needs to be exposed to an external consumer at some point. If you've already built your components using a common data interchange format, this is painless. If you've prematurely optimized to use some binary message packing approach you'll have to add another adapter layer. About the only place this kind of optimization makes sense IMO is where you are extremely space constrained, e.g. sending an SMS message to an application on a mobile device or storing some data in a file on a mobile device. For server side work this approach just gets in the way.

User 199388 avatar

glamdring replied ago:

0 votes Vote down Vote up Reply

Disagreed about both points. 1. Testing works ok, for two reasons: 1 you can deserialize the message manually or log it to a console. Also, see 2 2. It is no problem to switch between JSON and a binary format, if you do things properly. If we ever need to get back to JSON, for example, all we need to change is the converter implementation. This also means the JSON converter can be used for quick tests, while MessagePack converter can be used in staging/production.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java