AXIS2如何设置连接重试?

发布于 2024-08-20 10:30:20 字数 1319 浏览 10 评论 0原文

看来 Axis 管理客户端 org.apache.axis2.client.ServiceClient 正在发出 org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry() 和 默认重试3次。有没有办法设置不重试?

我的代码:

        ServiceClient client = new ServiceClient();
        Options opts = new Options();
        opts.setTo(new EndpointReference(strWebServiceUrl));
        opts.setAction(strNameOfMethodToInvoke);
        opts.setTimeOutInMilliSeconds(timeOut);
        client.setOptions(opts);
        OMElement res = client.sendReceive(createRequest());
        return (res.toString());

现在的代码是

        ServiceClient client = new ServiceClient();
        Options opts = new Options();
        opts.setTo(new EndpointReference(strWebServiceUrl));
        opts.setAction("urn:" + strNameOfMethodToInvoke);
        opts.setTimeOutInMilliSeconds(timeOut);

        HttpMethodParams methodParams = new HttpMethodParams();
        DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
        methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
        opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);

        client.setOptions(opts);
        OMElement res = client.sendReceive(createRequest());
        return (res.toString());

It seems that the Axis admin client org.apache.axis2.client.ServiceClient
is issuing org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry() and
the retry is like 3 times by default. Is there a way to set to not do retries?

My code:

        ServiceClient client = new ServiceClient();
        Options opts = new Options();
        opts.setTo(new EndpointReference(strWebServiceUrl));
        opts.setAction(strNameOfMethodToInvoke);
        opts.setTimeOutInMilliSeconds(timeOut);
        client.setOptions(opts);
        OMElement res = client.sendReceive(createRequest());
        return (res.toString());

The code now is

        ServiceClient client = new ServiceClient();
        Options opts = new Options();
        opts.setTo(new EndpointReference(strWebServiceUrl));
        opts.setAction("urn:" + strNameOfMethodToInvoke);
        opts.setTimeOutInMilliSeconds(timeOut);

        HttpMethodParams methodParams = new HttpMethodParams();
        DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
        methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
        opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);

        client.setOptions(opts);
        OMElement res = client.sendReceive(createRequest());
        return (res.toString());

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜吻♂芭芘 2024-08-27 10:30:20

您可以使用 HttpMethodParams.RETRY_HANDLER 参数进行设置。例如,在您的情况下:

HttpMethodParams methodParams = new HttpMethodParams();
DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);

wso2.org 网站 上有一个线程。

You can set it using the HttpMethodParams.RETRY_HANDLER parameter. In you case, for example:

HttpMethodParams methodParams = new HttpMethodParams();
DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);

There is a thread on the wso2.org website.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文