瀏覽代碼

修改broker启动问题

Airhead 8 年之前
父節點
當前提交
038889e283

+ 1 - 8
hos-broker/pom.xml

@ -54,18 +54,11 @@
            <groupId>com.yihu.hos</groupId>
            <artifactId>hos-web-framework</artifactId>
            <version>1.3.0</version>
            <exclusions>
                <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <version>1.4.1.RELEASE</version>
            <!--<scope>provided</scope>-->
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-stream -->
        <!-- sigar -->

+ 12 - 2
hos-broker/src/main/java/com/yihu/hos/broker/HosBrokerApplication.java

@ -11,14 +11,20 @@ import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurat
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.data.mongodb.gridfs.GridFsOperations;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@EnableScheduling
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
@EnableAsync
public class HosBrokerApplication extends SpringBootServletInitializer implements CommandLineRunner {
    @Autowired
    private GridFsOperations operations;
    private CamelStartBoot camelStartBoot;
    private ExecutorService executorService = Executors.newSingleThreadExecutor();
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(HosBrokerApplication.class);
@ -28,12 +34,16 @@ public class HosBrokerApplication extends SpringBootServletInitializer implement
    @Override
    public void run(String... strings) throws Exception {
        GridFSUtil.gridFsOperations = operations;
        camelStartBoot = new CamelStartBoot();
        camelStartBoot.start();
        executorService.execute(() -> {
            camelStartBoot = new CamelStartBoot();
            camelStartBoot.start();
        });
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            try {
                camelStartBoot.shutdown();
                executorService.shutdown();
            } catch (Exception ignored) {
            }
        }));

+ 2 - 2
hos-broker/src/main/java/com/yihu/hos/broker/controllers/ESBCamelController.java

@ -19,8 +19,8 @@ public class ESBCamelController {
    @Autowired
    private ESBCamelService esbCamelService;
    @RequestMapping(value = "/heartbeat", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation(value = "测试服务器可以正常连接", produces = "application/json", notes = "测试服务器可以正常连接")
    @RequestMapping(value = "/heartbeat", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation(value = "测试服务器可以正常连接", notes = "测试服务器可以正常连接")
    public String heartbeat() {
        return "test";
    }

+ 1 - 1
hos-broker/src/main/resources/log4j.properties

@ -31,7 +31,7 @@ log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
log4j.appender.jms=com.yihu.hos.broker.common.log.JMSAppender
log4j.appender.jms.InitialContextFactoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory
log4j.appender.jms.ProviderURL=tcp://activemq:61616
log4j.appender.jms.ProviderURL=tcp://172.19.103.58:61616
log4j.appender.jms.TopicBindingName=logTopic
log4j.appender.jms.TopicConnectionFactoryBindingName=ConnectionFactory
log4j.appender.jms.userName=admin