- 浏览: 448374 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
飞天奔月:
我来个简单点的代码 使用 LinkedHashSetpubli ...
ArrayList去重 -
飞天奔月:
public static <T> List< ...
ArrayList去重 -
aaron7524:
事务隔离级别 -
月陨殇:
wlh269 写道rswh110 写道lz内容写的不错,就是略 ...
事务隔离级别 -
lnx1824:
我的更奇怪,在本地静态的可以,放jetty里的页面后就不然,都 ...
JS得到上传图片尺寸
1.配置文件:ScheduledTimerTask是spring内置的一个类,
在它的timerTask标签中引入我们需要定时执行的业务代码,这里例如,targetSMSQueryTaskBiz;在period标签中加入执行频率,单位为毫秒;
2.业务类代码,这里为SMSQueryBizImpl,该类继承TimerTask,而TimerTask实现了Runnable接口,所以我们的业务类要实现run()方法;
在它的timerTask标签中引入我们需要定时执行的业务代码,这里例如,targetSMSQueryTaskBiz;在period标签中加入执行频率,单位为毫秒;
<bean id="targetSMSQueryTaskBiz" class="com.hollyinfo.invest.biz.message.SMSQueryBizImpl"> <property name="fileClient"> <ref bean="fileClient"/> </property> <property name="messageDao"> <ref bean="messageDao" /> </property> </bean> <bean id="scheduledSMSQureyTask" class="org.springframework.scheduling.timer.ScheduledTimerTask"> <property name="timerTask"> <ref bean="targetSMSQueryTaskBiz"/> </property> <property name="period"> <value>60000</value> </property> </bean> <bean class="org.springframework.scheduling.timer.TimerFactoryBean"> <property name="scheduledTimerTasks"> <list> <ref bean="scheduledSMSQureyTask"/> </list> </property> </bean> <bean id="SMSQueryTaskBiz" parent="jdbcTransactionProxy"> <property name="target" ref="targetSMSQueryTaskBiz" /> </bean>
2.业务类代码,这里为SMSQueryBizImpl,该类继承TimerTask,而TimerTask实现了Runnable接口,所以我们的业务类要实现run()方法;
public class SMSQueryBizImpl extends TimerTask implements SMSQueryBiz { /** 日志初始化 */ private static HollyinfoLog LOG = HollyinfoLogger.getLog(MessageBizImpl.class); private SMSFileTransClient fileClient; public void setFileClient(SMSFileTransClient fileClient) { this.fileClient = fileClient; } /** 消息数据通道接口 */ private MessageDao messageDao; public void setMessageDao(MessageDao messageDao) { this.messageDao = messageDao; } public SMSQueryBizImpl() { } public void run() { try{ //查询待接收结果文件 List fileNames=fileClient.queryFileList(); for (Iterator iterator = fileNames.iterator(); iterator.hasNext();) { String fileName = (String) iterator.next(); int idx=fileName.indexOf("."); String preName=fileName.substring(0, idx); //下载结果文件 boolean flag=fileClient.download(preName, "txt"); if(flag){ LOG.info("下载结果文件"+fileName+","+flag); Thread.sleep(10000); boolean delflag=false; if(readLastLine(new File(SystemParameter.smsResultDir+File.separator+fileName),"utf-8").indexOf("EOF")!=-1){ //删除服务端已下载文件 delflag=fileClient.deleteFile(preName, "txt"); //更新发送结果到核心系统 updateSendResults(fileName); } //删除客户端已下载文件 delFile(new File(SystemParameter.smsResultDir+File.separator+fileName)); LOG.info("删除中间服务结果文件"+fileName+","+delflag); }else{ LOG.info("下载结果文件"+fileName+","+flag); } } //======检查是否还有没上传成功的文件,做重新上传操作=====// String [] filenames=new File(SystemParameter.smsSendDir).list(); for (int i = 0; i < filenames.length; i++) { File tmpFile=new File(SystemParameter.smsSendDir+File.separator+filenames[i]); Pattern p = Pattern.compile("sms_send_list.+?txt"); Matcher fMatcher = p.matcher(tmpFile.getName()); //如果后缀为txt开头为sms_send_list,且内容不为空的文件 if (fMatcher.matches()&& NotEmptyFile(tmpFile)&&readLastLine(tmpFile,"utf-8").indexOf("EOF")!=-1) { boolean hasUpload=fileClient.upload(filenames[i], tmpFile, "txt"); if(hasUpload){ LOG.info("重复上传待发催报短信息文件:"+filenames[i]+"成功!"); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } //删除已经上传的信息文件 boolean flag =delFile(tmpFile); if(flag){ LOG.info("删除待发催报短信息文件:"+filenames[i]+"成功!"); } }else{ LOG.info("重复上传待发催报短信息文件:"+filenames[i]+"失败!"); } } } }catch (InterruptedException e) { e.printStackTrace(); } } }
发表评论
-
java开发实战视频详解
2017-07-02 08:09 492java开发实战视频详解 链接: http://pan.bai ... -
Spring(十七) Spring 拦截器
2009-02-18 00:44 2640该例子结合Spring(十六)这篇文章来看,本人觉得其实Spr ... -
Spring(十六) AOP(五)--和AOP(二)类似的切面编程
2009-02-17 23:06 1329.实现aop的例子 1.首先先来点预备类,咱定义一个表演的 ... -
Spring(十五)的监听器ContextLoaderListener的作用
2009-02-07 20:39 4759在SSH项目中我们自动加 ... -
Spring(十三) Spring中事务的传播属性详解
2009-02-06 17:32 1166Spring中事务的传播属性详解 在使用Spring时,大部 ... -
Spring(十四) Spring和Hibernate的结合--声明式事务管理
2009-02-06 16:23 3465采用声明式事务 1、声明式事务配置 * 配置SessionF ... -
Spring(十二) Spring和Hibernate的结合--手动事务管理
2009-02-05 17:57 3871=======在没有使用Spring声明式事物前,使用Hibe ... -
Spring(十一) AOP(四)spring面向切面编程--JDK代理和CGLIB代理
2009-02-05 16:56 2090spring对AOP的支持 1、如果目标对象实现了接口,默认 ... -
Spring(十) AOP(三)spring面向切面编程--Aspect类的Advice方法接收参数
2009-02-05 14:57 2416spring对AOP的支持 Aspect类默认情况下不需要实 ... -
Spring(九) AOP(二)spring面向切面编程--采用静态配置文件的方式
2009-02-05 14:24 1621Spring对AOP的支持(采用 ... -
Spring(八) AOP(一)spring面向切面编程--注解方式的面向切面编程
2009-02-05 11:14 1791注解方式的面向切面编程 spring对AOP的支持(采用Ann ... -
Spring(七)根据类型自动装配
2009-02-04 12:18 980根据类型自动装配 将Beans标签的default-autow ... -
Spring(六)根据名称自动装配
2009-02-04 12:06 1045根据类型自动装配 设置Beans标签default-auto ... -
Spring(五)作用域
2009-02-04 11:29 1038spring bean的作用域 scope可以值: * ... -
Spring(四)属性编辑器&注入(Injection)
2009-02-04 11:15 13091、spring普通属性注入 参见spring文档3.3.3 ... -
Spring(三)如何创建一个spring项目
2009-02-03 19:25 19251、spring依赖库 * SPRING_HOME/dist ... -
Spring(二)编辑XML文件的输入提示功能的配置
2009-02-03 11:52 11461.windows---preferences---输入xml ... -
Spring(一)为什么要使用spring
2009-02-03 11:12 1931使用Spring可以避免factory和siglton的泛滥 ...
相关推荐
Spring定时任务的几种实现,欢迎交流!
spring定时任务 xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=...
spring定时任务SimpleTrigger 和CronTrigger 配置
spring spring spring spring定时任务所需jar 齐全
使用spring定时任务,使用spring+mybatis 向数据库中插入数据实例
一个tomcat下部署了两个应用,一个是普通web应用syncc,另一个应用syncc_wx属于微信公众号后台程序涉及消息定时推送,tomcat未分离...”spring定时任务执行两次的异常排查处理.docx"针对上述描述问题进行分析和解决。
Spring 定时任务 各参数详细说明,注解方式,简洁
Spring3.x企业应用开发实战 中 Spring 定时任务源码(spring 三种定时任务的实现方式),Spring quartz java 定时器 定时任务 源码
spring 做定时器任务时所依赖的10个jar包,用于实现java定时任务。
实现定时任务的执行操作!
NULL 博文链接:https://bijian1013.iteye.com/blog/2380233
spring 定时任务 示例代码
本文档详细介绍了Spring定时任务配置的两种方式。一种方式是使用Spring提供的 MethodInvokingJobDetailFactoryBean 代理类,Quartz通过该代理类直接调度任务类的某个函数,另外一种方式是任务类继承并实现Quartz接口...
本案例是基于quartz+spring做的定时任务,包含所有jar包,可以直接运行
Spring Quartz定时任务所需要的6个jar包:commons-collections.jar、commons-logging.jar、jta.jar、log4j-1.2.14.jar、quartz-all-1.6.0.jar、spring-2.0.6.jar
可运行的项目,实现了spring定时任务,很好理解!一看就懂