{"record":{"id":"97d2ec08712b1cfa","repo":"flowable/flowable-engine","slug":"cannot-combine-onlytimers-with-onlymessages-in-97d2ec","errorCode":null,"errorMessage":"Cannot combine onlyTimers() with onlyMessages() in the same query","messagePattern":"Cannot combine onlyTimers\\(\\) with onlyMessages\\(\\) in the same query","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/SuspendedJobQueryImpl.java","lineNumber":442,"sourceCode":"            retriesLeft = true;\n        }\n        return this;\n    }\n\n    @Override\n    public SuspendedJobQueryImpl executable() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.executable = true;\n        } else {\n            executable = true;\n        }\n        return this;\n    }\n\n    @Override\n    public SuspendedJobQueryImpl timers() {\n        if (onlyMessages) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyTimers() with onlyMessages() in the same query\");\n        }\n\n        if (onlyExternalWorkers) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyExternalWorkers() with onlyMessages() in the same query\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.onlyTimers = true;\n        } else {\n            this.onlyTimers = true;\n        }\n        return this;\n    }\n\n    @Override\n    public SuspendedJobQueryImpl messages() {\n        if (onlyTimers) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyTimers() with onlyMessages() in the same query\");\n        }","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/SuspendedJobQueryImpl.java#L424-L460","documentation":"SuspendedJobQueryImpl.timers() throws FlowableIllegalArgumentException when the query was already narrowed with onlyMessages(). Job kind filters are mutually exclusive: a query can select timers, messages, or external-worker jobs, but not a combination. Flowable detects the conflict at query-build time and fails fast rather than producing contradictory SQL.","triggerScenarios":"Chaining .messages().timers() (in either order) on the same SuspendedJobQueryImpl instance, including inside an or() block where the flags live on the same query object.","commonSituations":"Developers assuming the filters are additive (like category filters) and calling both to mean 'timers OR messages'; copy-paste of query-builder chains where an extra .timers() was left behind.","solutions":["Call only one of timers(), messages(), or externalWorkers() per query.","If you need both timers and messages, run two queries and merge results in application code.","Remove the redundant/conflicting call from the builder chain."],"exampleFix":"// before\njobService.createSuspendedJobQuery().messages().timers(); // throws\n// after\njobService.createSuspendedJobQuery().messages(); // or .timers(), not both","handlingStrategy":"type-guard","validationCode":"boolean kindAlreadySet = onlyMessages || onlyTimers || onlyExternalWorkers;\nif (kindAlreadySet) throw new IllegalStateException(\"Job kind filter already set; cannot add another\");","typeGuard":"boolean canApplyTimers(SuspendedJobQueryImpl q) { return !q.isOnlyMessages() && !q.isOnlyExternalWorkers(); }","tryCatchPattern":"try {\n    query.messages().timers();\n} catch (FlowableIllegalArgumentException e) {\n    // split into two queries instead\n}","preventionTips":["Never chain more than one of timers()/messages()/externalWorkers().","Track which kind filter was applied in your own builder wrapper to prevent double calls.","Use separate query executions to union different job kinds."],"tags":["flowable","query","mutually-exclusive","job-service","timers"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}