Example #1
0
        public virtual CorrelationHandlerResult CorrelateMessage(CommandContext commandContext, string messageName,
                                                                 CorrelationSet correlationSet)
        {
            // first try to correlate to execution
            var correlations = CorrelateMessageToExecutions(commandContext, messageName, correlationSet);

            if (correlations.Count > 1)
            {
                throw Log.ExceptionCorrelateMessageToSingleExecution(messageName, correlations.Count, correlationSet);
            }
            if (correlations.Count == 1)
            {
                return(correlations[0]);
            }

            // then try to correlate to process definition
            correlations = CorrelateStartMessages(commandContext, messageName, correlationSet);

            if (correlations.Count > 1)
            {
                throw Log.ExceptionCorrelateMessageToSingleProcessDefinition(messageName, correlations.Count,
                                                                             correlationSet);
            }
            if (correlations.Count == 1)
            {
                return(correlations[0]);
            }
            return(null);
        }