Skip to content

配置说明

快速使用

业务项目大致分为 batch 批量模块、common 公共模块、online 联机模块、gateway 网关模块;common 公共模块是其他三个模块所依赖的公共模块。

common 模块

common 公共模块,只需要添加依赖,comet 中关于公共模块的依赖整合依赖:

xml
<dependency>
    <groupId>com.dcits</groupId>
    <artifactId>comet-starter-commons</artifactId>
</dependency>

batch 模块

batch 基本依赖

xml
<dependency>
    <groupId>com.dcits</groupId>
    <artifactId>comet-starter-batch-service</artifactId>
</dependency>

online 联机模块

  • 联机模块一般又分为 api 模块和 service 模块;service 模块依赖 api 模块;
  • api 模块只需添加依赖
xml
<dependency>
    <groupId>com.dcits</groupId>
    <artifactId>comet-starter-online-api</artifactId>
</dependency>
  • service 模块需要添加基本的依赖
xml
<dependency>
    <groupId>com.dcits</groupId>
    <artifactId>comet-starter-online-service</artifactId>
</dependency>

注解说明

注解说明备注
EnableOnlineService联机模块功能加载联机模块必须加
EnableBatchService批量模块功能加载批量模块必须加
EnableMqProducermq生产者使用MQ需要加
EnableMqConsumermq消费者使用MQ需要加
EnableCache缓存缓存
EnableSonicExecutorServerSonic调度端sonic调度端

参数配置说明

  • 联机模块
yaml
spring:
  redis:
    host: 10.7.19.105
    port: 7379
    password:
    database: 0
com:
  dcits:
    ##MQ模块配置项,分为consum和product
    rocketmq:
      ###producer
      producer:
        #该应用是否启用消息生产者,如果为true,则须配置producer和scheduled下的属性;如果为false,则可以不用配置
        enabled: true
        #发送同一类消息的设置为同一个group,保证唯一,默认不需要设置,rocketmq会使用ip@pid(pid代表jvm名字)作为唯一标示
        groupName: mqproducer
        #mq的nameserver地址
        namesrvAddr: 10.7.25.201:9876
        #消息最大长度 默认1024*4(4M)
        maxMessageSize: 4096
        #发送消息超时时间,默认3000
        sendMsgTimeout: 3000
        #发送消息失败重试次数,默认2
        retryTimesWhenSendFailed: 2
        scheduled:
          # 消息更新为异常状态的时间间隔,单位为秒(s)
          exceptionTimeout: 300
          # 定时扫描mq_producer_msg表中状态为1的消息,如果startTime与当前时间超过五分钟则将状态更新为4。
          corn1: 0 0 0 1/1 * ?     # 0/30 * * * * ?
          # 定时扫描mq_producer_msg表中状态为2的消息,然后发送。
          corn2: 0 0 0 1/1 * ?     #0/20 * * * * ?
      ###mq消费者配置
      consumer:
        #消息组 需要和生产者的groupName配置一样
        groupName: ensemble-cl
        #mq的nameserver地址
        namesrvAddr: 10.7.25.201:9876
        #该消费者订阅的主题和tags("*"号表示订阅该主题下所有的tags),格式:topic~tag1||tag2||tag3;topic2~*;
        topics: DemoTopic~*;
        consumeThreadMin: 20
        consumeThreadMax: 64
        #设置一次消费消息的条数,默认为1条
        consumeMessageBatchMaxSize: 1
      sonic:
        sdk:
          enabled: true
          service:
            app-id: DEV
            profile: DEV
            scheduler-addresses: 127.0.0.1:8080
            tenant-id: DEV
##序列
sequences:
  servers: 10.7.19.103:9004 #序列服务器列表,多个使用西文逗号分割,建议将已知的所有服务节点都进行配置
  tenantId: Galaxy    #请使用这个租户ID
  appId: TEST_APP    #自定义
  profile: dev        #自定义
  • 批量模块
yaml
spring:
  redis:
    host: 10.7.19.105
    port: 7379
com:
  dcits:
    sonic:
      client:
        enabled: false
        app-id: cl-batch
        profile: dev
        tenant-id: online-batch
        scheduler-addresses: 10.7.19.103:9999
      lock:
        enable: true
        db-type: mysql
      batch:
        namespace: com.dcits.ensemble.batch.eod.repository.CifEodDao
        dbType: LIBRA
        thread-pool:
          corePoolSize: 50
          maxPoolSize: 50
          queueCapacity: 10
          keepAliveSeconds: 60
          threadNamePrefix: batch-
          waitForTasksToCompleteOnShutdown: true

##序列
sequences:
  servers: 10.7.19.103:9004 #序列服务器列表,多个使用西文逗号分割,建议将已知的所有服务节点都进行配置
  tenantId: Galaxy    #请使用这个租户ID
  appId: TEST_APP    #自定义
  profile: dev        #自定义

例子

  • Batch 启动类配置
java
@SpringBootApplication(exclude = {BatchAutoConfiguration.class})
@EnableScheduling
@EnableBatchService
@EnableSonicExecutorServer
public class BatchMain {
    public static void main(String[] args) {
        SpringApplication.run(BatchMain.class, args);
    }
}
  • 联机处理的启动类
java

@SpringBootApplication(exclude = {BatchAutoConfiguration.class})
@EnableTransactionManagement
@EnableEurekaClient
@EnableFeignClients(basePackages = {"com.dcits.ensemble"})
@EnableScheduling
@EnableOnlineService
@EnableMqProducer
public class EnsServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EnsServiceApplication.class);
    }
}