当前位置: 首页>>代码示例>>C#>>正文


C# ITransport.Start方法代码示例

本文整理汇总了C#中ITransport.Start方法的典型用法代码示例。如果您正苦于以下问题:C# ITransport.Start方法的具体用法?C# ITransport.Start怎么用?C# ITransport.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITransport的用法示例。


在下文中一共展示了ITransport.Start方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public void Run()
        {
            // Create an in-memory TransactionalTransport and point it to the AuditQ
            // Serialize data into the database.

            string auditQueue = ConfigurationManager.AppSettings["AuditQueue"];
            string machineName = Environment.MachineName;

            // Make sure that the queue being monitored, exists!
            if (!MessageQueue.Exists(MsmqUtilities.GetFullPathWithoutPrefix(auditQueue)))
            {
                // The error queue being monitored must be local to this endpoint
                throw new Exception(string.Format("The audit queue {0} being monitored must be local to this endpoint and must exist. Make sure a transactional queue by the specified name exists. The audit queue to be monitored is specified in the app.config", auditQueue));
            }

            // Create an in-memory transport with the same configuration as that of the current endpoint.
            AuditMessageQueueTransport = new TransactionalTransport()
            {
                IsTransactional = CurrentEndpointTransport.IsTransactional,
                MaxRetries = CurrentEndpointTransport.MaxRetries,
                IsolationLevel = CurrentEndpointTransport.IsolationLevel,
                MessageReceiver = new MsmqMessageReceiver(),
                NumberOfWorkerThreads = CurrentEndpointTransport.NumberOfWorkerThreads,
                TransactionTimeout = CurrentEndpointTransport.TransactionTimeout,
                FailureManager = CurrentEndpointTransport.FailureManager
            };

            AuditMessageQueueTransport.Start(new Address(auditQueue, machineName));
            AuditMessageQueueTransport.TransportMessageReceived += new EventHandler<TransportMessageReceivedEventArgs>(AuditMessageQueueTransport_TransportMessageReceived);
        }
开发者ID:cfbarbero,项目名称:Management,代码行数:30,代码来源:Boostrapper.cs

示例2: Run

        public void Run()
        {
            if (!Configure.Instance.DistributorConfiguredToRunOnThisEndpoint())
                return;

            controlTransport = new TransactionalTransport
            {
                IsTransactional = true,
                FailureManager = MessageFailureManager,
                MessageReceiver = new MsmqMessageReceiver(),
                MaxRetries = 5,
                NumberOfWorkerThreads = NumberOfWorkerThreads,
            };

            controlTransport.TransportMessageReceived +=
                (obj, ev) =>
                {
                    var transportMessage = ev.Message;

                    if (!transportMessage.IsControlMessage())
                        return;

                    HandleControlMessage(transportMessage);
                };

            controlTransport.Start(ControlQueue);
        }
开发者ID:robertwilczynski,项目名称:NServiceBus,代码行数:27,代码来源:DistributorReadyMessageProcessor.cs

示例3: Run

        public void Run()
        {
            if (!RoutingConfig.IsConfiguredAsMasterNode)
                return;

            controlTransport = new TransactionalTransport
            {
                IsTransactional = true,
                FailureManager = MessageFailureManager,
                MessageReceiver = new MsmqMessageReceiver(),
                MaxRetries = 1,
                NumberOfWorkerThreads = NumberOfWorkerThreads,
            };

            controlTransport.TransportMessageReceived +=
                (obj, ev) =>
                {
                    var transportMessage = ev.Message;

                    if (!transportMessage.Headers.ContainsKey(Headers.ControlMessage))
                        return;

                    HandleControlMessage(transportMessage);
                };

            var bus = Configure.Instance.Builder.Build<IStartableBus>();
            bus.Started += (obj, ev) => controlTransport.Start(ControlQueue);
        }
开发者ID:eskianis,项目名称:NServiceBus,代码行数:28,代码来源:DistributorReadyMessageProcessor.cs

示例4: Run

        public void Run()
        {
            if (!DistributorEnabled)
                return;

            controlTransport = new TransactionalTransport
            {
                IsTransactional = true,
                FailureManager = MessageFailureManager,
                MessageReceiver = new MsmqMessageReceiver(),
                MaxRetries = 1,
                NumberOfWorkerThreads = NumberOfWorkerThreads,
            };

            controlTransport.TransportMessageReceived +=
                (obj, ev) =>
                {
                    var messages = Configure.Instance.Builder.Build<IMessageSerializer>()
                        .Deserialize(new MemoryStream(ev.Message.Body));
                    foreach (var msg in messages)
                        if (msg is ReadyMessage)
                            Handle(msg as ReadyMessage, ev.Message.ReplyToAddress);
                };

            var bus = Configure.Instance.Builder.Build<IStartableBus>();
            bus.Started += (obj, ev) => controlTransport.Start(ControlQueue);
        }
开发者ID:zidad,项目名称:NServiceBus,代码行数:27,代码来源:DistributorReadyMessageProcessor.cs

示例5: Start

        public void Start()
        {
            var templateTransport = Configure.Instance.Builder.Build<TransactionalTransport>();

            transport = new TransactionalTransport
                            {
                                //todo grab the receiver from the main bus and clone
                                MessageReceiver = new MsmqMessageReceiver(),
                                IsTransactional = true,
                                NumberOfWorkerThreads = templateTransport.NumberOfWorkerThreads == 0 ? 1 : templateTransport.NumberOfWorkerThreads,
                                MaxRetries = templateTransport.MaxRetries,
                                FailureManager = templateTransport.FailureManager
                            };

            transport.TransportMessageReceived += (s, e) =>
            {
                var address = GetRemoteAddress(RemoteAddress, e.Message);

                channelSender.Send(e.Message, address);

                notifier.RaiseMessageForwarded(ChannelType.Msmq, ChannelType.Http, e.Message);

                //todo get audit settings from the audit settings of the host (possibly allowing to override in config)
                //if (!string.IsNullOrEmpty(audit))
                // messageSender.Send(e.Message, audit);
            };
            transport.Start(InputQueue);
        }
开发者ID:artikh,项目名称:NServiceBus,代码行数:28,代码来源:MsmqChannelDispatcher.cs

示例6: Run

        public void Run()
        {
            if (auditQueueAddress == null)
                return;

            inputTransport = TransportFactory.GetTransport(OnTransportMessageReceived);
            inputTransport.Start(auditQueueAddress);
        }
开发者ID:northshoreab,项目名称:Hygia,代码行数:8,代码来源:Uploader.cs

示例7: Run

        public void Run()
        {
            if (!ConfigureTimeoutManager.TimeoutManagerEnabled)
                return;

            var messageReceiver = MessageReceiverFactory != null ? MessageReceiverFactory() : new MsmqMessageReceiver();

            inputTransport = new TransactionalTransport
            {
                MessageReceiver = messageReceiver,
                IsTransactional = true,
                NumberOfWorkerThreads = MainTransport.NumberOfWorkerThreads == 0 ? 1 : MainTransport.NumberOfWorkerThreads,
                MaxRetries = MainTransport.MaxRetries,
                FailureManager = Builder.Build(MainTransport.FailureManager.GetType())as IManageMessageFailures
            };

            inputTransport.TransportMessageReceived += OnTransportMessageReceived;

            inputTransport.Start(ConfigureTimeoutManager.TimeoutManagerAddress);
        }
开发者ID:johnsimons,项目名称:NServiceBus,代码行数:20,代码来源:TimeoutMessageProcessor.cs

示例8: Start

        public void Start(Address inputAddress)
        {
            localAddress = inputAddress;
            addressOfAuditStore = settings.AddressOfAuditStore;

            transport = new TransactionalTransport
                            {
                                MessageReceiver = settings.Receiver,
                                IsTransactional = true,
                                NumberOfWorkerThreads = settings.NumberOfWorkerThreads,
                                MaxRetries = settings.MaxRetries,
                                FailureManager = settings.FailureManager
                            };

            transport.TransportMessageReceived += OnTransportMessageReceived;

            transport.Start(localAddress);

            Logger.InfoFormat("Gateway started listening on inputs on - {0}", localAddress);
        }
开发者ID:nghead,项目名称:NServiceBus,代码行数:20,代码来源:GatewaySender.cs

示例9: Start

        public void Start(string inputAddress)
        {
            localAddress = inputAddress;

            var templateTransport = Configure.Instance.Builder.Build<TransactionalTransport>();

            transport = new TransactionalTransport
                            {
                                //todo grab the receiver from the main bus and clone
                                MessageReceiver = new MsmqMessageReceiver(),
                                IsTransactional = true,
                                NumberOfWorkerThreads = templateTransport.NumberOfWorkerThreads == 0 ? 1 : templateTransport.NumberOfWorkerThreads,
                                MaxRetries = templateTransport.MaxRetries,
                                FailureManager = templateTransport.FailureManager
                            };

            transport.TransportMessageReceived += OnTransportMessageReceived;

            transport.Start(inputAddress);
        }
开发者ID:ravikp,项目名称:NServiceBus,代码行数:20,代码来源:TransactionalChannelDispatcher.cs

示例10: RestoreTransport

        protected void RestoreTransport(ITransport t)
        {
            Tracer.Info("Restoring previous transport connection.");
            t.Start();

            // Send information to the broker - informing it we are a fault tolerant client
            t.Oneway(new ConnectionControl() { FaultTolerant = true });
            stateTracker.DoRestore(t);

            Tracer.Info("Sending queued commands...");
            Dictionary<int, Command> tmpMap = null;
            lock(((ICollection) requestMap).SyncRoot)
            {
                tmpMap = new Dictionary<int, Command>(requestMap);
            }

            foreach(Command command in tmpMap.Values)
            {
                if(command.IsMessageAck)
                {
                    Tracer.Debug("Stored MessageAck being dropped as stale.");
                    OnCommand(this, new Response() { CorrelationId = command.CommandId });
                    continue;
                }

                t.Oneway(command);
            }
        }
开发者ID:Redi0,项目名称:meijing-ui,代码行数:28,代码来源:FailoverTransport.cs

示例11: Start

        public void Start()
        {
            var templateTransport = Configure.Instance.Builder.Build<TransactionalTransport>();

            transport = new TransactionalTransport
                            {
                                //todo grab the receiver from the main bus and clone
                                MessageReceiver = new MsmqMessageReceiver(),
                                IsTransactional = true,
                                NumberOfWorkerThreads = templateTransport.NumberOfWorkerThreads == 0 ? 1 : templateTransport.NumberOfWorkerThreads,
                                MaxRetries = templateTransport.MaxRetries,
                                FailureManager = templateTransport.FailureManager
                            };

            transport.TransportMessageReceived += (s, e) =>
            {
                var transportMessage = e.Message;

                var address = GetRemoteAddress(RemoteAddress, transportMessage);

                //todo - why are we doing this?
                if (!String.IsNullOrEmpty(transportMessage.IdForCorrelation))
                    transportMessage.IdForCorrelation = transportMessage.Id;

                var headers = new NameValueCollection();

                HeaderMapper.Map(transportMessage, headers);

                channelSender.Send(address,headers,transportMessage.Body);

                notifier.RaiseMessageForwarded(ChannelType.Msmq, channelSender.Type, transportMessage);

                //todo get audit settings from the audit settings of the host (possibly allowing to override in config)
                //if (!string.IsNullOrEmpty(audit))
                // messageSender.Send(e.Message, audit);
            };

            transport.Start(InputQueue);
        }
开发者ID:kblooie,项目名称:NServiceBus,代码行数:39,代码来源:MsmqChannelDispatcher.cs

示例12: Run

        public void Run()
        {
            if (!Configure.Instance.IsTimeoutManagerEnabled())
            {
                return;
            }

            timeoutPersisterReceiver = new TimeoutPersisterReceiver(Builder.Build<IManageTimeouts>());
            timeoutPersisterReceiver.MessageSender = MessageSender;
            timeoutPersisterReceiver.TimeoutsPersister = TimeoutsPersister;
            timeoutPersisterReceiver.Start();

            inputTransport = new TransactionalTransport
                {
                    MessageReceiver =
                        TimeoutMessageProcessor.MessageReceiverFactory != null
                            ? TimeoutMessageProcessor.MessageReceiverFactory()
                            : new MsmqMessageReceiver(),
                    IsTransactional = true,
                    NumberOfWorkerThreads =
                        MainTransport.NumberOfWorkerThreads == 0 ? 1 : MainTransport.NumberOfWorkerThreads,
                    MaxRetries = MainTransport.MaxRetries,
                    FailureManager = new ManageMessageFailuresWithoutSlr(MainTransport.FailureManager),
                };

            inputTransport.TransportMessageReceived += OnTransportMessageReceived;

            inputTransport.Start(TimeoutDispatcherAddress);
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:29,代码来源:TimeoutDispatcherProcessor.cs

示例13: Run

        public void Run()
        {
            // Create an in memory transport which will listen for messages on the error queue.
            // When a message is received in the error queue, the TransportMessageReceived event handler
            // will handle the message. The contents of the message from the error queue will be inspected
            // and a ProcessErrorMessage will be sent using the Bus.
            string errorQueue = ConfigurationManager.AppSettings["ErrorQueueToMonitor"];
            string machineName = Environment.MachineName;

            // Make sure that the queue being monitored, exists!
            if (!MessageQueue.Exists(MsmqUtilities.GetFullPathWithoutPrefix(errorQueue)))
            {
                // The error queue being monitored must be local to this endpoint
                throw new Exception(string.Format("The error queue {0} being monitored must be local to this endpoint and must exist. Make sure a transactional queue by the specified name exists. The error queue to be monitored is specified in the app.config", errorQueue));
            }

            errorStorageQueueAddress = new Address(string.Format("{0}.Storage", errorQueue), machineName);

            ErrorMessageTransport = new TransactionalTransport()
            {
                IsTransactional = ErrorMonitorTransport.IsTransactional,
                MaxRetries = ErrorMonitorTransport.MaxRetries,
                IsolationLevel = ErrorMonitorTransport.IsolationLevel,
                MessageReceiver = new MsmqMessageReceiver(),
                NumberOfWorkerThreads = ErrorMonitorTransport.NumberOfWorkerThreads,
                TransactionTimeout = ErrorMonitorTransport.TransactionTimeout,
                FailureManager = ErrorMonitorTransport.FailureManager
            };

            ErrorMessageTransport.Start(new Address(errorQueue, machineName));
            ErrorMessageTransport.TransportMessageReceived +=new EventHandler<TransportMessageReceivedEventArgs>(ErrorMessageTransport_TransportMessageReceived);
        }
开发者ID:cfbarbero,项目名称:Management,代码行数:32,代码来源:Bootstrapper.cs

示例14: Run

        public void Run()
        {
            if (!Configure.Instance.IsTimeoutManagerEnabled())
            {
                return;
            }

            var messageReceiver = MessageReceiverFactory != null ? MessageReceiverFactory() : new MsmqMessageReceiver();

            inputTransport = new TransactionalTransport
            {
                MessageReceiver = messageReceiver,
                IsTransactional = true,
                NumberOfWorkerThreads = MainTransport.NumberOfWorkerThreads == 0 ? 1 : MainTransport.NumberOfWorkerThreads,
                MaxRetries = MainTransport.MaxRetries,
                FailureManager = new ManageMessageFailuresWithoutSlr(MainTransport.FailureManager),
            };

            inputTransport.TransportMessageReceived += OnTransportMessageReceived;

            inputTransport.Start(ConfigureTimeoutManager.TimeoutManagerAddress);
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:22,代码来源:TimeoutMessageProcessor.cs


注:本文中的ITransport.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。