Announcement Announcement Module
Collapse
No announcement yet.
Spring integration 2.1.2 cannot get service activators inside chain as BeanDefinition Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring integration 2.1.2 cannot get service activators inside chain as BeanDefinition

    Hi,

    I've just moved my project from spring integration 2.0.4.RELEASE to 2.1.2.RELEASE (also tried 2.1.3.RELEASE) and I'm having problems retrieving beans nested inside of a chain.

    Code:
    	<int:chain id="chain" input-channel="rabbitConsumer" auto-startup="true">
    		<int:filter ref="messageFilteringStrategyImpl" method="accept" />
    		<int:transformer ref="unmarshallPayload" method="transformPayload" />
    		<int:service-activator ref="datablockRequestTransformerImpl" method="transformRequest" />
    		<int:service-activator ref="datablockServiceEntryPointImpl" method="executeDatablock" />
    		<int:service-activator ref="responseClaimCheckDataStoreImpl" method="persistResponse" />
    	</int:chain>
    Previously I was able to get a handle on these beans using the XmlBeanFactory. I need to programatically replace the ref of one of the ServiceActivators to that of reference passed in. My only change to the code was that I updated the dependency version and changed the namespace to http://www.springframework.org/schem...ration-2.1.xsd where it was previously 2.0

    Does anyone have any ideas of how to get a handle on these beans? Any help would be much appreciated

    Thanks

  • #2
    This change was made to resolve another issue https://github.com/SpringSource/spri...ainParser.java

    Generally, a chain is considered a "black box".

    Can you explain your use case in more detail; there may be other solutions.

    Comment


    • #3
      Thanks for the quick reply.

      We have an infrastructure project which has our messaging configuration which has been abstracted away from our message enabled projects. All the message enabled projects have this as a dependency so they can avoid configuring their own beans, and centralise the messaging configuration.

      Using extensible XML authoring we have created a BeanDefinitionParser to parse a custom namespace from the message enabled projects. This namespace provides configuration to the messaging beans,

      Code:
      <datablock-infrastructure:datablock-infrastructure ref="myDatablockService" queueName="${queue.name}" datablockName="${datablock.name}"/>
      Using the BeanDefinitionPaser we then get a handle on the ref element, check it is of the type datablockServiceEntryPointImpl and substitute the targetObject field of the service activator in the chain for that provided by the client project.

      This way the client doesn't need to know about the underlying configuration or how it is required to be configured.

      Comment


      • #4
        On way would be to write a BeanFactoryPostProcessor; call getBeanNamesForType(MessageHandlerChain.class); iterate over the results, getting the bean definitions by name; access the 'handlers' property. That is a list of BeanDefinitionHolders; iterate over it, accessing the BeanDefinition therein; if it matches the criteria, update its properties as needed.

        But, it would probably be much simpler to just use expressions in your <service-activator/>s.

        For example, instead of

        Code:
        <int:service-activator ref="datablockServiceEntryPointImpl" method="executeDatablock" />
        use

        Code:
        <int:service-activator expression="@datablockServiceEntryPointImpl.executeDatablock(payload)" />
        Then, the client is just required to provide a <bean/> called "datablockServiceEntryPointImpl" - perhaps via your custom namespace handler.

        edit: Well, actually, this is no different to using a ref and method
        Last edited by Gary Russell; Jul 4th, 2012, 05:54 PM.

        Comment

        Working...
        X