Java timed Tasks

Source: Internet
Author: User

As the current understanding is not only for the current engineering understanding, not all common, for everyone can only as a reference




1, in the Impl in the Pom file introduced

<!--introducing Ucfjob core modules--

<dependency>

<groupId>com.ucf.schedule</groupId>

<artifactId>ucf-schedule-client</artifactId>

</dependency>

<!--when you use Springframework to customize a namespace

<!--when you use Springframework to customize a namespace

<dependency>

<groupId>com.ucf.schedule</groupId>

<artifactId>ucf-schedule-spring</artifactId>

</dependency>

These two are internal packaged jar packages,


2. Introduce the corresponding version in the parent's pom file


<!--timed Processing--

<!--introducing Ucfjob core modules--

<dependency>

<groupId>com.ucf.schedule</groupId>

<artifactId>ucf-schedule-client</artifactId>

<version>1.0.1-SNAPSHOT</version>

</dependency>

<!--when you use Springframework to customize a namespace

<dependency>

<groupId>com.ucf.schedule</groupId>

<artifactId>ucf-schedule-spring</artifactId>

<version>1.0.0-SNAPSHOT</version>

</dependency>

This introduces the package of the Internal encapsulation Automation task


3. In the total spring XML file in the parent project: Prod-applicationcontext.xml

Introducing Automated Task Resources

<!--add bywangqiaomin 2016-04-19 Automatic task configuration--

<import resource= "Classpath:/spring/schedule-context.xml"/>


This resource file exists under the Spring folder in the Impl project




4, this is the template of Schedule-context.xml

<?xml version= "1.0" encoding= "UTF-8"?>

<beans xmlns= "Http://www.springframework.org/schema/beans"

Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:util= "Http://www.springframework.org/schema/util"

xmlns:context= "Http://www.springframework.org/schema/context"

Xmlns:reg= "Http://www.ucfgroup.com/schema/schedule/reg" xmlns:job= "Http://www.ucfgroup.com/schema/schedule/job"

Xsi:schemalocation= "Http://www.springframework.org/schema/beans

Http://www.springframework.org/schema/beans/spring-beans.xsd

Http://www.springframework.org/schema/context

Http://www.springframework.org/schema/context/spring-context.xsd

Http://www.springframework.org/schema/util

http://www.springframework.org/schema/util/spring-util-3.0.xsd

Http://www.ucfgroup.com/schema/schedule/reg

Http://www.ucfgroup.com/schema/schedule/reg/reg.xsd

Http://www.ucfgroup.com/schema/schedule/job

Http://www.ucfgroup.com/schema/schedule/job/job.xsd ">

<!--configuring job registration Center--

<reg:zookeeper id= "Regcenter" serverlists= "${dubbo.registry}" basesleeptimemilliseconds= "1000" maxsleeptimemilliseconds= "" maxretries= "3"/>

<!--automatically close out-of-date outgoing products daily 0:5

<job:bean id= "Expiretimetask" group= "prodbuiness"

Class= "Com.ucf.prodcenter.schedule.ExpireTimeTask"

Regcenter= "Regcenter" cron= "0 5 0 * *?" fetchdatacount= "500"

Concurrentdataprocessthreadcount= "5" cyclefetchdata= "false"/>

</beans>



5. Set up automatic task class


public class Expiretimetask extends Abstractthroughputdataflowucfjob<string> {

@Override

Public list<string> Fetchdata (Jobexecutionmultipleshardingcontext arg0) {

}

@Override

public void ProcessData (Jobexecutionmultipleshardingcontext arg0,final String id) throws Exception {

}

}



This is the method contained within the schema package that is used for shard execution, the first to find the library data that matches the criteria, and the second to manipulate these qualifying data according to the ID of the entry and exit.

Java timed Tasks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.