flowable/flowable-engine · error · FlowableIllegalArgumentException

Cannot combine onlyOutbound() with onlyInbound() in the same

Error message

Cannot combine onlyOutbound() with onlyInbound() in the same query

What it means

ChannelDefinitionQueryImpl.onlyOutbound() throws FlowableIllegalArgumentException if onlyInbound() was already called on the same query. The inbound/outbound direction filters are mutually exclusive; setting both on one ChannelDefinitionQuery is a contradiction, so the second call fails fast with a clear message.

Source

Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/ChannelDefinitionQueryImpl.java:258

    @Override
    public ChannelDefinitionQueryImpl latestVersion() {
        this.latest = true;
        return this;
    }
    
    @Override
    public ChannelDefinitionQuery onlyInbound() {
        if (onlyOutbound) {
            throw new FlowableIllegalArgumentException("Cannot combine onlyInbound() with onlyOutbound() in the same query");
        }
        this.onlyInbound = true;
        return this;
    }

    @Override
    public ChannelDefinitionQuery onlyOutbound() {
        if (onlyInbound) {
            throw new FlowableIllegalArgumentException("Cannot combine onlyOutbound() with onlyInbound() in the same query");
        }
        this.onlyOutbound = true;
        return this;
    }

    @Override
    public ChannelDefinitionQuery implementation(String implementation) {
        if (implementation == null) {
            throw new FlowableIllegalArgumentException("implementation is null");
        }
        this.implementation = implementation;
        return this;
    }

    @Override
    public ChannelDefinitionQueryImpl channelCreateTime(Date createTime) {
        this.createTime = createTime;
        return this;

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Apply only one directional filter per query instance
  2. If both directions are needed, drop both filters to query all definitions and filter results in Java, or run two queries
  3. Validate mutually exclusive options before building the query
  4. Start a fresh ChannelDefinitionQuery when switching direction

Example fix

// before
query.onlyInbound();
query.onlyOutbound(); // throws
// after
if (direction.equals("inbound")) {
    query.onlyInbound();
} else if (direction.equals("outbound")) {
    query.onlyOutbound();
}
Defensive patterns

Strategy: validation

Validate before calling

if (wantInbound && wantOutbound) {
    throw new IllegalArgumentException("onlyOutbound cannot follow onlyInbound on the same query");
}
if (wantOutbound) {
    query.onlyOutbound();
}

Type guard

boolean directionNotSet(ChannelDefinitionQueryImpl q) {
    return !q.isOnlyInboundSet() && !q.isOnlyOutboundSet();
}

Try / catch

try {
    query.onlyOutbound();
} catch (FlowableIllegalArgumentException e) {
    logger.warn("Conflicting direction filters: {}", e.getMessage());
    query = channelDefinitionQuery().onlyOutbound(); // rebuild cleanly
}

Prevention

When it happens

Trigger: Calling query.onlyInbound().onlyOutbound() (in either order), or code paths that add the outbound filter after the inbound filter was applied earlier in the builder chain.

Common situations: Dynamic query assembly accumulating filters from user-selected checkboxes (both 'inbound' and 'outbound' selected); duplicated filter code after refactoring.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/dc855ce9253af873. Report an issue: GitHub.