zoukankan      html  css  js  c++  java
  • spring quartz1.8.6集群结算服务定时任务与appserver独立分开

    1.quartz集群如何处理同一个数据库,同一套sqtz表的lock问题,否则会导致打架。

    思路如下:

    1.com.xxx.quartz.BeanInvokingJobDetailFactoryBeanSs 同一个内存地址。 FactoryBean名字区分,因为Long无法比较大小,比较的是内存地址。
    2.<property name="group" value="schedulerSs" />  分组上来做文章
    3.org.quartz.scheduler.instanceName = SchedulerSs   重新定义instanceName,instanceId
    4.服务器时间必须要准确!! 否则定时任务有问题

    与appserver串起来了:部署在一台机器上面。
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cpicExpireExpireTask' is defined

    综合上述的方法,还是会相互影响。最终的解决方法是重新建立一个单独的settle数据库,配置单独的settleDataSource数据源,在处理spring boot 多数据源的问题上,否则会报错:

    2017-01-06 20:36:07.478 [main] ERROR org.springframework.boot.SpringApplication#handleRunFailure [line:827] - Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer': Invocation of init method failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: settleDataSource,dataSource

    Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: settleDataSource,dataSource

    解决方法是:

    1. destroy-method="close" primary="true"   数据源配置上面设置主要数据源
    2. @SpringBootApplication(exclude={DataSourceAutoConfiguration.class})  加载的时候直接跳过。

    以下的配置也需要加上,否则spring boot启动的时候也会报错:

    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
    <constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="dataSource" />
    </bean>

  • 相关阅读:
    About HDFS blocks
    Hadoop源代码分析(一)
    Hadoop源代码分析(三)
    MapReduce基础
    Pig安装与配置教程
    MapReduce数据流(三)
    MapReduce数据流(二)
    c++中的临时对象
    如何修改CMD命令行窗口下的默认路径
    VC2005: warning LNK4076: 无效的增量状态文件
  • 原文地址:https://www.cnblogs.com/simpledev/p/6263217.html
Copyright © 2011-2022 走看看