java110 лет назад: 4
Родитель
Сommit
c369808e15

+ 1 - 0
pom.xml

@@ -29,6 +29,7 @@
         <module>service-acct</module>
         <module>service-oa</module>
         <module>service-dev</module>
+        <module>service-busi-merge</module>
 
     </modules>
 

+ 119 - 0
service-busi-merge/pom.xml

@@ -0,0 +1,119 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>MicroCommunity</artifactId>
+        <groupId>com.java110</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>service-busi-merge</artifactId>
+    <packaging>jar</packaging>
+
+    <name>service-busi-merge</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>java110-service</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-acct</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-community</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-dev</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-fee</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-job</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-oa</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-report</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-store</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>service-user</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <finalName>service-busi-merge</finalName>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.10</version>
+                <executions>
+                    <execution>
+                        <id>unpack</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>com.java110</groupId>
+                                    <artifactId>java110-interface</artifactId>
+                                    <version>${microcommunity.version}</version>
+                                    <type>jar</type>
+                                    <overWrite>true</overWrite>
+                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <mainClass>com.java110.BusiServiceApplicationStart</mainClass>
+                </configuration>
+            </plugin>
+        </plugins>
+
+    </build>
+</project>

+ 83 - 0
service-busi-merge/src/main/java/com/java110/BusiServiceApplicationStart.java

@@ -0,0 +1,83 @@
+package com.java110;
+
+import com.java110.core.annotation.Java110CmdDiscovery;
+import com.java110.core.annotation.Java110ListenerDiscovery;
+import com.java110.core.client.RestTemplate;
+import com.java110.core.event.cmd.ServiceCmdEventPublishing;
+import com.java110.core.event.service.BusinessServiceDataFlowEventPublishing;
+import com.java110.service.init.ServiceStartInit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.converter.StringHttpMessageConverter;
+
+import java.nio.charset.Charset;
+
+
+/**
+ * spring boot 初始化启动类
+ *
+ * @version v0.1
+ * @auther com.java110.wuxw
+ * @mail 928255095@qq.com
+ * @date 2016年8月6日
+ * @tag
+ */
+@SpringBootApplication(
+        scanBasePackages = {"com.java110.service",
+                "com.java110.core",
+                "com.java110.user",
+                "com.java110.acct",
+                "com.java110.common",
+                "com.java110.community",
+                "com.java110.dev",
+                "com.java110.fee",
+                "com.java110.job",
+                "com.java110.oa",
+                "com.java110.report",
+                "com.java110.store",
+                "com.java110.config.properties.code",
+                "com.java110.db"}
+)
+@EnableDiscoveryClient
+@Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
+        basePackages = {"com.java110.user.listener"})
+@Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class,
+        basePackages = {"com.java110.user.cmd"})
+public class BusiServiceApplicationStart {
+
+    private static Logger logger = LoggerFactory.getLogger(BusiServiceApplicationStart.class);
+
+    private static final String LISTENER_PATH = "java110.UserService.listeners";
+
+    public static void main(String[] args) throws Exception {
+        try {
+            ApplicationContext context = SpringApplication.run(BusiServiceApplicationStart.class, args);
+            ServiceStartInit.initSystemConfig(context);
+            //加载业务侦听
+            // SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH);
+        } catch (Throwable e) {
+            logger.error("系统启动失败", e);
+        }
+    }
+
+    /**
+     * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力.
+     *
+     * @return restTemplate
+     */
+    @Bean
+    @LoadBalanced
+    public RestTemplate restTemplate() {
+        StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8"));
+        RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class);
+        return restTemplate;
+    }
+}

+ 100 - 0
service-busi-merge/src/main/resources/application-dev.yml

@@ -0,0 +1,100 @@
+jedis:
+  pool:
+    config:
+      maxTotal: 100
+      maxIdle: 20
+      maxWaitMillis: 20000
+    host: dev.redis.java110.com
+    port: 6379
+    timeout: 3000
+    password: hc
+
+eureka:
+  instance:
+    leaseRenewalIntervalInSeconds: 10
+    leaseExpirationDurationInSeconds: 30
+    preferIpAddress: true
+    instanceId: ${spring.cloud.client.ip-address}:${server.port}
+  client:
+    serviceUrl:
+      defaultZone: http://dev.java110.com:8761/eureka/
+      #defaultZone: http://localhost:8761/eureka/
+server:
+  port: 8000
+  tomcat:
+    uri-encoding: UTF-8
+
+java110:
+  community-service: community-service
+
+spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: busi-service
+  redis:
+    database: 0
+    host: dev.redis.java110.com
+    port: 6379
+    password: hc
+    pool:
+      max-active: 300
+      max-wait: 10000
+      max-idle: 100
+      min-idle: 0
+      timeout: 0
+  datasource:
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+    type: com.alibaba.druid.pool.DruidDataSource
+    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
+    maxPoolPreparedStatementPerConnectionSize: 20
+    password: TT@12345678
+    testOnBorrow: false
+    testWhileIdle: true
+    minEvictableIdleTimeMillis: 300000
+    timeBetweenEvictionRunsMillis: 60000
+    testOnReturn: false
+    driverClassName: com.mysql.cj.jdbc.Driver
+    maxActive: 20
+    username: TT
+
+#============== kafka ===================
+kafka:
+  consumer:
+    zookeeper:
+      connect: dev.zk.java110.com:2181
+    servers: dev.kafka.java110.com:9092
+    enable:
+      auto:
+        commit: true
+    session:
+      timeout: 6000
+    auto:
+      commit:
+        interval: 100
+      offset:
+        reset: latest
+    topic: test
+    group:
+      id: notifyBusinessStatus
+    concurrency: 10
+
+  producer:
+    zookeeper:
+      connect: dev.zk.java110.com:2181
+    servers: dev.kafka.java110.com:9092
+    retries: 0
+    batch:
+      size: 4096
+    linger: 1
+    buffer:
+      memory: 40960

+ 3 - 0
service-busi-merge/src/main/resources/application.yml

@@ -0,0 +1,3 @@
+spring:
+  profiles:
+    active: dev

+ 32 - 0
service-busi-merge/src/main/resources/dataSource.yml

@@ -0,0 +1,32 @@
+dataSources:
+  ds1: !!com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
+    username: TT
+    password: TT@12345678
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+
+shardingRule:
+  tables:
+    business_xxx:
+      actualDataNodes: ds1.business_community
+      databaseStrategy:
+        inline:
+          shardingColumn: community_id
+          algorithmExpression: ds${Long.parseLong(community_id) % 2}
+
+  bindingTables:
+    - business_xxx
+
+  defaultDataSourceName: ds1
+  defaultDatabaseStrategy:
+    none:
+  defaultTableStrategy:
+    none:
+props:
+  sql.show: true

+ 3 - 0
service-busi-merge/src/main/resources/java110.properties

@@ -0,0 +1,3 @@
+java110.mappingPath=classpath:mapper/**/**/*.xml
+
+