Fetching Camunda variables through zeebe client

Hello,
Im running a Java+spring app as a worker app, however, my spring app is supposed to also query zeebe engine outside of worker scope. For example, to perform one of the use cases, I need to query process variables, I have the process key and ZeebeClient, however I do not see any option to access variables of this process…

for example:

Optional<ProcessInstance> pi = zeebeClient.newProcessInstanceQuery().filter(piFilter -> piFilter.parentProcessInstanceKey(processInstanceKey)).send().join().items().stream().findFirst();

this will provide me with my process instance, however, the ProcessInstance interface seem to be missing any kind of information about variables, nor I have I found anything to query variables in zeebeClient library for java in version 8.6.6, am I missing something? How can I access the process variables outside of worker scope?

In Zeebe 8.6.6, the Java client API doesn’t allow direct access to process variables. You can use the Camunda Operate API to query them via REST, store variables in a database during execution, or extract them from worker job payloads. Using the Operate API is similar to Spotify’s API for structured data and is the best solution for scalability.