Results 1 to 6 of 6

Thread: Using Property Placeholder for Message Channel ID

  1. #1
    Join Date
    Jun 2012
    Posts
    4

    Default 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:

    Code:
    <context:property-placeholder/>
    
    <int:channel id="${channel.name}"/>
    Thank you.

  2. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    632

    Default

    Hello

    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:
    Code:
    <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.

    Cheers,
    Artem Bilan

  3. #3
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Can you explain why you need to configure the name of the channel; perhaps there's another solution to your underlying issue.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #4
    Join Date
    Oct 2012
    Location
    Bangalore, India.
    Posts
    3

    Default

    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!
    Code:
    <int-jdbc:inbound-channel-adapter
    		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" />
    		</int:poller>
    </int-jdbc:inbound-channel-adapter>
    Regards, Seshu.
    Last edited by Gary Russell; Oct 25th, 2012 at 08:44 AM.

  5. #5
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

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

    See this thread - http://forum.springsource.org/showth...apter-creation

    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.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  6. #6
    Join Date
    Oct 2012
    Location
    Bangalore, India.
    Posts
    3

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •