示例#1
0
        public Message CreateMessage(InvokeMethodRequest request, InvokeMethodOptions options)
        {
            var message = new Message
            {
                Category                 = Message.Categories.Application,
                Direction                = (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request,
                Id                       = CorrelationId.GetNext(),
                IsReadOnly               = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered              = (options & InvokeMethodOptions.Unordered) != 0,
                IsAlwaysInterleave       = (options & InvokeMethodOptions.AlwaysInterleave) != 0,
                BodyObject               = request,
                IsUsingInterfaceVersions = request.InterfaceVersion > 0,
                RequestContextData       = RequestContextExtensions.Export(this.serializationManager)
            };

            if (options.IsTransactional())
            {
                SetTransaction(message, options);
            }
            else
            {
                // clear transaction info if not in transaction
                message.RequestContextData?.Remove(TransactionContext.Orleans_TransactionContext_Key);
            }


            return(message);
        }
示例#2
0
        public Message CreateMessage(InvokeMethodRequest request, InvokeMethodOptions options)
        {
            var direction = (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request;
            var message   = new Message
            {
                Category                 = Message.Categories.Application,
                Direction                = direction,
                Id                       = CorrelationId.GetNext(),
                IsReadOnly               = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered              = (options & InvokeMethodOptions.Unordered) != 0,
                IsTransactionRequired    = (options & InvokeMethodOptions.TransactionRequiresNew) != 0 || (options & InvokeMethodOptions.TransactionRequired) != 0,
                BodyObject               = request,
                IsUsingInterfaceVersions = request.InterfaceVersion > 0,
            };

            TransactionInfo transactionInfo = message.IsTransactionRequired ? TransactionContext.GetTransactionInfo() : null;

            if (transactionInfo != null)
            {
                transactionInfo.PendingCalls++;
                message.TransactionInfo = new TransactionInfo(transactionInfo);
            }

            if ((options & InvokeMethodOptions.AlwaysInterleave) != 0)
            {
                message.IsAlwaysInterleave = true;
            }

            message.RequestContextData = RequestContext.Export(this.serializationManager);
            return(message);
        }
示例#3
0
        internal static Message CreateMessage(InvokeMethodRequest request, InvokeMethodOptions options)
        {
            var message = new Message(
                Categories.Application,
                (options & InvokeMethodOptions.OneWay) != 0 ? Directions.OneWay : Directions.Request)
            {
                Id          = CorrelationId.GetNext(),
                IsReadOnly  = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered = (options & InvokeMethodOptions.Unordered) != 0,
                BodyObject  = request
            };

            if ((options & InvokeMethodOptions.AlwaysInterleave) != 0)
            {
                message.IsAlwaysInterleave = true;
            }

            var contextData = RequestContext.Export();

            if (contextData != null)
            {
                message.RequestContextData = contextData;
            }
            return(message);
        }
示例#4
0
        public Message CreateMessage(object body, InvokeMethodOptions options)
        {
            var(requestContextData, runningRequest) = RequestContextExtensions.ExportInternal(this.deepCopier);
            var callChainId = runningRequest switch
            {
                Message msg when msg.CallChainId != Guid.Empty => msg.CallChainId,
                _ => Guid.NewGuid(),
            };

            var message = new Message
            {
                Category           = Message.Categories.Application,
                Direction          = (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request,
                Id                 = CorrelationId.GetNext(),
                IsReadOnly         = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered        = (options & InvokeMethodOptions.Unordered) != 0,
                IsAlwaysInterleave = (options & InvokeMethodOptions.AlwaysInterleave) != 0,
                BodyObject         = body,
                RequestContextData = requestContextData,
                CallChainId        = callChainId,
            };

            messagingTrace.OnCreateMessage(message);
            return(message);
        }
示例#5
0
        public Message CreateMessage(object body, InvokeMethodOptions options)
        {
            var message = new Message
            {
                Category           = Message.Categories.Application,
                Direction          = (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request,
                Id                 = CorrelationId.GetNext(),
                IsReadOnly         = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered        = (options & InvokeMethodOptions.Unordered) != 0,
                IsAlwaysInterleave = (options & InvokeMethodOptions.AlwaysInterleave) != 0,
                BodyObject         = body,
                RequestContextData = RequestContextExtensions.Export(this.deepCopier)
            };

            messagingTrace.OnCreateMessage(message);
            return(message);
        }
示例#6
0
文件: Message.cs 项目: ticup/orleans
        internal static Message CreateRcRequest(InvokeMethodRequest request, bool refresh)
        {
            var message = new Message(
                Categories.Application, Directions.OneWay)
            {
                Id                 = CorrelationId.GetNext(),
                BodyObject         = request,
                IsAlwaysInterleave = true
            };

            message.SetHeader(Header.RC_MSG, refresh ? ReactiveComputationTypes.KeepAlive : ReactiveComputationTypes.Execute);

            var contextData = RequestContext.Export();

            message.RequestContextData = contextData;

            return(message);
        }
示例#7
0
        public Message CreateMessage(InvokeMethodRequest request, InvokeMethodOptions options)
        {
            var direction = (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request;
            var message   = new Message
            {
                Category    = Message.Categories.Application,
                Direction   = direction,
                Id          = CorrelationId.GetNext(),
                IsReadOnly  = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered = (options & InvokeMethodOptions.Unordered) != 0,
                BodyObject  = request
            };

            if ((options & InvokeMethodOptions.AlwaysInterleave) != 0)
            {
                message.IsAlwaysInterleave = true;
            }

            message.RequestContextData = RequestContext.Export();
            return(message);
        }
示例#8
0
        internal static Message CreateMessage(InvokeMethodRequest request, InvokeMethodOptions options)
        {
            var message = new Message(
                Message.Categories.Application,
                (options & InvokeMethodOptions.OneWay) != 0 ? Message.Directions.OneWay : Message.Directions.Request)
            {
                Id          = CorrelationId.GetNext(),
                InterfaceId = request.InterfaceId,
                MethodId    = request.MethodId,
                IsReadOnly  = (options & InvokeMethodOptions.ReadOnly) != 0,
                IsUnordered = (options & InvokeMethodOptions.Unordered) != 0,
                BodyObject  = request
            };

            if ((options & InvokeMethodOptions.AlwaysInterleave) != 0)
            {
                message.IsAlwaysInterleave = true;
            }

            RequestContext.ExportToMessage(message);
            return(message);
        }