Beispiel #1
0
        public virtual void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance activityInstance, IList <JobEntity> elements)
        {
            IDictionary <string, TimerDeclarationImpl> sourceTimerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.SourceScope);
            IDictionary <string, TimerDeclarationImpl> targetTimerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.TargetScope);

            foreach (JobEntity job in elements)
            {
                if (!isTimerJob(job))
                {
                    // skip non timer jobs
                    continue;
                }

                MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(job.ActivityId);
                ActivityImpl         targetActivity       = parseContext.getTargetActivity(migrationInstruction);

                if (targetActivity != null && activityInstance.migratesTo(targetActivity.EventScope))
                {
                    // the timer job is migrated
                    JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(targetActivity.ActivityId, job.JobHandlerType);

                    TimerDeclarationImpl targetTimerDeclaration = targetTimerDeclarationsInEventScope.Remove(targetActivity.Id);

                    MigratingJobInstance migratingTimerJobInstance = new MigratingTimerJobInstance(job, targetJobDefinitionEntity, targetActivity, migrationInstruction.UpdateEventTrigger, targetTimerDeclaration);
                    activityInstance.addMigratingDependentInstance(migratingTimerJobInstance);
                    parseContext.submit(migratingTimerJobInstance);
                }
                else
                {
                    // the timer job is removed
                    MigratingJobInstance removingJobInstance = new MigratingTimerJobInstance(job);
                    activityInstance.addRemovingDependentInstance(removingJobInstance);
                    parseContext.submit(removingJobInstance);
                }

                parseContext.consume(job);
            }

            if (activityInstance.migrates())
            {
                addEmergingTimerJobs(parseContext, activityInstance, sourceTimerDeclarationsInEventScope, targetTimerDeclarationsInEventScope);
            }
        }
Beispiel #2
0
        public virtual void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, IList <JobEntity> elements)
        {
            foreach (JobEntity job in elements)
            {
                if (!isAsyncContinuation(job))
                {
                    continue;
                }

                ScopeImpl targetScope = transitionInstance.TargetScope;
                if (targetScope != null)
                {
                    JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.TargetScope.Id, job.JobHandlerType);

                    MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.TargetScope);

                    transitionInstance.DependentJobInstance = migratingJobInstance;
                    parseContext.submit(migratingJobInstance);
                }

                parseContext.consume(job);
            }
        }