yes, there is a way. Use extension elements and task listener in the receive task. Task listener should run your query with runtime service. To include currently running process instance into the query make receive task async (transaction is committed).
Thanks Martin, could you please give me more details about the query?
I saw that with HistoricProcessInstanceQuery I can retrieve unfinished processes, but I need also distinguish suspended processes from those in receive task. Both processes are in ACT_HI_PROCINST table and are unfinished.
The used statement is the following: <java>List<HistoricProcessInstance> unfinishedProcs = historyService.createHistoricProcessInstanceQuery().unfinished().list();</java>
to query for suspended processes use runtime service (runtimeService.createProcessInstanceQuery().suspended().list()). I did not find a way how to distinguish between suspended/non-suspended processes in HistoricQuery. If you wan to fetch all process instances in one query use native API. To query for all jobs use management service