Asynchronous Task does not excute
Hi,
I define a asynchronous task in my application, but when server starts, this task does not excute automatically. Why this happens?
I declare service extension in plugin.xml like this:
And my application run on a Jetty Server in eclipse, target platform is Foundation SDK 3.0.1&Eclipse(20110215-2034 dev-offering ). But my jazz foundation server is 3.0.0.
Thanks in advance!
I define a asynchronous task in my application, but when server starts, this task does not excute automatically. Why this happens?
I declare service extension in plugin.xml like this:
<extension
point="com.ibm.team.repository.service.serviceProvider">
<serviceProvider
componentId="com.ibm.ams.pm.polling"
implementationClass="com.ibm.ams.pm.feedreader.task.service.AmsPollingService">
<provides>
<providedService
interface="com.ibm.ams.pm.feedreader.task.IAmsPollingService">
</providedService>
</provides>
</serviceProvider>
</extension>
<extension
point="com.ibm.team.repository.common.components">
<component
id="com.ibm.ams.pm.polling"
name="AMS Polling Service">
<service
kind="RPC"
name="AMS Polling Service"
uri="com.ibm.ams.pm.feedreader.task.IAmsPollingService"
version="1">
</service>
</component>
</extension>
<extension
point="com.ibm.team.repository.service.asynchronousTask">
<asynchronousTask
taskId="com.ibm.ams.pm.FeedReaderTask">
<extensionService
componentId="com.ibm.ams.pm.polling"
implementationClass="com.ibm.ams.pm.feedreader.task.FeedReaderTask">
<prerequisites>
<requiredService
interface="com.ibm.ams.pm.feedreader.task.IAmsPollingService">
</requiredService>
<configurationProperties>
<configurationProperty
accessPolicy="OPEN"
default="10"
description="description"
displayableName="Polling Interval Time"
name="com.ibm.ams.pm.feedreader.FeedReaderTask.fixedDelay"
required="true"
type="STRING"
updatePolicy="FRAMEWORK_RESTART_REQUIRED">
</configurationProperty>
<configurationProperty
accessPolicy="OPEN"
default="600"
description="description"
displayableName="User"
name="com.ibm.ams.pm.feedreader.FeedReaderTask.runAsUser"
required="true"
type="STRING"
updatePolicy="FRAMEWORK_RESTART_REQUIRED">
</configurationProperty>
</configurationProperties>
</prerequisites>
</extensionService>
</asynchronousTask>
</extension>
And my application run on a Jetty Server in eclipse, target platform is Foundation SDK 3.0.1&Eclipse(20110215-2034 dev-offering ). But my jazz foundation server is 3.0.0.
Thanks in advance!
3 answers
Configuration property names and task ids should be relative to the component that provides the service or task. For a task like yours, you would want to declare the task id to be just "FeedReaderTask", and the configuration properties to be "FeedReaderTask.fixedDelay" and "FeedReaderTask.runAsUser". (And do you really want the runAsUser default value to be "600"?) Also, your implementation of getTaskId() should just return "FeedReaderTask". The system will automatically prepend the component id and task id to the fixedDelay property, so I'm betting that with your current declaration, it's looking for "com.ibm.team.ams.pm.polling.com.ibm.ams.pm.FeedReaderTask.fixedDelay". If you see a message like
CRJAZ0853I The fixed delay property "com.ibm.team..." is not defined.
being logged, then that's evidence that the property names are not declared correctly.
CRJAZ0853I The fixed delay property "com.ibm.team..." is not defined.
being logged, then that's evidence that the property names are not declared correctly.
Hi John,
Thanks for your reply. I follow your suggestion to change my service extension like this:
And the implementation of getTaskId() also return "FeedReaderTask". But the task still not excute and there is no message like
CRJAZ0853I The fixed delay property "com.ibm.team..." is not defined.
being logged. I start my app server in debug mode and create a breakpoint in getTaskId(), this method never be invoked. :(
Thanks for your reply. I follow your suggestion to change my service extension like this:
<extension
point="com.ibm.team.repository.service.serviceProvider">
<serviceProvider
componentId="com.ibm.ams.pm.polling"
implementationClass="com.ibm.ams.pm.feedreader.task.service.AmsPollingService">
<provides>
<providedService
interface="com.ibm.ams.pm.feedreader.task.IAmsPollingService">
</providedService>
</provides>
</serviceProvider>
</extension>
<extension
point="com.ibm.team.repository.common.components">
<component
id="com.ibm.ams.pm.polling"
name="AMS Polling Service">
<service
kind="RPC"
name="AMS Polling Service"
uri="com.ibm.ams.pm.feedreader.task.IAmsPollingService"
version="1">
</service>
</component>
</extension>
<extension
point="com.ibm.team.repository.service.asynchronousTask">
<asynchronousTask
taskId="FeedReaderTask">
<extensionService
componentId="com.ibm.ams.pm.feedreader"
implementationClass="com.ibm.ams.pm.feedreader.task.FeedReaderTask">
<prerequisites>
<requiredService
interface="com.ibm.ams.pm.feedreader.task.IAmsPollingService">
</requiredService>
<configurationProperties>
<configurationProperty
accessPolicy="OPEN"
default="10"
description="description"
displayableName="Polling Interval Time"
name="FeedReaderTask.fixedDelay"
required="true"
type="LONG"
updatePolicy="FRAMEWORK_RESTART_REQUIRED">
</configurationProperty>
<configurationProperty
accessPolicy="OPEN"
default="jtsuser"
description="description"
displayableName="User"
name="FeedReaderTask.runAsUser"
required="true"
type="STRING"
updatePolicy="FRAMEWORK_RESTART_REQUIRED">
</configurationProperty>
</configurationProperties>
</prerequisites>
</extensionService>
</asynchronousTask>
</extension>
And the implementation of getTaskId() also return "FeedReaderTask". But the task still not excute and there is no message like
CRJAZ0853I The fixed delay property "com.ibm.team..." is not defined.
being logged. I start my app server in debug mode and create a breakpoint in getTaskId(), this method never be invoked. :(
Your task declaration looks OK now, as far as I can tell. Could it be that you don't have your launch configured to load your bundle? Otherwise, you might be able to get some debugging info if you add this to your log4j.properties file:
log4j.logger.com.ibm.team.repository.service.internal.scheduler=DEBUG
Then from the log messages, you might be able to determine whether your task is even being detected.
log4j.logger.com.ibm.team.repository.service.internal.scheduler=DEBUG
Then from the log messages, you might be able to determine whether your task is even being detected.