Hi,
I am using Spring+Quartz+commonj+WorkManagerTaskExecutor on Websphere to do some job scheduling.
Problem: I would like to call a Jersey Resource by using Jersey Client API or HTTPClient inside the scheduler method at certain time intervals. My job bean gets triggered and a simple system.out works expected. But if i implement my logic (by using Jersey client) within that execute method, then that logic was never called or nothing happens.
Web.xml
scheduler-config.xmlCode:<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:scheduler-config.xml </param-value> </context-param>
ScheduleTimer.javaCode:<bean id="sampleJob" class="de.scheduler.ScheduleTimer" lazy-init="default" autowire="default" dependency-check="default" /> <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>executeJob</value> </property> <property name="concurrent" value="false" /> </bean> <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean" lazy-init="default" autowire="default" dependency-check="default"> <property name="jobDetail"> <ref bean="sampleJobDetail" /> </property> <!-- startDelay 100 seconds --> <property name="startDelay" value="100000"> </property> <!-- repeat every 50 seconds --> <property name="repeatInterval" value="50000"/> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="simpleTrigger" /> </list> </property> <property name="taskExecutor" ref="taskExecutor"></property> </bean> <bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor"> <property name="workManagerName" value="wm/default"/> <property name="resourceRef" value="false"/> </bean> </beans>
Please help me.Code:public class ScheduleTimer { public void executeJob() { System.out.println("Job started at: " + new Date()); ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource("http://localhost:10040/AppContext"); // Get plain text System.out.println(service.path("webresources").path("addsmsmessage").queryParams(params).accept( MediaType.TEXT_PLAIN).post(String.class));


Reply With Quote
