An instance of a call to a remote method. A call will send zero or more request messages to the
server and receive zero or more response messages back.
Instances are created by a HttpJsonChannel and used by stubs to invoke their remote
behavior.
#start must be called prior to calling any other methods, with the exception of #cancel. Whereas #cancel must not be followed by any other methods, but can be called
more than once, while only the first one has effect.
Methods are potentially blocking but are designed to execute quickly. The implementations of
this class are expected to be thread-safe.
There is a race between #cancel and the completion/failure of the RPC in other ways.
If #cancel won the race, Listener.onClose()
is called with statusCode corresponding to CANCELLED. Otherwise, Listener.onClose() is called with whatever status the RPC
was finished. We ensure that at most one is called.
Prevent any further processing for this HttpJsonClientCall. No further messages may be
sent or will be received. The server is not informed of cancellations. Cancellation is
permitted even if previously #halfClosed. Cancelling an already cancel()ed
ClientCall has no effect.
No other methods on this class can be called after this method has been called.
if not null, will appear as the cause of the CANCELLED status
halfClose()
publicabstractvoidhalfClose()
Close the call for request message sending. Incoming response messages are unaffected. This
should be called when no more messages will be sent from the client.
Message delivery is guaranteed to be sequential in the order received. In addition, the
listener methods will not be accessed concurrently. While it is not guaranteed that the same
thread will always be used, it is guaranteed that only a single thread will access the listener
at a time.
If called multiple times, the number of messages able to delivered will be the sum of the
calls.
This method is safe to call from multiple threads without external synchronization.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThis webpage provides documentation for the \u003ccode\u003eHttpJsonClientCall\u003c/code\u003e class in the Google API Client Libraries for Java (gax), outlining its functionality and usage across various versions.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of \u003ccode\u003eHttpJsonClientCall\u003c/code\u003e is 2.63.1, with a list of other versions available, ranging down to 2.7.1, each with its corresponding documentation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eHttpJsonClientCall\u003c/code\u003e represents a call to a remote method, enabling the sending of request messages and receiving of response messages, and it must be initiated with the start method before other methods are called.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecancel\u003c/code\u003e method can be used to prevent further processing of a \u003ccode\u003eHttpJsonClientCall\u003c/code\u003e, with no further messages sent or received, and may be called at any time during the process.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eHttpJsonClientCall\u003c/code\u003e class includes methods for managing messages such as \u003ccode\u003esendMessage\u003c/code\u003e, \u003ccode\u003ehalfClose\u003c/code\u003e, \u003ccode\u003erequest\u003c/code\u003e, and \u003ccode\u003estart\u003c/code\u003e, as well as detailed parameters and their descriptions, which can be used by the user.\u003c/p\u003e\n"]]],[],null,["# Class HttpJsonClientCall<RequestT,ResponseT> (2.69.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.69.0 (latest)](/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.68.2](/java/docs/reference/gax/2.68.2/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.67.0](/java/docs/reference/gax/2.67.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.66.0](/java/docs/reference/gax/2.66.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.65.0](/java/docs/reference/gax/2.65.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.63.1](/java/docs/reference/gax/2.63.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.62.0](/java/docs/reference/gax/2.62.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.61.0](/java/docs/reference/gax/2.61.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.60.0](/java/docs/reference/gax/2.60.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.59.1](/java/docs/reference/gax/2.59.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.58.0](/java/docs/reference/gax/2.58.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.57.0](/java/docs/reference/gax/2.57.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.55.0](/java/docs/reference/gax/2.55.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.54.1](/java/docs/reference/gax/2.54.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.53.0](/java/docs/reference/gax/2.53.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.52.0](/java/docs/reference/gax/2.52.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.51.0](/java/docs/reference/gax/2.51.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.50.0](/java/docs/reference/gax/2.50.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.49.0](/java/docs/reference/gax/2.49.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.48.1](/java/docs/reference/gax/2.48.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.47.0](/java/docs/reference/gax/2.47.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.46.1](/java/docs/reference/gax/2.46.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.45.0](/java/docs/reference/gax/2.45.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.43.0](/java/docs/reference/gax/2.43.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.42.0](/java/docs/reference/gax/2.42.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.41.0](/java/docs/reference/gax/2.41.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.39.0](/java/docs/reference/gax/2.39.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.38.0](/java/docs/reference/gax/2.38.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.37.0](/java/docs/reference/gax/2.37.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.36.0](/java/docs/reference/gax/2.36.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.35.0](/java/docs/reference/gax/2.35.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.34.1](/java/docs/reference/gax/2.34.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.33.0](/java/docs/reference/gax/2.33.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.32.1](/java/docs/reference/gax/2.32.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.31.1](/java/docs/reference/gax/2.31.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.30.1](/java/docs/reference/gax/2.30.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.24.0](/java/docs/reference/gax/2.24.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.23.3](/java/docs/reference/gax/2.23.3/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.22.0](/java/docs/reference/gax/2.22.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.21.0](/java/docs/reference/gax/2.21.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.20.1](/java/docs/reference/gax/2.20.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.19.6](/java/docs/reference/gax/2.19.6/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.18.7](/java/docs/reference/gax/2.18.7/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.17.0](/java/docs/reference/gax/2.17.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.16.0](/java/docs/reference/gax/2.16.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.15.0](/java/docs/reference/gax/2.15.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.14.0](/java/docs/reference/gax/2.14.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.13.0](/java/docs/reference/gax/2.13.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.12.2](/java/docs/reference/gax/2.12.2/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.11.0](/java/docs/reference/gax/2.11.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.10.0](/java/docs/reference/gax/2.10.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.9.0](/java/docs/reference/gax/2.9.0/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.8.1](/java/docs/reference/gax/2.8.1/com.google.api.gax.httpjson.HttpJsonClientCall)\n- [2.7.1](/java/docs/reference/gax/2.7.1/com.google.api.gax.httpjson.HttpJsonClientCall) \n\n public abstract class HttpJsonClientCall\u003cRequestT,ResponseT\u003e\n\nAn instance of a call to a remote method. A call will send zero or more request messages to the\nserver and receive zero or more response messages back.\n\nInstances are created by a [HttpJsonChannel](/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonChannel) and used by stubs to invoke their remote\nbehavior.\n\n#start must be called prior to calling any other methods, with the exception of #cancel. Whereas #cancel must not be followed by any other methods, but can be called\nmore than once, while only the first one has effect.\n\nMethods are potentially blocking but are designed to execute quickly. The implementations of\nthis class are expected to be thread-safe.\n\nThere is a race between #cancel and the completion/failure of the RPC in other ways.\nIf #cancel won the race, Listener.onClose()\nis called with `statusCode` corresponding to [CANCELLED](/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code#com_google_api_gax_rpc_StatusCode_Code_CANCELLED). Otherwise, Listener.onClose() is called with whatever status the RPC\nwas finished. We ensure that at most one is called. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e HttpJsonClientCall\\\u003cRequestT,ResponseT\\\u003e \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### HttpJsonClientCall()\n\n public HttpJsonClientCall()\n\nMethods\n-------\n\n### cancel(String message, Throwable cause)\n\n public abstract void cancel(String message, Throwable cause)\n\nPrevent any further processing for this `HttpJsonClientCall`. No further messages may be\nsent or will be received. The server is not informed of cancellations. Cancellation is\npermitted even if previously #halfClosed. Cancelling an already `cancel()`ed\n`ClientCall` has no effect.\n\nNo other methods on this class can be called after this method has been called.\n\n### halfClose()\n\n public abstract void halfClose()\n\nClose the call for request message sending. Incoming response messages are unaffected. This\nshould be called when no more messages will be sent from the client.\n\n### request(int numMessages)\n\n public abstract void request(int numMessages)\n\nRequests up to the given number of messages from the call to be delivered to [HttpJsonClientCall.Listener#onMessage(Object)](/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonClientCall.Listener#com_google_api_gax_httpjson_HttpJsonClientCall_Listener_onMessage_). No additional messages will be delivered.\n\nMessage delivery is guaranteed to be sequential in the order received. In addition, the\nlistener methods will not be accessed concurrently. While it is not guaranteed that the same\nthread will always be used, it is guaranteed that only a single thread will access the listener\nat a time.\n\nIf called multiple times, the number of messages able to delivered will be the sum of the\ncalls.\n\nThis method is safe to call from multiple threads without external synchronization.\n\n### sendMessage(RequestT message)\n\n public abstract void sendMessage(RequestT message)\n\nSend a request message to the server. May be called zero or more times but for unary and server\nstreaming calls it must be called not more than once.\n\n### start(HttpJsonClientCall.Listener\\\u003cResponseT\\\u003e responseListener, HttpJsonMetadata requestHeaders)\n\n public abstract void start(HttpJsonClientCall.Listener\u003cResponseT\u003e responseListener, HttpJsonMetadata requestHeaders)\n\nStart a call, using `responseListener` for processing response messages.\n\nIt must be called prior to any other method on this class, except for #cancel which\nmay be called at any time."]]