Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Spring Integration 2.1 compliance question

  1. #1
    Join Date
    Mar 2012
    Posts
    6

    Default Spring Integration 2.1 compliance question

    Hi,

    I tried to update our project to Spring Core 3.1.0 (from 3.0.6)
    and Spring Integration 2.1.0 (from 2.0.5).

    Some of our tests were broken now, because a
    string of the payload seems not to be extracted any more using
    a si-mail:outbound-channel-adapter.

    Caused by: org.springframework.integration.MessageHandlingExc eption: Unable to create MailMessage from payload type [javax.xml.transform.dom.DOMSource], expected MimeMessage, MailMessage, byte array or String.
    at org.springframework.integration.mail.MailSendingMe ssageHandler.convertMessageToMailMessage

    Using Spring Core 3.1.0 with Spring Integration 2.0.5 still works.

    Any help is highly appreciated.
    Thanks.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    Can you provide a bit more info about the upstream components? I don't think the change is a result of the mail adapter but rather something upstream that maybe used to send a String payload but now sends a DOMSource.

    A quick fix would be to add a transformer (from Source to String) OR even register a Converter and make the input-channel to your mail adapter a Datatype Channel (by adding the 'datatype' attribute).

    -Mark

  3. #3
    Join Date
    Mar 2012
    Posts
    6

    Default

    Well, our use case is a whole workflow of small steps resulting in a web service call and a confirmation E-Mail message:

    1) Marshall the relevant subset of our domain to some export object structure:

    <si:channel id="eoObjectInputChannel"/>

    <oxm:jaxb2-marshaller id="eoMarshaller" contextPath="somePackage"/>
    <bean id="resultToStringTransformer" class="org.springframework.integration.xml.transfo rmer.ResultToStringTransformer"/>

    <si-xml:marshalling-transformer marshaller="eoMarshaller" id="eoMarshallerTransformer"
    input-channel="eoObjectInputChannel" output-channel="eoXmlOutputChannel"
    result-transformer="resultToStringTransformer"/>

    <si:channel id="eoXmlOutputChannel"/>

    2) Perform some XSLT transformations on the marshalled export objects:

    <si:channel id="eoXmlInputChannel"/>

    <si-xml:xslt-transformer id="xsltTransformer" xsl-resource="classpath:somePath/transformation.xslt"
    input-channel="eoXmlInputChannel" output-channel="elfXmlOutputChannel"/>

    <siublish-subscribe-channel id="elfXmlOutputChannel"/>

    3) Send the transformed XML to the destination web service:

    <si:bridge input-channel="elfXmlOutputChannel" output-channel="elfXmlInputChannel"/>
    <si:bridge input-channel="elfXmlOutputChannel" output-channel="elfXmlInputForMailChannel"/>

    <si:channel id="elfXmlInputChannel"/>

    <si:chain input-channel="elfXmlInputChannel" output-channel="replyChannel">
    <si-ws:header-enricher>
    <si-ws:soap-action value="http://someUrl"/>
    </si-ws:header-enricher>
    <si-ws:outbound-gateway id="staterFinalAgreementService"
    destination-provider="finalAgreementDestinationProvider"
    message-sender="messageSenderImpl'}">
    </si-ws:outbound-gateway>
    </si:chain>

    <si:channel id="replyChannel"/>

    <si:bridge input-channel="replyChannel" output-channel="staterReplyForMailChannel"/>

    5) Confirmation mailing setup:

    <si:channel id="elfXmlInputForMailChannel"/>
    <si:channel id="staterReplyForMailChannel"/>

    <si-mail:header-enricher input-channel="elfXmlInputForMailChannel" output-channel="outboundMail">
    <si-mail:to value="#{loggingAddresses}"/>
    <si-mail:from value="some address"/>
    <si-mail:subject value="Some Subject"/>
    </si-mail:header-enricher>

    <si-mail:header-enricher input-channel="staterReplyForMailChannel" output-channel="outboundMail">
    <si-mail:to value="#{loggingAddresses}"/>
    <si-mail:from value="some address"/>
    <si-mail:subject value="Some Subject"/>
    </si-mail:header-enricher>

    <si:channel id="outboundMail"/>

    <si-mail:outbound-channel-adapter channel="outboundMail" mail-sender="mailSenderImpl"/>

    <bean id="mailSenderImpl" class="org.springframework.mail.javamail.JavaMailS enderImpl">
    <property name="javaMailProperties" ref="javaMailProperties"/>
    <property name="host" value="#{loggingHost}"/>
    </bean>

    5) Logging Interceptors for each step

    <si:channel id="loggingChannel"/>

    <si:channel-interceptor>
    <si:wire-tap channel="loggingChannel"/>
    </si:channel-interceptor>

    <bean id="logger" class="somePackage.SpringIntegrationLogger"/>
    <si:service-activator id="loggerService" input-channel="loggingChannel" expression="@logger.log(payload)"/>

    As of Spring Integration 2.1 two integration tests testing the whole workflow fail during mail transfer.
    The DOMSource containing the SOAP message is something we set in a web service message of a
    mocked web service connection.

    With Spring Integration 2.0.5 the SOAP body was automatically converted to a String, now
    MailSendingMessageHandler.convertMessageToMailMess age refuses to accept a DOMSource as payload.

    Thanks.

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    So you if I understand you correctly what you are saying is that the following gateway is returning different result type (DOMSource instead of String) Could you please confirm?

  5. #5
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    Can you run with DEBUG logging? I'd like to specifically see the payload types as we transition through the transformers, and particularly into the chain via elfXmlInputChannel.

    Can you run the same test with 2.0.5 and compare?
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  6. #6
    Join Date
    Mar 2012
    Posts
    6

    Default

    I realize that there is a difference between 2.0.5 and 2.1.0 at

    <si:bridge input-channel="replyChannel" output-channel="staterReplyForMailChannel"/>

    In 2.0.5 the payload is a string in 2.1.0 a DOMSource.

  7. #7
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    That's impossible, not at the <bridge>. MessagingBridge is the simplest component you can possibly imagine but most importantly it doesn't do anything to a Message other than moving it from one channel to another. So whatever is happening must be happening upstream.

  8. #8
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    In 2.0.5 the payload is a string in 2.1.0 a DOMSource....
    Right - we already know that from your exception - that's why I asked for the log; I need to see the payload types as the message passes through the transformers; the output type of the gateway depends on its input. If the input is a String, the output will be a String.

    The only way I can see the gateway emitting a DOMSource is if its input was a Source.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  9. #9
    Join Date
    Mar 2012
    Posts
    6

    Default Integration Test Debug Log

    Enclosed you will find the DEBUG logs of 2.0.5 and 2.1.0

  10. #10
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    The problem is with your Mock, when we extract the response data, the code is now expecting a SoapMessage; if it's not we just extract the Source...

    Code:
    Object resultObject = this.doExtractData(message);
    
    if (message instanceof SoapMessage){			
    	Map<String, Object> mappedMessageHeaders = headerMapper.toHeadersFromReply((SoapMessage) message);
    	Message<?> siMessage = MessageBuilder.withPayload(resultObject).copyHeaders(mappedMessageHeaders).build();
    	return siMessage;
    }
    else {
    	return message.getPayloadSource();
    }
    It looks like your Mock is not returning a SoapMessage; I'll need to investigate further as to whether this is a bug.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •