示例#1
0
        private void HandleSubmit(HttpListenerContext ctx, CallInfo callInfo)
        {
            Logger.Debug("Received message submission for id: " + callInfo.ClientId);
            string hash = ctx.Request.Headers[HttpHeaders.ContentMd5Key];

            byte[] buffer = GetBuffer(ctx);
            string myHash = Hasher.Hash(buffer);

            if (myHash != hash)
            {
                CloseResponseAndWarn(ctx, "MD5 hash received does not match hash calculated on server. Consider resubmitting.", 412);
                return;
            }

            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30) }))
            {
                persister.InsertMessage(DateTime.UtcNow, callInfo.ClientId, Convert.FromBase64String(callInfo.MD5), buffer, ctx.Request.Headers);

                scope.Complete();
            }

            ReportSuccess(ctx);
        }
示例#2
0
        void HandleDatabusProperty(HttpListenerContext ctx, CallInfo callInfo)
        {
            Logger.Debug("Received databus property, id: " + callInfo.ClientId);

            if(DataBus == null)
                throw new InvalidOperationException("Databus transmission received without a databus configured");
        }
示例#3
0
        private void HandleAck(HttpListenerContext ctx, CallInfo callInfo)
        {
            Logger.Debug("Received message ack for id: " + callInfo.ClientId);

            var msg = new TransportMessage { ReturnAddress = ReturnAddress };

            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30)}))
            {
                byte[] outMessage;
                NameValueCollection outHeaders;

                persister.AckMessage(callInfo.ClientId, Convert.FromBase64String(callInfo.MD5), out outMessage, out outHeaders);

                if (outHeaders != null && outMessage != null)
                {
                    msg.Body = outMessage;

                    HeaderMapper.Map(outHeaders, msg);
                    if (msg.TimeToBeReceived < TimeSpan.FromSeconds(1))
                        msg.TimeToBeReceived = TimeSpan.FromSeconds(1);

                    msg.Recoverable = true;

                    if (String.IsNullOrEmpty(msg.IdForCorrelation))
                        msg.IdForCorrelation = msg.Id;

                    if (msg.MessageIntent == MessageIntentEnum.Init) // wasn't set by client
                        msg.MessageIntent = MessageIntentEnum.Send;

                    //todo the from key isn't used for anything, remove?
                    if (ctx.Request.Headers[HttpHeaders.FromKey] != null)
                        msg.Headers.Add(Headers.HttpFrom, ctx.Request.Headers[HttpHeaders.FromKey]);

                    MessageReceived(this, new MessageForwardingArgs { Message = msg });
                }

                scope.Complete();
            }

            ReportSuccess(ctx);
        }
示例#4
0
        void HandleSubmit(CallInfo callInfo)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30) }))
            {
                persister.InsertMessage(callInfo.ClientId,DateTime.UtcNow, callInfo.Buffer, callInfo.Headers);

                scope.Complete();
            }
        }
示例#5
0
        void HandleDatabusProperty(CallInfo callInfo)
        {
            if(DataBus == null)
                throw new InvalidOperationException("Databus transmission received without a databus configured");

            //todo
            TimeSpan timeToBeReceived = TimeSpan.FromDays(1);

            string newDatabusKey;

            using(var stream = new MemoryStream(callInfo.Buffer))
                newDatabusKey = DataBus.Put(stream,timeToBeReceived);

            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30) }))
            {
                persister.UpdateHeader(callInfo.ClientId, callInfo.Headers[GatewayHeaders.DatabusKey], newDatabusKey);

                scope.Complete();
            }
        }
示例#6
0
        void HandleAck(CallInfo callInfo)
        {
            var msg = new TransportMessage();
            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30)}))
            {
                byte[] outMessage;
                NameValueCollection outHeaders;

                persister.AckMessage(callInfo.ClientId, out outMessage, out outHeaders);

                if (outHeaders != null && outMessage != null)
                {
                    msg.Body = outMessage;

                    HeaderMapper.Map(outHeaders, msg);
                    if (msg.TimeToBeReceived < TimeSpan.FromSeconds(1))
                        msg.TimeToBeReceived = TimeSpan.FromSeconds(1);

                    msg.Recoverable = true;

                    if (String.IsNullOrEmpty(msg.IdForCorrelation))
                        msg.IdForCorrelation = msg.Id;

                    if (msg.MessageIntent == MessageIntentEnum.Init) // wasn't set by client
                        msg.MessageIntent = MessageIntentEnum.Send;

                    //todo this header is used by the httpheadermanager and need to be abstracted to support other channels
                    if (callInfo.Headers[HttpHeaders.FromKey] != null)
                        msg.Headers.Add(Headers.HttpFrom, callInfo.Headers[HttpHeaders.FromKey]);

                    MessageReceived(this, new MessageReceivedOnChannelArgs { Message = msg });
                }

                scope.Complete();
            }
        }