Package io.camunda.client.impl.http
Class DocumentDataConsumer<T>
java.lang.Object
io.camunda.client.impl.http.DocumentDataConsumer<T>
- Type Parameters:
T- the type of the successful response body, always anInputStream
- All Implemented Interfaces:
CircularBufferInputStream.CapacityCallback,org.apache.hc.core5.http.nio.AsyncDataConsumer,org.apache.hc.core5.http.nio.AsyncEntityConsumer<ApiEntity<T>>,org.apache.hc.core5.http.nio.ResourceHolder
public class DocumentDataConsumer<T>
extends Object
implements org.apache.hc.core5.http.nio.AsyncEntityConsumer<ApiEntity<T>>, CircularBufferInputStream.CapacityCallback
An asynchronous consumer for binary data that represents a document.
This implementation guarantees that the data is consumed in a non-blocking manner, and that
the data is stored in a buffer with a fixed capacity. The consumer works with a CapacityChannel to notify the I/O layer when more data can be read from the network.
If the server returns:
- application/octet-stream: the data is returned as an
InputStream - application/problem+json: the data is returned as a
ProblemDetail
The input stream response is returned via the result callback immediately as soon as the
content type is determined to be application/octet-stream. This allows the caller to
start reading the data in a streaming fashion and does not require the entire response body to be
buffered in memory.
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentDataConsumer(int bufferCapacity, com.fasterxml.jackson.databind.ObjectMapper json) -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(ByteBuffer src) voidvoidonCapacityAvailable(int increment) voidvoidvoidstreamStart(org.apache.hc.core5.http.EntityDetails entityDetails, org.apache.hc.core5.concurrent.FutureCallback<ApiEntity<T>> resultCallback) voidupdateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)
-
Constructor Details
-
DocumentDataConsumer
public DocumentDataConsumer(int bufferCapacity, com.fasterxml.jackson.databind.ObjectMapper json)
-
-
Method Details
-
streamStart
public void streamStart(org.apache.hc.core5.http.EntityDetails entityDetails, org.apache.hc.core5.concurrent.FutureCallback<ApiEntity<T>> resultCallback) - Specified by:
streamStartin interfaceorg.apache.hc.core5.http.nio.AsyncEntityConsumer<T>
-
failed
- Specified by:
failedin interfaceorg.apache.hc.core5.http.nio.AsyncEntityConsumer<T>
-
getContent
- Specified by:
getContentin interfaceorg.apache.hc.core5.http.nio.AsyncEntityConsumer<T>
-
updateCapacity
public void updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel) throws IOException - Specified by:
updateCapacityin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
consume
- Specified by:
consumein interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
streamEnd
- Specified by:
streamEndin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
releaseResources
public void releaseResources()- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-
onCapacityAvailable
public void onCapacityAvailable(int increment) - Specified by:
onCapacityAvailablein interfaceCircularBufferInputStream.CapacityCallback
-