public BatchRequest( final MediaType mediaType, final String address, final List<?> providers, final String jwt) { this.mediaType = mediaType; this.jwt = jwt; this.address = address; this.providers = providers; initBatchClientFactoryBean(); }
public BatchRequest( final MediaType mediaType, final String address, final List<?> providers, final String jwt) { this.mediaType = mediaType; this.jwt = jwt; this.address = address; this.providers = providers; initBatchClientFactoryBean(); }
/** * Sends the current request, with items accumulated by invoking methods on proxies obtained via * {@link #getService(java.lang.Class)}, to the Batch service, and awaits for a synchronous or asynchronous * response, depending on the {@code async} parameter. * It also clears out the accumulated items, in case of reuse of this instance for subsequent requests. * * @param async whether asynchronous Batch process is requested, or not * @return batch response */ public BatchResponse commit(final boolean async) { String boundary = "--batch_" + UUID.randomUUID().toString(); WebClient webClient = WebClient.create(bcfb.getAddress()).path("batch"). header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt). type(RESTHeaders.multipartMixedWith(boundary.substring(2))); if (async) { webClient.header(RESTHeaders.PREFER, Preference.RESPOND_ASYNC); } String body = BatchPayloadGenerator.generate(bcfb.getBatchRequestItems(), boundary); LOG.debug("Batch request body:\n{}", body); initBatchClientFactoryBean(); return new BatchResponse(boundary, jwt, webClient.post(body)); } }
/** * Sends the current request, with items accumulated by invoking methods on proxies obtained via * {@link #getService(java.lang.Class)}, to the Batch service, and awaits for a synchronous or asynchronous * response, depending on the {@code async} parameter. * It also clears out the accumulated items, in case of reuse of this instance for subsequent requests. * * @param async whether asynchronous Batch process is requested, or not * @return batch response */ public BatchResponse commit(final boolean async) { String boundary = "--batch_" + UUID.randomUUID().toString(); WebClient webClient = WebClient.create(bcfb.getAddress()).path("batch"). header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt). type(RESTHeaders.multipartMixedWith(boundary.substring(2))); if (async) { webClient.header(RESTHeaders.PREFER, Preference.RESPOND_ASYNC); } String body = BatchPayloadGenerator.generate(bcfb.getBatchRequestItems(), boundary); LOG.debug("Batch request body:\n{}", body); initBatchClientFactoryBean(); return new BatchResponse(boundary, jwt, webClient.post(body)); } }