Announcement Announcement Module
No announcement yet.
DOMResult to JMS message conversion exception Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DOMResult to JMS message conversion exception

    Hi All,

    I am writing a sample with SI 1.0.4.

    I want to send a XML message to a queue and then convert the message using unmarshaller to the corresponding Java object.

    2) After doing some processing the sample should marshall the response to an XML and put it on a channel.

    The channel message will be picked up jms:outbound-channel-adapter so that it can put it on reply queue.


    However when marshaller is done with creation of DOMResult object the JMS adaptor fails to picup and put it on the queue with error---

    HTML Code:
    Cannot convert object of type [javax.xml.transform.dom.DOMResult] to JMS message. Supported message payloads are: String, byte array, Map<String,?>, Serializable object.

    Can someone please suggest if I need to use some other type of JMS adaptor to recieve message on channel and put on queue? Or I need to do something else.

    Any help will be of great help.

    P.S-- Kind of struggling for half day

  • #2
    I have encountered this too. I created a DOMResult to String transformer and sent the message through this transformer before hitting the JMS outbound adapter. I'm not sure if there's already something in the framework you can use but this did the trick for me.


    • #3
      What component is producing the DOMResult? Is it something in Spring Integration or something of your own?

      In 2.0, we're adding support for Spring 3.0's new ConversionService API. That is currently supported for any SpEL evaluation, any method-invocation via the "standard" MessageHandler implementations (e.g. Service Activator), and any "Datatype Channel".

      If you are using 2.0 M4, you could add a "datatype" attribute with a value of "java.lang.String" to the channel that precedes the JMS adapter. Then, you could define a ConversionServiceFactoryBean with a custom implementation of a DOMResult-to-String Converter. That bean's id should be "integrationConversionService".

      We should probably consider providing a library of Converters that could easily be enabled. For example, we might provide this in the XML support JAR, and then we could even provide namespace support to configure those Converters for the "integrationConversionService". Please let me know if you think that's a good idea... or if you have a better one.



      • #4
        I haven't got my source to hand but I believe it's as a result of using the ws inbound gateway component with a marshaller configured.

        Your idea seems like a good one to me. Perhaps building up a library of converters is something the community could easily contribute towards.


        • #5
          Thanks for reply. I too used the ResultToStringTransformer feeding DOmResult but team does not seem to be too happy

          Yes, I used SI oxm:jibx-marshaller to create DomResult out of java object. I am going to have the component by June end in prod.

          So, I doubt I will be able to use Spring-I 2.0 as this seems to be scheduled for prod release by July end.
          And, idea of convertors is definitely looks bright.


          • #6

            I have a small query related to this-

            We have a client sends the JMS message conating XML content over Queue which is being listened by jms:message-driven-channel-adapter.

            From adaptor I put the message on xmlTypeChannel and use oxm:jibx-marshaller to unmarshall the message to create a custom object.

            I am wondering if I can get SI/JMS headers into the unmarshalled object to store header values like messageID/correlationID. And, similarly I would like to set these IDs in the response XML as I created above in the message on UnMarshall?

            I am searching on google for some inputs but any pointer by you on this will be of great help.


            • #7
              I managed to do this with this configuration (using spring-integration 2.2.2.RELEASE). Hope this helps:

                  <bean id="marshaller" class="">
                  	<property name="proxyInterfaces" value="net.sf.cglib.proxy.Factory,org.hibernate.proxy.HibernateProxy" />
                  	<property name="mappingLocations">
              		<property name="targetClasses">
                  <bean id="resultTransformer" class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />
                  <int-xml:marshalling-transformer marshaller="marshaller" input-channel="toTransformNormaResponses" output-channel="toNormaResponsesQueue" result-transformer="resultTransformer"/>