davsclaus
Jan 12th, 2005, 03:13 AM
Hi
Scenario:
My use-case requires me to setup two Tasks after server startup.
Task A (scheduledTaskEDI) will loop forever and listen on an AS/400 dataqueue and process any incomming messages.
Task B (scheduledTaskTilmeldKunde) will do the same as A but listening to a different data queue.
I am using the build Spring support to setup my tasks and active the tasks after server startup using the TimerFactoryBean.
The problems is:
My 2nd task is never setup since the first task is never terminated (loop forever).
My configuration is:
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryB ean">
<property name="daemon">
<value>false</value>
</property>
<property name="scheduledTimerTasks">
<list>
<ref local="scheduledTaskTilmeldKunde"/>
<ref local="scheduledTaskEDI"/>
</list>
</property>
</bean>
<bean id="scheduledTaskTilmeldKunde" class="org.springframework.scheduling.timer.ScheduledTime rTask">
<property name="delay">
<value>10000</value>
</property>
<property name="period">
<value>-1</value>
</property>
<property name="timerTask">
<ref local="checkTilmeldKunde"/>
</property>
</bean>
<bean id="checkTilmeldKunde" class="org.springframework.scheduling.timer.MethodInvokin gTimerTaskFactoryBean">
<property name="targetObject">
<ref local="as400DataQueueTilmeldKunde"/>
</property>
<property name="targetMethod">
<value>listen</value>
</property>
</bean>
<bean id="checkFakturaEDI" class="org.springframework.scheduling.timer.MethodInvokin gTimerTaskFactoryBean">
<property name="targetObject">
<ref local="as400DataQueueEDI"/>
</property>
<property name="targetMethod">
<value>listen</value>
</property>
</bean>
<bean id="scheduledTaskEDI" class="org.springframework.scheduling.timer.ScheduledTime rTask">
<property name="delay">
<value>5000</value>
</property>
<property name="period">
<value>-1</value>
</property>
<property name="timerTask">
<ref local="checkFakturaEDI"/>
</property>
</bean>
And from my Tomcat log it can see that only the first job is started.
Thread-2 12 jan 2005 10:01:24 INFO dk.webfragt.access.as400.AS400DataQueueListener - DataQueueListener starting [EDI]
Thread-2 12 jan 2005 10:01:25 DEBUG dk.webfragt.access.as400.AS400DataQueueListener - Got AS/400 system
Thread-2 12 jan 2005 10:01:25 DEBUG dk.webfragt.access.as400.AS400DataQueueListener - Listening on data queue /QSYS.LIB/L2950TPGM.LIB/EBUDTAQ1.DTAQ, count=1
I have tried setting the deamon property of TimerFactoryBean to both true or false. But it never works.
If I change my code to terminate in the task instead of looping forever. Both jobs are started as the log below profs:
Thread-2 12 jan 2005 10:09:58 INFO dk.webfragt.access.as400.AS400DataQueueListener - DataQueueListener starting [EDI]
Thread-2 12 jan 2005 10:10:03 INFO dk.webfragt.access.as400.AS400DataQueueListener - DataQueueListener starting [TilmeldKunde]
I can see from the log above that both tasks are using the same thread Thread-2, but it could be the fact that the first job has terminated and thus Thread-2 is avail.
So what do you do to make sure that my 2 tasks are using their own thread?
Scenario:
My use-case requires me to setup two Tasks after server startup.
Task A (scheduledTaskEDI) will loop forever and listen on an AS/400 dataqueue and process any incomming messages.
Task B (scheduledTaskTilmeldKunde) will do the same as A but listening to a different data queue.
I am using the build Spring support to setup my tasks and active the tasks after server startup using the TimerFactoryBean.
The problems is:
My 2nd task is never setup since the first task is never terminated (loop forever).
My configuration is:
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryB ean">
<property name="daemon">
<value>false</value>
</property>
<property name="scheduledTimerTasks">
<list>
<ref local="scheduledTaskTilmeldKunde"/>
<ref local="scheduledTaskEDI"/>
</list>
</property>
</bean>
<bean id="scheduledTaskTilmeldKunde" class="org.springframework.scheduling.timer.ScheduledTime rTask">
<property name="delay">
<value>10000</value>
</property>
<property name="period">
<value>-1</value>
</property>
<property name="timerTask">
<ref local="checkTilmeldKunde"/>
</property>
</bean>
<bean id="checkTilmeldKunde" class="org.springframework.scheduling.timer.MethodInvokin gTimerTaskFactoryBean">
<property name="targetObject">
<ref local="as400DataQueueTilmeldKunde"/>
</property>
<property name="targetMethod">
<value>listen</value>
</property>
</bean>
<bean id="checkFakturaEDI" class="org.springframework.scheduling.timer.MethodInvokin gTimerTaskFactoryBean">
<property name="targetObject">
<ref local="as400DataQueueEDI"/>
</property>
<property name="targetMethod">
<value>listen</value>
</property>
</bean>
<bean id="scheduledTaskEDI" class="org.springframework.scheduling.timer.ScheduledTime rTask">
<property name="delay">
<value>5000</value>
</property>
<property name="period">
<value>-1</value>
</property>
<property name="timerTask">
<ref local="checkFakturaEDI"/>
</property>
</bean>
And from my Tomcat log it can see that only the first job is started.
Thread-2 12 jan 2005 10:01:24 INFO dk.webfragt.access.as400.AS400DataQueueListener - DataQueueListener starting [EDI]
Thread-2 12 jan 2005 10:01:25 DEBUG dk.webfragt.access.as400.AS400DataQueueListener - Got AS/400 system
Thread-2 12 jan 2005 10:01:25 DEBUG dk.webfragt.access.as400.AS400DataQueueListener - Listening on data queue /QSYS.LIB/L2950TPGM.LIB/EBUDTAQ1.DTAQ, count=1
I have tried setting the deamon property of TimerFactoryBean to both true or false. But it never works.
If I change my code to terminate in the task instead of looping forever. Both jobs are started as the log below profs:
Thread-2 12 jan 2005 10:09:58 INFO dk.webfragt.access.as400.AS400DataQueueListener - DataQueueListener starting [EDI]
Thread-2 12 jan 2005 10:10:03 INFO dk.webfragt.access.as400.AS400DataQueueListener - DataQueueListener starting [TilmeldKunde]
I can see from the log above that both tasks are using the same thread Thread-2, but it could be the fact that the first job has terminated and thus Thread-2 is avail.
So what do you do to make sure that my 2 tasks are using their own thread?