Announcement Announcement Module
Collapse
No announcement yet.
Advice-chain class type. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Advice-chain class type.

    Hi,
    I'm using spring integration amqp. I have a doubt about the advice chain attribute of channel adapter. I had configured it as follows.

    Code:
     <int-amqp:inbound-channel-adapter id="myAdapter"
                                          channel="mychannel"
                                          queue-names="myQueue"
                                          connection-factory="rabbitConnectionFactory"
                                          advice-chain="retryAdviceChai"
                />
    <bean id="retryOperationsInterceptor"
              class="org.springframework.amqp.rabbit.config.StatelessRetryOperationsInterceptorFactoryBean">
            <property name="retryOperations">
                <bean class="org.springframework.retry.support.RetryTemplate">
                    <property name="retryPolicy">
                        <bean class="com.manorama.m4marry.integration.errorhandling.ExceptionBasedRetryPolicy">
                            <property name="maxAttempts" value="3" />
                        </bean>
                    </property>
                </bean>
            </property>
     </bean>

    And this configuration worked. but when I had a look into schema spring-integration-amqp I found that the expected type of advice chain in java.util.collection

    Code:
    <xsd:attribute name="advice-chain" type="xsd:string">
        <xsd:annotation>
            <xsd:appinfo>
                 <tool:annotation kind="ref">
                     <tool:expected-type type="java.util.Collection"/>
                 </tool:annotation>
                 <xsd:documentation>
                       Array of AOP Advice instances to be applied to the MessageListener.
                 </xsd:documentation>
            </xsd:appinfo>
        </xsd:annotation>
    </xsd:attribute>

    This got me confused as my retryAdviceChain is of type org.springframework.amqp.rabbit.config.StatelessRe tryOperationsInterceptorFactoryBean.

  • #2
    This is one of the reasons why we all love the Spring Framework.

    It automatically converts from a singleton to an array (or Collection) if that's what the required type is and you only supply a singleton.

    This simply saves us from creating a collection or array bean, when we really don't need one.

    Actually, the schema is wrong, it says the type is a Collection, when it's actually an array (Advice[]). But, Spring knows how to convert a Collection to an array too!!

    Comment

    Working...
    X