View Full Version : Starting a ChannelAdapter when auto-start = false
cmdunn01886
Oct 16th, 2009, 01:50 PM
I have set the auto-startup attribute on my ChannelAdapter to false and would like to programmatically start it. How do I accomplish this?
Thanks.
Mark Fisher
Oct 16th, 2009, 01:56 PM
You can do a bean lookup (or inject it by reference).
One question: does the channel-adapter have both "id" and "channel" attributes?
cmdunn01886
Oct 16th, 2009, 02:00 PM
Just the id. I'm sorry - I'm missing something in your response. If I lookup the bean via the context, I get the bean - in this case the DirectChannel.
<pre>
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(serviceResources);
DirectChannel endpoint = (DirectChannel)ctx.getBean("xmlFile");
</pre>
There is no way to start it, correct?
<pre>
<file:inbound-channel-adapter id="xmlFile"
directory="file:/virat/inputxml"
auto-create-directory="false"
auto-startup="false"
filename-pattern=".+.xml">
<integration:poller>
<integration:interval-trigger time-unit="SECONDS" interval="1"/>
</integration:poller>
</file:inbound-channel-adapter>
</pre>
Mark Fisher
Oct 16th, 2009, 02:50 PM
Yes, that's why I asked about the "id" and "channel". If you don't provide a value for "channel", then the value in "id" is used as the name of an auto-created channel. So, you have two options:
1) create a channel and reference it from the "channel" attribute so that the "id" value is used for the adapter bean instead of the auto-created channel bean
2) lookup the bean named "x.adapter" where "x" is the value of your "id" attribute (and hence the channel name)
This was originally designed to be a *convenience* but after explaining it a few times, I realize it can be a bit confusing.
Hope that helps.
Mark
cmdunn01886
Oct 16th, 2009, 02:57 PM
Mark,
It makes sense now. Thanks for the explanation.
Mike
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.