protected internal virtual IList <EventSubscriptionEntity> FindSignalEventSubscriptions(
            CommandContext commandContext, string signalName)
        {
            IEventSubscriptionManager eventSubscriptionManager = commandContext.EventSubscriptionManager;

            if (Builder.IsTenantIdSet)
            {
                return(eventSubscriptionManager.FindSignalEventSubscriptionsByEventNameAndTenantId(signalName,
                                                                                                   Builder.TenantId));
            }
            return(eventSubscriptionManager.FindSignalEventSubscriptionsByEventName(signalName));
        }
        protected internal virtual IList <EventSubscriptionEntity> FindSignalEventSubscriptions(string signalName,
                                                                                                string tenantId)
        {
            IEventSubscriptionManager eventSubscriptionManager = Context.CommandContext.EventSubscriptionManager;

            if (!ReferenceEquals(tenantId, null))
            {
                return
                    (eventSubscriptionManager.FindSignalEventSubscriptionsByEventNameAndTenantIdIncludeWithoutTenantId(
                         signalName, tenantId));
            }
            // find event subscriptions without tenant id
            //Preparing: select EVT.* from ACT_RU_EVENT_SUBSCR EVT left join ACT_RU_EXECUTION EXC on EVT.EXECUTION_ID_ = EXC.ID_ where (EVENT_TYPE_ = 'signal') and (EVENT_NAME_ = ?) and (EVT.EXECUTION_ID_ is null or EXC.SUSPENSION_STATE_ = 1) and EVT.TENANT_ID_ is null
            return(eventSubscriptionManager.FindSignalEventSubscriptionsByEventNameAndTenantId(signalName, null));
        }