springxsdspring-amqpspring-rabbit

RabbitTemplate XSD has unmatching property "return-callback"


I am not sure this is a bug or (more likely) my misunderstanding on how spring/XSD work.

I have this xml-defined rabbitTemplate :

    <rabbit:template    id="rabbitTemplate" 
                        connection-factory="rabbitConnectionFactory"  
                        mandatory="true" 
                        channel-transacted="true" 
                        message-converter="simpleMessageConverter"
                        return-callback="rabbitFailedRoutingReturnCallback"/>

Which does not accept the latest property "return-callback" :

[Error creating bean with name 'rabbitTemplate': Invalid property 'returnCallback' of bean class [org.springframework.amqp.rabbit.core.RabbitTemplate]: Bean property 'returnCallback' is not writable or has an invalid setter method. Did you mean 'returnsCallback'?]

Replacing with "returns-callback" as suggested, and although it is present in TemplateParser, does not work since the property is not present in the latest spring-rabbit xsd. And RabbitTemplate look like it has no setter for returnCallback (without 's').

Switching to standard bean definition works fine :

    <bean id="rabbitTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate">
        <property name="connectionFactory" ref="rabbitConnectionFactory" />
        <property name="mandatory"  value="true" />
        <property name="channelTransacted"  value="true" />
        <property name="messageConverter"       ref="simpleMessageConverter" />
        <property name="returnsCallback"        ref="rabbitFailedRoutingReturnCallback" />
    </bean>     

Also, looking at source code from spring-rabbit template source code, it looks fine. So either it has not been published, or I have the wrong url for the published version of it.

So, anyone can help me find out whether it's a bug or my misunderstanding?

(Since I am still uneasy with spring xml definitions and namespaces, and generally absent-minded, I have rather ask here before raising an issue)


Solution

  • There are many similar question on StackOverflow. The answer is: use Spring-aware IDE, e.g. IntelliJ IDEA or Spring Tools Suite. The point is to make your IDE to resolve those XSD files from classpath, essentially from a spring-rabbit.jar. This way it will show you those attributes which are actual for the version for the dependency you use.

    The returns-callback is correct to use:

        NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETURN_CALLBACK_ATTRIBUTE);
        NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETURNS_CALLBACK_ATTRIBUTE);
    

    The first line is a bug, since that deprecated return-callback has to be mapped to the RabbitTemplate.setReturnsCallback().

    I think it is time to remove that return-callback altogether since it was replaced by the returns-callback four years ago.