Oct 6th, 2006, 11:19 AM
I'm building JMS communication layer in my spring application, which will directly send/receive or pub/sub to Tibco EMS. This part works fine. My next step is to convert my ArrayList of POJOs to XML and send it out...
I'm wondering so many different ways we can do the work, but which is the best way to do it?
- pure Java XML solution: DOM, SAX
- j2ee XML solution: JAXP, JAXB
- open source solution: castor, XMLBean, XStream...
- spring solution: oxm packages which wrapped the above things
Welcome any recommendations and advice.
Oct 6th, 2006, 06:43 PM
Without any requirements, it is hard to give good advice. For instance, if speed is of importance, it is always a good idea not to use any XML marshalling technique, since they are always slower then manual XML handling (especially if using StaX or SAX).
Originally Posted by henry
The only advice I can give you is to localize your choice of technology. Whatever technology you choose, make sure it is only used in only place, hidden behind an generic interface (i.e. without throwing framework specific checked exceptions). Using this design, you can always change the implementation used.
Oct 9th, 2006, 03:29 AM
One can make use of OGNL in such a marshalling tool. I just wrote such an unmarshaller, which weighs only 250 lines of code, but offers functionalities and simplicity that the Castor can only dream of
Oct 9th, 2006, 10:04 AM
Thanks for your advice.
The speed is one of concern along with flexibility, extensibility, and scalability like any enterprise application requirements. Considering those facts, I think I will use both mechanisms - XML marshalling and MessageConverter from spring jms package - to do the conversion work depending the specific requirement. But the spring's SimpleMessageConverter only supports conversion of TextMessage, BytesMessage, and MapMessage. I didn't find anything to support ArrayList, Set, or other complex data types. I think probably we need to develop our own customized MessageConverter. Any advice?
As you suggested in design, I have already written a common jms layer to handle all messaging implemention to/from various destinations - tibco ems, MQ, and other jms providers.
Oct 9th, 2006, 10:13 AM
This sounds good. If it's possible, can you have a sample which do the complex type conversion using OGNL?
Originally Posted by Injecteer
Oct 17th, 2006, 07:40 AM
Originally Posted by henry
Did you completely write a jms layer, or did you use Springs JMS abstraction framework?
Oct 17th, 2006, 09:36 AM
I use Spring way to write whole jms layer, which includes JmsTemplate, JndiTemplate, MDP... Also, I combine StAX to marshal/unmarshal java collection to/from XML. It's great experience.
Originally Posted by beemsoft