Friday, May 9, 2008

servicemix problems: NormalizedMessage getContent,copyPropertiesAndAttachments()

Though servicemix is widely used and very nice ESB framework, it has some basic problems.The one i am talking about here is very little thing but it can be annoying if you forget this or don't know this.

While creating and sending NormalizedMessage object from any data, after doing that if you read data using NormalizedMessage.getContent() method and send the message object with exhchange to deliveryChannel, using DeliveryChannelImpl.send(MessageExchange) method, then you will get null exception in DeliveryChannelImpl class.

Yes this is true.I don't know why, but it removes content from the message object.Only the content is removed and the properties are still there.

You can read properties from it in same component as many times as you want.If you are forwarding same message to next component, properties will automatically goes.But if you read content once, you must set it again :(.

Also remember that if you need to make new MessageExchange, then you must copy all properties and attachments using TransformComponentSupport.copyPropertiesAndAttachments(outExchange,inMsg,outMsg) method.Then all your data from one message will be copied to another message.

So keep checking this if you getting null Exceptions while sending message through DeliveryChannel.

0 Comments: