
Originally Posted by
eivindw
I've written down an example of how we've used the CommonJ Spring integration to set up simple scheduling on WebSphere. There doesn't seem to be very much information about this, so I thought it might be useful for others
The article is posted here:
http://boss.bekk.no/display/BOSS/Spr...g+in+WebSphere
Feel free to make comments/suggestions here or on the article page.
First of all thank you for that wonderful article. It has saved me countless hours.
1. I was able to successfully integrated quartz and WorkManager into my application. For those who are interested, below is my spring beans file:
HTML Code:
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronReportTrigger" />
</list>
</property>
<property name="taskExecutor" ref="taskExecutor"></property>
</bean>
<bean id="cronReportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean" lazy-init="default" autowire="default" dependency-check="default">
<property name="jobDetail">
<ref bean="sampleJobDetail" />
</property>
<property name="cronExpression">
<value>1 * * * * ?</value>
</property>
</bean>
<bean id="sampleJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" lazy-init="default" autowire="default" dependency-check="default">
<property name="targetObject">
<ref bean="sampleJob" />
</property>
<property name="targetMethod">
<value>doJob</value>
</property>
</bean>
<bean id="sampleJob" class="ca.pro.jmx.SampleJob" lazy-init="default" autowire="default" dependency-check="default" />
<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName" value="wm/default"/>
<property name="resourceRef" value="false"/>
</bean>
2. I would like to use a TimerManager but here is where I am having some difficulties. I used your sample code and setup my spring beans xml file as:
HTML Code:
<bean id="sampleBatchRunnable" class="ca.pro.jmx.SampleBatchRunnable"/>
<bean id="batchListener" class="ca.pro.jmx.ScheduledDateTimerListener">
- Run at next -
<property name="timeStr" value="13:45"/>
- Run at interval -
<property name="period" value="60000"/>
<property name="fixedRate" value="true"/>
<property name="runnable" ref="sampleBatchRunnable"/>
</bean>
<bean id="timerFactory" class="ca.pro.jmx.DateTimerManagerFactoryBean">
<property name="timerManagerName" value="java:comp/env/tm/default"/>
<property name="resourceRef" value="false"/>
<property name="scheduledDateTimerListeners">
<list>
<ref bean="batchListener"/>
</list>
</property>
</bean>
To my web.xml file I added:
HTML Code:
<resource-ref>
<res-ref-name>tm/default</res-ref-name>
<res-type>commonj.timers.TimerManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
</resource-ref>
When I deploy my application using the WebSphere application console, it prompts me to choose the TimerManager, but when I click on the browse button, the 'Available Resources' list is empty. When I click on the configured TimerManagers, I can see that there are many 'tm/default' TimerManagers configured (at different scopes). Then why does the available resources list show up blank.
My configuration in web.xml file for a datasource is similar, but when I deploy my application, the available datasources are correctly shown in the Available Resources screen.
Any ideas on what am I doing wrong with the TimerManager?
Your help is much appreciated!