Identifying message subscriptions which are linked to event-based gateways

I am using this query runtimeService.createEventSubscriptionQuery().withoutTenantId().eventType("message").list() which gives a list of message subscriptions (they can be intermediate catch events, receive tasks,…) and I get input parameters of those subscriptions using runtimeService.getVariablesLocal(subscription.getExecutionId()).

However, as you can see in this other topic Rest Correlate Message with localVariables for Event Based Gateway, when the subscription comes right after an event-based gateway, I cannot access the input local variables even if the message subscription is there.

I was wondering if there is a way to identify message event subscriptions which are linked to an event-based gateway, using the Java API, so that I can handle them accordingly.

Thanks.