ESB messages API and design considerations
karypid Sep 12, 2008 6:36 AMI'm a newcomer to JBossESB and am having trouble understanding the API and rationale behind message factories and the body. I would appreciate some feedback to these very basic questions:
I set a breakpoint in my message composer code and using the variable inspector I observed that:
When you use the XMLMessageFactory to create a text message, it creates an entry in the table of objects that belong to the message body. The key used is "org.jboss.soa.esb.message.payload.text", which is the constant value for TextBody.DEFAULT_LOCATION.
If you simply use a MessageFactory, an entry is created in the message objects table under the key Body.DEFAULT_LOCATION (whose value is "org.jboss.soa.esb.message.defaultEntry").
Now, all actions that pre-ship with the JBoss ESB expect the message body to reside at Body.DEFAULT_LOCATION. So, if you create your message using an XMLMessageFactory, all these goodies are useless, because they can't "see" your message body.
My understanding was that the basic things you need to decide in order to create your message, are:
The kind of serialization you want to use withing the ESB: this means you must choose either XMLMessageFactory or SerializedMessageFactory.
What will be in the message body. This means that you must choose a TextBody, ObjectBody, BytesBody, or MapBody).
So, here's the list of things that don't make sense:
Why is MessageFactory non-abstract? Shouldn't one be forced to use XML / Java serialization (or roll their own)? I would've expected it to be abstract and for XMLMessageFactory and SerializedMessageFactory to extend it. If you want some other serialization, you would need to extend MessageFactory and implement the message construction methods.
Since MessageFactory is (evidently) non-abstract, what serialization does it use?
I would've expected the message factories (XMLMessageFactory and SerializedMessageFactory) to place the body under the Body.DEFAULT_LOCATION key. Why don't they do that?
In fact, what's the point of having various message body types (TextBody, ObjectBody, etc)? Is it to improve legibility of the code? (admittedly, writing "TextBody" immediately reveals to the developer reading it what one is working with text here)