Announcement Announcement Module
Collapse
No announcement yet.
jms:outbound-channel-adaptor and message-converter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jms:outbound-channel-adaptor and message-converter

    I am attempting to use spring -integration with hornetq as a live-backup pair. In a failover scenario, messages are redelivered. Having ran some tests, i found a message was sent twice, reading: duplicate-detection, I wrote my own message converter that extended spring integrations HeaderMappingMessageConverter and uses some reflection to be able to set the appropriate message property (message.setStringProperty(org.hornetq.api.core.Me ssage.HDR_DUPLICATE_DETECTION_ID.toString(), getUniqueIdFromField(object))

    I then tried to wire this into my spring integration config:

    Code:
        <beans:bean id="hqMsgConverter" class="com.xxx.yyy.HornetQNoDupsMessageConverter" >
             <beans:property name="uniqueIdFieldName" value="id" />
             <beans:property name="className" value="com.xxx.yyy.DataItem" />
         </beans:bean>
    
      <jms:outbound-channel-adapter destination="DeliveredQueue"
                                          channel="deliverednputChannel"
                                          message-converter="hqMsgConverter"/>
    When I attached the remote debugger my class was never called, only the HeaderMappingMessageConverter.

    I looked at the source of JmsOutboundChannelAdapterParser (I am using 2.0.0.M2 and i also checked in the svn repositiory JmsOutboundChannelAdapterParser.java, I can see no reference to any useage of the message-converter attribute (other than it being allowable by the schema). It does not appear to be an constant on the JmsAdapterParserUtils like the others.

    I was really hoping to be able to use the message-converter without having to wire it into a jms-template.

    Please let me know the correct intention of message-converter on the outbound-channel-adapter and if this is a bug or not.

    Thanks.

  • #2
    OK I can see it being set in the code JmsOutboundGateway.java.

    I will download and wire in the latest version of Spring Integration, and run the remote debugger over it to check that all is being initalised correctly.

    Comments still appreciated until i get to check (I am on Australian time, so it will be another 12 hours before i am back at my desk to check it properly)

    Comment


    • #3
      I have been unable to get the messageConverter to kick in unless using a message template.

      I wanted to do this:

      Code:
      <jms:outbound-channel-adapter destination=SendQueue"
                                            channel="dispatchDataItemInputChannel"
                                            connection-factory="connectionFactoryHornetQ"
                                            message-converter="hqMsgConverter"
                                            />
      But instead, could only get it to work, when using a custom jmsTemplate, as follows:

      Code:
       <beans:bean id="SendTemplate" class="org.springframework.jms.core.JmsTemplate">
              <beans:property name="connectionFactory"  ref="connectionFactoryHornetQ"/>
              <beans:property name="defaultDestination" ref="SendQueue" />
              <beans:property name="messageConverter"   ref="hqMsgConverter" />
          </beans:bean>
      
         
        <jms:outbound-channel-adapter channel="dispatchDataItemInputChannel"
                                      jms-template="SendTemplate" />
      Whilst this provides me with a workaround, it is not fitting into spring integration in the way i hoped.


      Please advise if this is a bug and can be fixed?

      Comment


      • #4
        Could you please open an issue in JIRA? If you can attach a simple, isolated, reproducible test case that would be ideal.

        Also, what version are you using currently (still M2)?

        Comment


        • #5
          I upgraded to M4 and the latest spring, 3.0.3. So this issue is with the current version.

          I will produce the test case tomorrow and attach it to the jira.

          Thanks for listening.

          Ben

          Comment


          • #6
            Ben,

            I just created this issue: https://jira.springsource.org/browse/INT-1203

            I was able to reproduce it... should be committing a fix soon.

            Thanks for discovering it!
            -Mark

            Comment


            • #7
              I resolved the issue. Please try it out when you get a chance. We are hoping to release 2.0 M5 tomorrow.

              Comment


              • #8
                Excellent news, I did not spot your message until after i built my test case. I attached it to the jira anyway. I wrote it as a standalone project since it has taken me over 6 hours to attempt to get the source from svn, not sure why, but its really slow.

                The test case tests it through spring config and uses mockrunner jms configuration.

                Thanks for fixing the issue, will try it once M5 is release.

                Comment


                • #9
                  Thanks. Have taken M5 and confirmed it works now with the message-converter.

                  As a side note (and for others) I can see that using the jms-template causes it to break, with the following exception shown below:

                  Caused by: org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'jmsTemplate' of bean class [org.springframework.integration.jms.JmsSendingMess ageHandler]: Bean property 'jmsTemplate' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

                  at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:1016)


                  The test case i attached to the jira covers the problem, but i will reopen the jira and recoment there too.

                  Thanks again for making the change, just need to fix the use of jms-template again :-)

                  Comment


                  • #10
                    Added comment to the jira but was unable to re-open it.

                    Comment

                    Working...
                    X