Announcement Announcement Module
No announcement yet.
Using Property Placeholder for Message Channel ID Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Property Placeholder for Message Channel ID

    In Spring 3.1, is it possible to use a property placeholder to resolve the 'id' attribute of a message channel?

    I would like, for example, to do the following in my context.xml file:

    <int:channel id="${}"/>
    Thank you.

  • #2

    No, you can't. Id isn't a property of a bean. It is an identificator in the components registry. It should be something staticaly defined or automaticaly generated by the framefowrk on the background.
    By the way, you can't do this one too:
    HTML Code:
    <bean id="${SOME_PLACEHOLDER}" class="java.lang.String"/>
    However, you can use this trick:
    <service-activator input-channel="channel1" output-channel="${channel2}"/>
    <service-activator input-channel="${channel2}" output-channel="channel3"/>
    End remove from your config channel2 declaration. On the context startup will work org.springframework.integration.config.xml.Channel Initializer, which automaticaly creates DirectChannel's from Endpoints' input-channel attribute, if there is no such channel bean in the context.

    Artem Bilan


    • #3
      Can you explain why you need to configure the name of the channel; perhaps there's another solution to your underlying issue.


      • #4
        Hi Gary,

        My requirement also similar to the one discussed above.

        Requirement: Can we able to dynamically generate the ‘id’ attribute for inbound-channel-adapter by using the property place holder in the SI flow.

        I am developing a piece of code to poll a table using the JDBC inbound adapter. I need to have more than one JDBC adapter in my flow for N number of poller configurations.
        I don't want to hard code all (N number of pollers) the poller configurations (say, 10 poller. one by one). Instead, I need to load them dynamically at the run time using properties.
        This is, to avoid the difficulty of adding of poller configuration in future without modifying code, I Just want to configure the properties.

        Is there any posibilities to generate the id attribute dynamically? find below the code snippet and suggest the feasibility. Thanks!
        		id="${pollingAdaptor}" channel="inputChannel"
        		auto-startup="true" data-source="dataSource" query="${selectQuery}"
        		update="${updateQuery}" update-per-row="true">
        		<int:poller fixed-rate="${pollingInterval}"
        			default="false" error-channel="errorChannel">
        			<int:transactional transaction-manager="txManager" />
        Regards, Seshu.
        Last edited by Gary Russell; Oct 25th, 2012, 09:44 AM.


        • #5
          Please use [ code ] ... [ /code ] tags when posting code/config (no spaces inside brackets - I have edited your post).

          See this thread -

          and follow it's links. It shows how to dynamically create inbound adapters, with property placeholders, in child application contexts. Each adapter can then send messages into the main (parent) context.


          • #6
            Hi Gary,

            Thanks for your inputs. This piece of implementation is really good.

            I can able to dynamically create inbound adapters (child contexts).

            Now I have one more requirement, I need to get and set the properties of the inbound adapters (which is inside the child contexts) using either M-Bean or control bus.

            I didn’t found any interface which exposes getter, setter method for JDBC inbound adapters. Please let me know if any such interfaces exist. If not, how can I set or get the properties of inbound adapters dynamically using M-Bean or Control-Bus. Thanks!

            Regards, Seshu.