skipcheck

TM1 client · Docs · The client

Tm1Batch

import io.skipcheck.tm1.client.Tm1Batch;

A JSON $batch being put together, from Tm1Client.batch: calls made through client are queued rather than sent, and run sends them together. Each call's result is there once the batch has run. Every service's methods work through it unchanged. TM1 (11.8) runs the calls in the order they were made, so a later call sees an earlier one's writes. See Tm1SessionBatch for what else TM1 does with a batch.

Read three things in one round trip:

// Each call is queued as it's made, and has its result once the batch has run
Tm1Batch batch = tm1.batch();
Mono<Cube> sales = batch.client().cubes().get("Sales", ODataQuery.none());
Mono<Dimension> region = batch.client().dimensions().get("Region", ODataQuery.none());
Flux<Process> processes = batch.client().processes().list(ODataQuery.none().select(Process.NAME));
return batch.run().then(Mono.zip(sales, region, processes.collectList()));

Create many elements in batches of 200, each failure kept to its own element:

// One request per element, 200 to a $batch; one element's failure is its own
Tm1Batch batch = tm1.batch();
List<Mono<String>> results = cities.stream()
    .map(city -> batch.client()
        .elements()
        .create("City", "City", ElementPatch.builder().name(city).build())
        .map(Element::name)
        .onErrorResume(e -> Mono.just(city + " failed: " + e.getMessage())))
    .toList();
return batch.run(200).thenMany(Flux.concat(results));

Members

clientThe client whose calls join this batch.
sizeHow many requests have joined.
runSends the queued requests (Tm1SessionBatch.run).
runSends the queued requests, at most perRequest to each $batch (Tm1SessionBatch.run).

client

Tm1Client client()

The client whose calls join this batch. A call's request is queued when the call is made; its result is there once the batch has run.

Returns

the client

size

int size()

How many requests have joined.

Returns

the number

run

Mono<Void> run()

Sends the queued requests (Tm1SessionBatch.run).

Returns

completes when every call has its result

run

Mono<Void> run(int perRequest)

Sends the queued requests, at most perRequest to each $batch (Tm1SessionBatch.run).

Parameters

perRequest
the most requests in one $batch

Returns

completes when every call has its result

Also in the Javadoc.