Processing mode is set by adding the X-Cumulocity-Processing-Mode
header to any request. The intended way of accessing headers in cumulocity java client is through interceptors.
You can register an interceptor on your desired Platform
bean using the registerInterceptor()
method. You can instantiate a separate Platform
bean for this purpose or try to modify the ones provided by the SDK.
Ok thanks, just understood that I had to explicitely cast the Platform bean to PlatformImpl. Not nice, but that does the job.
@Cyril_Poder Would it be possible to post a code example how you finally achieved changing the processing mode?
Yep, basically you first inject the platform bean in you class, like:
private final Platform platform;
given that you’re using Lombok with @RequiredArgsConstructor
annotation.
Then you’d have something like:
((PlatformImpl)platform).registerInterceptor((new HttpClientInterceptor() {
@Override
public Invocation.Builder apply(Invocation.Builder builder) {
return builder.header("X-Cumulocity-Processing-Mode", "TRANSIENT");
}
}));
The imports, in case you’re wondering, for Platform and Invocation.Builder are:
import com.cumulocity.sdk.client.Platform;
import com.cumulocity.sdk.client.PlatformImpl;
import javax.ws.rs.client.Invocation;
Of course this is not how one should implement it, as doing this you definately change the processing mode, so you’d rather either unregister the interceptor after your call or handle the value of the processing mode centrally, but that’s up to what you need to achieve.