コード例 #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) }))
            {
                var p = new Persistence { ConnectionString = connString };

                p.InsertMessage(DateTime.UtcNow, callInfo.ClientId, Convert.FromBase64String(callInfo.MD5), buffer, ctx.Request.Headers);

                scope.Complete();
            }

            ReportSuccess(ctx);
        }
コード例 #2
0
ファイル: HttpChannel.cs プロジェクト: bishoprook/NServiceBus
        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 = inputQueue };

            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30)}))
            {
                var p = new Persistence { ConnectionString = connString };

                byte[] outMessage;
                NameValueCollection outHeaders;

                p.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;

                    if (ctx.Request.Headers[HttpHeaders.FromKey] != null)
                        msg.Headers.Add(Headers.HttpFrom, ctx.Request.Headers[HttpHeaders.FromKey]);

                    string routeTo = Headers.RouteTo.Replace(HeaderMapper.NServiceBus + Headers.HeaderName + ".", "");
                    string destination;
                    if (msg.Headers.ContainsKey(routeTo))
                        destination = msg.Headers[routeTo];
                    else
                        destination = destinationQueue;

                    Logger.Info("Sending message to " + destination);

                    messageSender.Send(msg, destination);

                }

                scope.Complete();
            }

            ReportSuccess(ctx);
        }
コード例 #4
0
ファイル: HttpChannel.cs プロジェクト: bishoprook/NServiceBus
        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;

                    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);
        }