0

私はラクダにかなり慣れていないので、問題に悩まされています。

cxf エンドポイントを使用して動的 Web サービス プロキシ (動作中) を作成しようとしています。Java DSL を使用して cxf エンドポイントのタイムアウトを設定する方法がわからないことを除けば、すべてうまくいっています。

Spring 構成を使用してそれを行う方法に関する多くの記事を見つけましたが、Java DSL のみを使用してこれを達成しようとしています。

これが私が現在持っているものです。Java DSLを使用してCXFタイムアウト(接続/受信)を操作する方法について、誰かが正しい方向に向けてください。

public void configure() throws Exception
{

    onException(Exception.class).handled(true).transform()
            .method(MyExceptionHandler.class, "handleException");

    CxfEndpoint inboundCxf = new CxfEndpoint();
    inboundCxf.setAddress(soapProxyConfig.getBaseUrl()
            + soapProxyConfig.getAddress());
    inboundCxf.setCamelContext(camelContext);
    inboundCxf.setDataFormat(DataFormat.RAW);
    inboundCxf.setServiceName(new QName(soapProxyConfig
            .getTargetNamespace(), soapProxyConfig.getRemoteServiceName()));
    inboundCxf.setPortName(new QName(soapProxyConfig.getTargetNamespace(),
            soapProxyConfig.getRemotePortName()));
    inboundCxf.setWsdlURL(soapProxyConfig.getRemoteWsdl());

    SedaEndpoint sedaEndpoint = new SedaEndpoint();
    sedaEndpoint.setConcurrentConsumers(100);
    sedaEndpoint.setExchangePattern(ExchangePattern.InOut);
    sedaEndpoint.setSize(100);
    sedaEndpoint.setCamelContext(camelContext);
    sedaEndpoint.setEndpointUriIfNotSpecified("seda:" + routeId + "-Queue");

    Endpoint[] remoteEndpoints = new Endpoint[soapProxyConfig
            .getRemoteUrls().size()];
    for (int i = 0; i < soapProxyConfig.getRemoteUrls().size(); i++)
    {
        Endpoint endpoint = camelContext.getEndpoint(soapProxyConfig
                .getRemoteUrls().get(i));

        endpoint.setCamelContext(camelContext);
        remoteEndpoints[i] = endpoint;
    }

    from(inboundCxf).routeId(routeId)
            .routePolicy(new WebServiceRoutePolicy()).to(sedaEndpoint);
    from(sedaEndpoint).routeId(routeId + "-Queue").loadBalance()
            .roundRobin().to(remoteEndpoints).id("Out");
4

1 に答える 1

1

わかりました、それで、いくつかのテストと私の髪を引っ張った後、私はそれを完全に間違った方法で行っていることがわかりました.

インバウンドの CXF タイムアウト値を設定する必要はありません。アウトバウンドの HTTP タイムアウト値を設定するだけで、目的のタイムアウト検出が得られます。

だから今、私はこのようなルートを持っています

        onException(Exception.class).handled(true).transform(
            method(SoapExceptionHandler.class, "handleException"));

    SedaEndpoint sedaEnpoint = createSedaEnpoint();
    JettyHttpEndpoint jettyEnpoint = createJettyHttpEndpoint();

    CxfEndpoint cxfEnpoint = createCxfEndpoint();

    from(cxfEnpoint).routeId(getRouteName()).to(sedaEnpoint);
    from(sedaEnpoint).to(jettyEnpoint)
            .routeId(getRouteName() + "-endpoint");

そして、JettyProducer のタイムアウトを設定する方法を知りたい人のために、ここに行きます

private JettyHttpEndpoint createJettyHttpEndpoint() throws Exception
{
    JettyHttpComponent jettyComponent = new JettyHttpComponent();
    jettyComponent.setCamelContext(camelContext);
    jettyComponent.setHttpClientMinThreads(proxyConfig
            .getMinRemoteClientThreads());
    jettyComponent.setHttpClientMaxThreads(proxyConfig
            .getMaxRemoteClientThreads());

    JettyHttpEndpoint jettyEnpoint = new JettyHttpEndpoint(jettyComponent,
            "jetty:http", new URI(proxyConfig.getTargetEndpointUrl()));
    jettyEnpoint.setCamelContext(camelContext);
    jettyEnpoint.setExchangePattern(ExchangePattern.InOut);
    jettyEnpoint.setThrowExceptionOnFailure(false);
    jettyEnpoint.getClient().setTimeout(
            proxyConfig.getRemoteEndpointTimeout());

    return jettyEnpoint;
}

その構成と Jetty エンドポイントでのタイムアウトの設定により、構成可能なタイムアウトを取得できるようになりました :)

于 2013-03-21T12:58:57.973 に答える