骆驼可以做到这一点: 2个站在码头上的休息服务,首先由http(例如在端口1234上)和第二个https(例如在端口4321上),我怎么配置它?那可能吗?2个端口和协议上的骆驼码头休息方法
影响,我需要获得(例如网址):
http://localhost:1234/firstHttpMethod
http://localhost:1234/secondHttpMethod
https://localhost:4321/firstHttpsMethod
https://localhost:4321/secondHttpsMethod
这一刻,当我尝试添加2路,仅次于正在工作。如何解决这个问题(我有一个思考做2休息服务 - 首先在码头,其次是别的东西,但它不是好的概念)。
代码如下所示:
camelContext.addRoutes(firstJettyBuilder());
camelContext.addRoutes(secondJettyBuilder());
protected RouteBuilder firstJettyBuilder()
{
return new RouteBuilder()
{
@Override
public void configure()
throws Exception
{
restConfiguration()
.component("jetty")
.host("localhost")
.port(42300)
.scheme("https")
.bindingMode(RestBindingMode.json)
.dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES")
.dataFormatProperty("json.in.enableFeatures", "FAIL_ON_NULL_FOR_PRIMITIVES");
configureSSL();
}
private void configureSSL()
{
final JettyHttpComponent jettyComponent = camelContext.getComponent("jetty", JettyHttpComponent.class);
final Map<String, Object> sslSocketConnectorProperties = new HashMap<>();
sslSocketConnectorProperties.put("keyStorePath", KEYSTORE);
sslSocketConnectorProperties.put("trustStorePath", KEYSTORE);
sslSocketConnectorProperties.put("keyStorePassword", KEYSTORE_PASSWORD);
sslSocketConnectorProperties.put("trustStorePassword", KEYSTORE_PASSWORD);
jettyComponent.setSslSocketConnectorProperties(sslSocketConnectorProperties);
}
};
}
protected RouteBuilder createPosJettyBuilder()
{
return new RouteBuilder()
{
@Override
public void configure()
throws Exception
{
restConfiguration()
.component("jetty")
.host("localhost")
.port(42302)
.scheme("http")
.bindingMode(RestBindingMode.json)
.dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES")
.dataFormatProperty("json.in.enableFeatures", "FAIL_ON_NULL_FOR_PRIMITIVES");
}
};
}
请提供您的路由配置。 – SubOptimal
你的第二个工作是什么?当你启动camelcontext时,两条路线都会出现吗?只有一条路线? –
取决于调用第一或第二个jettyBuilder的顺序,我只能连接到其中一个服务 – pustypawel