簡體   English   中英

駱駝碼頭使用 Spring 啟動端口

[英]Camel Jetty to use Spring Boot port

我正在使用 apache 駱駝構建 spring 引導應用程序。 我希望我在駱駝中的rest() DSL 監聽與 spring 啟動啟動相同的端口。

我嘗試關注此鏈接,但如果不使用servlet組件就無法解決它。 我不希望我的路線看起來像servlet:/hello而是想直接使用碼頭(jetty:http://0.0.0.0:0/hello)

我能夠無錯誤地啟動服務器,但沒有發生路由。

調用http://localhost:8080/hello不起作用。

日志

 Bean 'org.apache.camel.spring.boot.CamelAutoConfiguration' of type [org.apache.camel.spring.boot.CamelAutoConfiguration] is not eligible for getting processed by all BeanPos
 Logging initialized @1690ms to org.eclipse.jetty.util.log.Slf4jLog
 Server initialized with port: 8080
 jetty-9.4.27.v20200227; built: 2020-02-27T18:37:21.340Z; git: a304fd9f351f337e7c0e2a7c28878dd536149c6c; jvm 1.8.0_221-b11
 Initializing Spring embedded WebApplicationContext
 Root WebApplicationContext: initialization completed in 733 ms
 DefaultSessionIdManager workerName=node0
 No SessionScavenger set, using defaults
 node0 Scavenging every 660000ms
 Started @1882ms
 Initializing ExecutorService 'applicationTaskExecutor'
 Detected and using LURCacheFactory: camel-caffeine-lrucache
 LiveReload server is running on port 35729
 Loading additional Camel XML routes from: classpath:camel/*.xml
 Loading additional Camel XML rests from: classpath:camel-rest/*.xml
 JMX is enabled
 Apache Camel 3.2.0 (CamelContext: ServicesRest) is starting
 StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
 Route: route1 started and consuming from: direct://getCustomer
 jetty-9.4.27.v20200227; built: 2020-02-27T18:37:21.340Z; git: a304fd9f351f337e7c0e2a7c28878dd536149c6c; jvm 1.8.0_221-b11
 Started o.e.j.s.ServletContextHandler@79c2e942{/,null,AVAILABLE}
 Started ServerConnector@11d5056{HTTP/1.1, (http/1.1)}{0.0.0.0:63660}
 Started @2441ms
 Route: route2 started and consuming from: jetty:http://0.0.0.0:0/hello
 Total 2 routes, of which 2 are started
 Apache Camel 3.2.0 (CamelContext: ServicesRest) started in 0.043 seconds
 Initializing Spring DispatcherServlet 'dispatcherServlet'
 Initializing Servlet 'dispatcherServlet'
 Completed initialization in 3 ms
 Started ServerConnector@436343c0{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
 Jetty started on port(s) 8080 (http/1.1) with context path '/'
 Started CamelMicroservicesApplication in 1.688 seconds (JVM running for 2.462)

路線生成器

@Component
public class SimpleRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        rest("/").get("hello")
            .produces("text/plain")
            .to("direct:getCustomer")

            .outType(String.class);

        from("direct:getCustomer")
                .log(LoggingLevel.INFO, "${body}");

    }
}

build.gradle

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.springframework.boot', module:'spring-boot-starter-tomcat'
    }
    implementation 'org.springframework.boot:spring-boot-starter-jetty'
    implementation 'org.apache.camel.springboot:camel-spring-boot-starter:3.2.0'
    implementation 'org.apache.camel.springboot:camel-rest-starter:3.2.0'
    implementation 'org.apache.camel:camel-jetty:3.2.0'
   }
}

If you setup Spring Boot to use whatever HTTP server (tomcat, jetty, undertow) and you want to use that as part of Camel Rest DSL, then you should use camel-servlet-starter to use servlets to integrate with Spring Boot HTTP server.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM