code: @Override
      public TaskInstance findTaskByWorkItemId(Long workItemId) {
          if( config.isRest() ) {
              Map<String, Object> valuesMap = new HashMap<String, Object>();
              valuesMap.put(WORK_ITEM_ID, workItemId);
  
              return makeHttpGetRequestAndCreateCustomResponse(
                      build(loadBalancer.getUrl(), QUERY_URI + "/" + TASK_BY_WORK_ITEM_ID_GET_URI, valuesMap), TaskInstance.class);
  
  
          } else {
              CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "QueryService", "getTaskByWorkItemId", new Object[]{workItemId}) ) );
              ServiceResponse<TaskInstance> response = (ServiceResponse<TaskInstance>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM" ).getResponses().get(0);
  
              throwExceptionOnFailure(response);
              if (shouldReturnWithNullResponse(response)) {
                  return null;
              }
              return response.getResult();
          }
      }
docs: task basic queries