Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:01:11+00:00 2026-06-05T20:01:11+00:00

I require retrying to send a GWT RPC request if it fails (any response

  • 0

I require retrying to send a GWT RPC request if it fails (any response code other then HTTP 200). Reasons are complex so I won’t elaborate on that. What I have so far is I treat all request responses in the same place like this:

    // We override the RpcRequestBuilder.doSetCallback method and force your service to use it
    // With this we can read the response headers if we need to.
    ((ServiceDefTarget)serviceRPC).setRpcRequestBuilder(new RpcRequestBuilder() {

        @Override
        protected void doSetCallback(RequestBuilder rb, final RequestCallback callback) {
            super.doSetCallback(rb, new RequestCallback() {

                @Override
                public void onResponseReceived(Request request,
                        Response response) {
                    httpResponseOkHandler(callback, request, response);
                }

                @Override
                public void onError(Request request, Throwable exception) {
                    httpResponseErrorHandler(callback, request, exception);
                }
            });
        }
    });

So, using httpResponseOkHandler method, I can catch HTTP failures. But, is there a way to “rethrow” the Request, i.e. try again? I don’t want to store the high level parameters of the RPC request, I would prefer to use the request content that was already streamed and ready to resend.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:01:12+00:00Added an answer on June 5, 2026 at 8:01 pm

    Well, found the answer myself. So it’s pretty neat after all. Working in heavily loaded hospital environments, network tend to be unreliable. So that is why I needed to resend rpc requests a few times before giving up. Here is the solution :

    1- Set you special request builder to catch all requests responses but keep the request builder.

        ((ServiceDefTarget)serviceRPC).setRpcRequestBuilder(new RpcRequestBuilder() {
    
            @Override
            protected void doSetCallback(RequestBuilder rb, final RequestCallback callback) {
                final RequestBuilder requestBuilder = rb;
                super.doSetCallback(rb, new RequestCallback() {
    
                    @Override
                    public void onResponseReceived(Request request,
                            Response response) {
                        httpResponseOkHandler(requestBuilder, callback, request, response);
                    }
    
                    @Override
                    public void onError(Request request, Throwable exception) {
                        httpResponseErrorHandler(requestBuilder, callback, request, exception);
                    }
                });
            }
        });
    

    2- Now use the request builder to send the request as many times as you want. One great thing is the request builder was already set and data was serialized which avoids having to store POJO unserialized data.

        // We had some server HTTP error response (we only expect code 200 from server when using RPC)
        if (response.getStatusCode() != Response.SC_OK) {
            Integer requestTry = requestValidation.get(requestBuilder.getRequestData());
            if (requestTry == null) {
                requestValidation.put(requestBuilder.getRequestData(), 1);
                sendRequest(requestBuilder, callback, request);
            }
            else if (requestTry < MAX_RESEND_RETRY) {
                requestTry += 1;
                requestValidation.put(requestBuilder.getRequestData(), requestTry);
                sendRequest(requestBuilder, callback, request);
            } else {
                InvocationException iex = new InvocationException("Unable to initiate the asynchronous service invocation -- check the network connection", null);
                callback.onError(request, iex);
            }
        } else {
            callback.onResponseReceived(request, response);         
        }
    

    This is working fine for me, use it at your own risK!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

require savon client = Savon::Client.new http://www.brenda-enzymes.org/soap2/brenda.wsdl response = client.request (:get_km_value) do |soap| soap.body =
require 'coderay' puts CodeRay.scan('puts Hello, world!', :ruby).page This code will print full HTML page
I require ASP.NET server side code in a SVG that I created. To accomplish
require 'net/http' 1.upto(99) do |novel| puts Downloading ##{novel}... Net::HTTP.start(http://www.nbc.com) do |http| resp = http.get(/heroes/novels/downloads/Heroes_novel_0#{novel}.pdf)
require juggernaut Juggernaut.publish(channel1, Some data) The code above works if Juggernaut is on the
require 'net/http' urls = [ {'link' => 'http://www.google.com/'}, {'link' => 'http://www.facebook.com/'}, {'link' => 'http://www.yahoo.com/'}
require 'ruby2ruby' require 'parsetree' code = puts(var) sexp = SexpProcessor.new.process(ParseTree.translate(code)) # => s(:fcall, :puts,
require 'rubygems' require 'mechanize' agent = Mechanize.new page = agent.get(http://google.com/) This simple script works
require 'watir' ie = Watir::Browser.new ie.goto http://www.wallpapers.com/windows/Wallpapers/Animals/Dogs ie.select(:id, ctl00_CPH1_ctl00_ddlSortExpression).flash ie.select(:id, ctl00_CPH1_ctl00_ddlSortExpression).set(Newest) C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:433:in `method_missing': undefined
require( dirname(dirname(dirname(dirname(dirname(dirname(dirname( __FILE__ ))))))).'/wp-load.php' ); this is the code im using at present. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.