Esempio n. 1
0
        /// <summary>
        /// Add data to the current correlation
        /// </summary>
        /// <remarks>If there is no current correlation, starts a new correlation</remarks>
        /// <param name="key">key (name) of the correlation</param>
        /// <param name="value">value of the added correlation data</param>
        public void CorrelationAdd(string key, string value)
        {
            Code.ExpectsNotNullOrWhiteSpaceArgument(key, nameof(key), TaggingUtilities.ReserveTag(0x2381771e /* tag_96x24 */));
            Code.ExpectsNotNullOrWhiteSpaceArgument(value, nameof(value), TaggingUtilities.ReserveTag(0x2381771f /* tag_96x25 */));

            CorrelationData data = CurrentCorrelation;

            if (data == null)
            {
                CorrelationStart(null);
                data = CurrentCorrelation;
            }

            if (data != null)
            {
                string oldData = data.Data(key);

                CorrelationHandler.CorrelationAdd(key, value, data);

                EventHandler <CorrelationEventArgs> correlationDataAdded = CorrelationDataAdded;
                if (correlationDataAdded != null)
                {
                    correlationDataAdded(this, new CorrelationEventArgs(data, key, oldData));
                }
            }
        }
Esempio n. 2
0
 public CallableAnonymousInnerClass(CorrelateAllMessageCmd outerInstance, CommandContext commandContext, CorrelationHandler correlationHandler, CorrelationSet correlationSet)
 {
     this.outerInstance      = outerInstance;
     this.commandContext     = commandContext;
     this.correlationHandler = correlationHandler;
     this.correlationSet     = correlationSet;
 }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public java.util.List<org.camunda.bpm.engine.impl.runtime.MessageCorrelationResultImpl> execute(final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext)
        public virtual IList <MessageCorrelationResultImpl> execute(CommandContext commandContext)
        {
            ensureAtLeastOneNotNull("At least one of the following correlation criteria has to be present: " + "messageName, businessKey, correlationKeys, processInstanceId", messageName, builder.BusinessKey, builder.CorrelationProcessInstanceVariables, builder.ProcessInstanceId);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.CorrelationHandler correlationHandler = org.camunda.bpm.engine.impl.context.Context.getProcessEngineConfiguration().getCorrelationHandler();
            CorrelationHandler correlationHandler = Context.ProcessEngineConfiguration.CorrelationHandler;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.CorrelationSet correlationSet = new org.camunda.bpm.engine.impl.runtime.CorrelationSet(builder);
            CorrelationSet correlationSet = new CorrelationSet(builder);
            IList <CorrelationHandlerResult> correlationResults = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, commandContext, correlationHandler, correlationSet));

            // check authorization
            foreach (CorrelationHandlerResult correlationResult in correlationResults)
            {
                checkAuthorization(correlationResult);
            }

            IList <MessageCorrelationResultImpl> results = new List <MessageCorrelationResultImpl>();

            foreach (CorrelationHandlerResult correlationResult in correlationResults)
            {
                results.Add(createMessageCorrelationResult(commandContext, correlationResult));
            }

            return(results);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public org.camunda.bpm.engine.runtime.ProcessInstance execute(final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext)
        public virtual ProcessInstance execute(CommandContext commandContext)
        {
            ensureNotNull("messageName", messageName);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.CorrelationHandler correlationHandler = org.camunda.bpm.engine.impl.context.Context.getProcessEngineConfiguration().getCorrelationHandler();
            CorrelationHandler correlationHandler = Context.ProcessEngineConfiguration.CorrelationHandler;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.CorrelationSet correlationSet = new org.camunda.bpm.engine.impl.runtime.CorrelationSet(builder);
            CorrelationSet correlationSet = new CorrelationSet(builder);

            IList <CorrelationHandlerResult> correlationResults = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, commandContext, correlationHandler, correlationSet));

            if (correlationResults.Count == 0)
            {
                throw new MismatchingMessageCorrelationException(messageName, "No process definition matches the parameters");
            }
            else if (correlationResults.Count > 1)
            {
                throw LOG.exceptionCorrelateMessageToSingleProcessDefinition(messageName, correlationResults.Count, correlationSet);
            }
            else
            {
                CorrelationHandlerResult correlationResult = correlationResults[0];

                checkAuthorization(correlationResult);

                ProcessInstance processInstance = instantiateProcess(commandContext, correlationResult);
                return(processInstance);
            }
        }
        public CorrelationHandler SetupCorrelationHandler()
        {
            var handler = new CorrelationHandler();

            var innerHandler = new InnerHandlerMock();

            innerHandler.AssertResponse(new HttpResponseMessage(HttpStatusCode.OK));
            handler.InnerHandler = innerHandler;

            return(handler);
        }
        public void UncorrelatedMessage_Should_Not_Propagate_To_Next_Pipeline()
        {
            var correlationManager = Substitute.For <IMessageCorrelationManager>();

            correlationManager.TryMatchResponse(Arg.Any <ProtocolMessage>()).Returns(false);

            var correlationHandler    = new CorrelationHandler <IMessageCorrelationManager>(correlationManager);
            var channelHandlerContext = Substitute.For <IChannelHandlerContext>();
            var nonCorrelatedMessage  =
                new PingResponse().ToProtocolMessage(PeerIds[0], CorrelationId.GenerateCorrelationId());

            correlationHandler.ChannelRead(channelHandlerContext, nonCorrelatedMessage);

            channelHandlerContext.DidNotReceive().FireChannelRead(nonCorrelatedMessage);
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public org.camunda.bpm.engine.impl.runtime.MessageCorrelationResultImpl execute(final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext)
        public virtual MessageCorrelationResultImpl execute(CommandContext commandContext)
        {
            ensureAtLeastOneNotNull("At least one of the following correlation criteria has to be present: " + "messageName, businessKey, correlationKeys, processInstanceId", messageName, builder.BusinessKey, builder.CorrelationProcessInstanceVariables, builder.ProcessInstanceId);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.CorrelationHandler correlationHandler = org.camunda.bpm.engine.impl.context.Context.getProcessEngineConfiguration().getCorrelationHandler();
            CorrelationHandler correlationHandler = Context.ProcessEngineConfiguration.CorrelationHandler;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.CorrelationSet correlationSet = new org.camunda.bpm.engine.impl.runtime.CorrelationSet(builder);
            CorrelationSet correlationSet = new CorrelationSet(builder);

            CorrelationHandlerResult correlationResult = null;

            if (startMessageOnly)
            {
                IList <CorrelationHandlerResult> correlationResults = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, commandContext, correlationHandler, correlationSet));
                if (correlationResults.Count == 0)
                {
                    throw new MismatchingMessageCorrelationException(messageName, "No process definition matches the parameters");
                }
                else if (correlationResults.Count > 1)
                {
                    throw LOG.exceptionCorrelateMessageToSingleProcessDefinition(messageName, correlationResults.Count, correlationSet);
                }
                else
                {
                    correlationResult = correlationResults[0];
                }
            }
            else
            {
                correlationResult = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass2(this, commandContext, correlationHandler, correlationSet));

                if (correlationResult == null)
                {
                    throw new MismatchingMessageCorrelationException(messageName, "No process definition or execution matches the parameters");
                }
            }

            // check authorization
            checkAuthorization(correlationResult);

            return(createMessageCorrelationResult(commandContext, correlationResult));
        }
Esempio n. 8
0
        /// <summary>
        /// End the correlation
        /// </summary>
        /// <param name="id">Id of the thread</param>
        /// <param name="invokeEventHandler">Should we invoke the correlation ended event handler</param>
        public void CorrelationEnd(int?id = null, bool invokeEventHandler = true)
        {
            CorrelationData correlationData = GetCorrelationData(id);

            if (correlationData != null)
            {
                CurrentCorrelation = correlationData.ParentCorrelation;

                CorrelationHandler.CorrelationEnd(correlationData);

                if (invokeEventHandler)
                {
                    EventHandler <CorrelationEventArgs> correlationEnded = CorrelationEnded;
                    if (correlationEnded != null)
                    {
                        correlationEnded(this, new CorrelationEventArgs(correlationData));
                    }
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Start a correlation
        /// </summary>
        /// <param name="data">correlation to set on the thread, null for default (new) correlation</param>
        public void CorrelationStart(CorrelationData data)
        {
            data = CorrelationHandler.CorrelationStart(data);
            if (data != null)
            {
                data.ParentCorrelation = CurrentCorrelation;
                if (data.ParentCorrelation == null)
                {
                    data.ShouldLogDirectly = ShouldLogDirectly;
                }

                CurrentCorrelation = data;

                // Note: Creating a copy of the event handler to avoid multi-threaded race conditions
                // Not creating extension methods to avoid unnecessary creating of arguments if not set
                EventHandler <CorrelationEventArgs> correlationStarted = CorrelationStarted;
                if (correlationStarted != null)
                {
                    correlationStarted(this, new CorrelationEventArgs(data));
                }
            }
        }