I believe I figured it out. Rather than calling stop() on my ApplicationContext, I need to call shutdown() on my TaskScheduler instance. So with my own Trigger implementation and my own "taskScheduler" bean defined with its "waitForTasksToCompleteOnShutdown" property set to true, this is my resulting class so far. It seems to work as expected. My inbound channel adapter runs the query once like I want, returning a Message who's payload is a List of rows. Is this the right approach?
Code:
@Component
public class Client {
private static ThreadPoolTaskScheduler taskScheduler;
@Inject
public void setTaskScheduler(ThreadPoolTaskScheduler taskScheduler) {
Client.taskScheduler = taskScheduler;
}
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext.xml", Client.class);
taskScheduler.shutdown();
}
}
Including my integration.xml for completeness:
Code:
<int-jdbc:inbound-channel-adapter query="select * from tblData_OutboundTrace where datediff(d, MidnightStartDate, getdate()) = 1 and Extension != '' order by MidnightStartDate asc"
channel="outboundTraceResults"
data-source="pfDataSource">
<poller trigger="runOnceTrigger"/>
</int-jdbc:inbound-channel-adapter>
<channel id="outboundTraceResults"/>
<service-activator id="outboundTraceProcessor" input-channel="outboundTraceResults"
ref="pfMessageHandler" method="processOutboundTraceResults"/>
<beans:bean id="pfMessageHandler"
class="com.myco.phones.trace.PrairieFyreTraceMessageHandler"/>
<beans:bean id="runOnceTrigger"
class="com.myco.scheduling.RunOnceTrigger"/>
<beans:bean id="taskScheduler"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"
p:waitForTasksToCompleteOnShutdown="true"/>