240.8. 동일한 포트로 여러 경로 사용


동일한 CamelContext에 동일한 포트(예: org.jboss.netty.bootstrap.ServerBootstrap 인스턴스)를 공유하는 Netty HTTP 의 여러 경로가 있을 수 있습니다. 이렇게 하려면 경로에서 동일한 org.jboss.netty.bootstrap.ServerBootstrap 인스턴스를 공유하므로 여러 부트스트랩 옵션이 동일해야 합니다. 인스턴스는 생성된 첫 번째 경로의 옵션으로 구성됩니다.

경로가 동일해야 하는 옵션은 org.apache.camel.component.nettyServerBootstrapConfiguration 구성 클래스에 정의된 모든 옵션입니다. 다른 옵션으로 다른 경로를 구성한 경우 Camel은 시작 시 예외가 발생하여 옵션이 동일하지 않음을 나타냅니다. 이를 완화하려면 모든 옵션이 동일합니다.

다음은 동일한 포트를 공유하는 두 경로가 있는 예입니다.

동일한 포트를 공유하는 두 경로

from("netty-http:http://0.0.0.0:{{port}}/foo")
  .to("mock:foo")
  .transform().constant("Bye World");

from("netty-http:http://0.0.0.0:{{port}}/bar")
  .to("mock:bar")
  .transform().constant("Bye Camel");

다음은 1st 경로와 동일한 org.apache.camel.component.netty.NettyServerBootstrapConfiguration 옵션이 없는 잘못된 2nd 경로의 예입니다. 이로 인해 Camel이 시작 시 실패합니다.

동일한 포트를 공유하는 두 경로이지만 두 번째 경로는 잘못 구성되어 시작 시 실패합니다.

from("netty-http:http://0.0.0.0:{{port}}/foo")
  .to("mock:foo")
  .transform().constant("Bye World");

// we cannot have a 2nd route on same port with SSL enabled, when the 1st route is NOT
from("netty-http:http://0.0.0.0:{{port}}/bar?ssl=true")
  .to("mock:bar")
  .transform().constant("Bye Camel");

240.8.1. 여러 경로에서 동일한 서버 부트스트랩 구성 사용

org.apache.camel.component.netty.NettyServerBootstrapConfiguration 유형의 단일 인스턴스에서 공통 서버 부트스트랩 옵션을 구성하면 Netty HTTP 소비자의 bootstrapConfiguration 옵션을 사용하여 모든 소비자에서 동일한 옵션을 참조하고 재사용할 수 있습니다.

<bean id="nettyHttpBootstrapOptions" class="org.apache.camel.component.netty.NettyServerBootstrapConfiguration">
  <property name="backlog" value="200"/>
  <property name="connectTimeout" value="20000"/>
  <property name="workerCount" value="16"/>
</bean>

아래와 같이 경로에서 이 옵션을 참조합니다.

<route>
  <from uri="netty-http:http://0.0.0.0:{{port}}/foo?bootstrapConfiguration=#nettyHttpBootstrapOptions"/>
  ...
</route>

<route>
  <from uri="netty-http:http://0.0.0.0:{{port}}/bar?bootstrapConfiguration=#nettyHttpBootstrapOptions"/>
  ...
</route>

<route>
  <from uri="netty-http:http://0.0.0.0:{{port}}/beer?bootstrapConfiguration=#nettyHttpBootstrapOptions"/>
  ...
</route>

Netty HTTP Server 예제를 참조하십시오. 자세한 내용은 Netty HTTP Server 예제를 참조하십시오.

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동