Skip to content

Commit

Permalink
Merge pull request #268 from simbag/parallel-batch-processing
Browse files Browse the repository at this point in the history
Added ability to handle JSON-RPC batch requests in parallel
  • Loading branch information
briandilley authored Jan 27, 2021
2 parents 4d32e9d + b69a88f commit 13e9a2f
Show file tree
Hide file tree
Showing 9 changed files with 455 additions and 137 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ The following settings apply to both the `JsonRpcServer` and `JsonServiceExporte
* `rethrowExceptions` - Boolean specifying whether or not the server should re-throw exceptions after sending them back to the client.
* `backwardsComaptible` - Boolean specifying whether or not the server should allow for jsonrpc 1.0 calls. This only includes the omission of the jsonrpc property of the request object, it will not enable class hinting.
* `errorResolver` - An implementation of the `ErrorResolver` interface that resolves exception thrown by services into meaningful responses to be sent to clients. Multiple `ErrorResolver`s can be configured using the `MultipleErrorResolver` implementation of this interface.
* `batchExecutorService` - A configured `ExecutorService` to use for parallel JSON-RPC batch processing. By default batch requests are handled sequentially.
### Server Method resolution
Methods are resolved in the following way, each step immediately short circuits the
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ description = 'This project aims to provide the facility to easily implement JSO
version = '1.5.3-2'
group = 'com.github.briandilley.jsonrpc4j'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava {
options.encoding = 'UTF-8'
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/googlecode/jsonrpc4j/JsonResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.googlecode.jsonrpc4j;

import com.fasterxml.jackson.databind.JsonNode;

/**
* Contains the JSON-RPC answer in {@code response}
* {@code exceptionToRethrow} contains exception, which should be thrown when property {@code rethrowExceptions}
* is active
*/
public class JsonResponse {
private JsonNode response;
private int code;
private RuntimeException exceptionToRethrow;

public JsonResponse() {
}

public JsonResponse(JsonNode response, int code) {
this.response = response;
this.code = code;
}

public JsonNode getResponse() {
return response;
}

public void setResponse(JsonNode response) {
this.response = response;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public RuntimeException getExceptionToRethrow() {
return exceptionToRethrow;
}

public void setExceptionToRethrow(RuntimeException exceptionToRethrow) {
this.exceptionToRethrow = exceptionToRethrow;
}
}
Loading

0 comments on commit 13e9a2f

Please sign in to comment.