RequestFactory default wire format specification

61 views
Skip to first unread message

Miroslav Genov

unread,
Mar 26, 2012, 4:11:20 PM3/26/12
to google-we...@googlegroups.com
Hello,

Does anyone knows where there is a specification of the wire format which RF is using by default ?

Regards,
  Miroslav

Thomas Broyer

unread,
Mar 27, 2012, 5:14:11 AM3/27/12
to google-we...@googlegroups.com
The specification is the code ;-)
Have a look at the com.google.web.bindery.requestfactory.shared.messages.* classes for the payload data, and the AbstractRequestContext and SimpleRequestProcessor for how their semantics.
In the ResponseMessage, there will either be general failure (causes onFailure to be called on all Receivers, including most importantly the "global" one, optionally passed to the fire() method of the RequestContext), violations (same as a general failure, but onConstraintViolations will be called instead of onFailure) or all three of operations, status codes and invocation results (actually, status codes and invocation results go by pair, and either one of operations or status-codes/invocation-results could be empty, but I don't think they could both be). Operations are data about proxies (have they been created/updated/deleted, along with their properties, as requested by the with() on the Requests); status codes gives the result/failure status of each method invocation (will trigger either onSuccess or onFailure of the Receiver associated with the method invocation) and invocation results (paired to the status codes by their index in the lists) will be either a ServiceFailureMessage (passed on onFailure) or the result (passed to onSuccess), depending on the status code.

Miroslav Genov

unread,
Mar 27, 2012, 8:07:34 AM3/27/12
to google-we...@googlegroups.com
:) I see. 

My question was related to documentation, because I've heard you to say that some RF parts are working "by design", so I was wondering where there is a such a document, that describes it. I know that GWT project has some Wiki pages about RF, but non of them is explaining in details the format of the request/response messages.

I'm digging into the source, to find out how the things are working and to find a way to make some optimization on the server side, cause It's really slow. 50 small entities are serialized in ~10 seconds on GAE, where with GSON, the serialization takes 300 ms. I made profiling of a simple request that doesn't accept any parameters and returns 50 entities.

Here is the test code that is making the request and measures the request time:

 public void testMethodReturningLargeDataSet() {
    delayTestFinish(DELAY_TEST_FINISH);

    SimpleFooRequest request = simpleFooRequest();

    final long start = System.currentTimeMillis();
    request.returnValueProxies().to(new Receiver<List<SimpleValueProxy>>() {
      @Override
      public void onSuccess(List<SimpleValueProxy> response) {
        long end = System.currentTimeMillis();

        System.out.println("Size: " + response.size() + " Time: " + (end - start) + " ms");
      }
    }).fire();
  }

Result time of this test is: Size: 50 Time: 1336 ms, where with gson, the serialization time of this 50 objects is ~ 300 ms which means that RF is 4 times slower then the simple json serialization. 

The profiler is saying that: SimpleRequestProcessor.process method is taking 58% of the processing time, where:
createReturnOperations -         20%
   - EntityCodex.encode           10%
   - AutoBeanUtils.getAllProperties()  4%
   - setTypeToken                  - 2%
   - Other invocations             - 3%

processInvocationMessages  - 37%
   - resolveClientValue             - 28%
   - ServiceLayerDecorator.invoke (Service method invocation) - 1 ms (0%)
   - EntityCodex.encode           - 9%

Thomas, do you have any thoughts about some optimizations of RF ?
Reply all
Reply to author
Forward
0 new messages