Camel Jetty использует порт Spring Boot - PullRequest
0 голосов
/ 13 апреля 2020

Я создаю приложение весенней загрузки с apache верблюдом. Я хочу, чтобы мой rest() DSL на верблюде прослушивал тот же порт, на котором запущена весенняя загрузка.

Я пытался перейти по этой ссылке , но не смог решить ее без использования 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'
   }
}

1 Ответ

0 голосов
/ 13 апреля 2020

Если вы настроили Spring Boot для использования любого HTTP-сервера (tomcat, jetty, undertow) и хотите использовать его как часть Camel Rest DSL, то вам следует использовать camel-servlet-starter для использования сервлетов для интеграции с Spring Boot HTTP-сервер.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...