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


C# IModel.TxSelect方法代码示例

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


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

示例1: Open

        public override void Open(TimeSpan timeout)
        {
            if (State != CommunicationState.Created && State != CommunicationState.Closed)
                throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", State));

            OnOpening();
            #if VERBOSE
            DebugHelper.Start();
            #endif
            _model = ConnectionManager.Instance.OpenModel(new RabbitMQUri(RemoteAddress.Uri), _bindingElement.BrokerProtocol, timeout);

            if (Transaction.Current != null)
            {
                _model.TxSelect();

                _transactional = true;
            }

            if (_messageProcessor != null)
            {
                _model.BasicReturn += ModelOnBasicReturn;
            }

            #if VERBOSE
            DebugHelper.Stop(" ## Out.Open {{Time={0}ms}}.");
            #endif
            OnOpened();
        }
开发者ID:parshim,项目名称:MessageBus,代码行数:28,代码来源:RabbitMQTransportOutputChannel.cs

示例2: ReceiveInContext

			public IMessage ReceiveInContext (ref string host, ref IConnection cn, 
			                                  ref IModel model, string txId)
			{
				if (host == null)
					host = q.QRef.Host;
				else if (host != q.QRef.Host)
					throw new MonoMessagingException ("Transactions can not span multiple hosts");
				
				if (cn == null) {
					ConnectionFactory cf = new ConnectionFactory ();
					cn = cf.CreateConnection (host);
				}
				
				if (model == null) {
					model = cn.CreateModel ();
					model.TxSelect ();
				}
				
				return doReceive (q, model);
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:20,代码来源:RabbitMQMessageQueue.cs

示例3: SendInContext

		private void SendInContext (ref string host, ref IConnection cn, 
		                            ref IModel model, IMessage msg, string txId)
		{
			if (host == null)
				host = QRef.Host;
			else if (host != QRef.Host)
				throw new MonoMessagingException ("Transactions can not span multiple hosts");
			
			if (cn == null) {
				ConnectionFactory cf = new ConnectionFactory ();
				cn = cf.CreateConnection (host);
			}
			
			if (model == null) {
				model = cn.CreateModel ();
				model.TxSelect ();
			}
			
			SetDeliveryInfo (msg, GetVersion (cn), txId);
			Send (model, msg);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:21,代码来源:RabbitMQMessageQueue.cs

示例4: DeclareTransactional

 /// <summary>
 /// Declare to that broker that a channel is going to be used transactionally, and convert exceptions that arise.
 /// </summary>
 /// <param name="channel">
 /// The channel to use.
 /// </param>
 /// <exception cref="SystemException">
 /// </exception>
 public static void DeclareTransactional(IModel channel)
 {
     try
     {
         channel.TxSelect();
     }
     catch (Exception e)
     {
         throw RabbitUtils.ConvertRabbitAccessException(e);
     }
 }
开发者ID:DonMcRae,项目名称:spring-net-amqp,代码行数:19,代码来源:RabbitUtils.cs

示例5: PublishTransactionalMessages

        private TimeSpan PublishTransactionalMessages(IModel transactionalChannel, string hostname, string exchange, string path, bool requeue)
        {
            TimeSpan result = TimeSpan.MaxValue;
            MessageFormatter messageFormatter = new MessageFormatter();
            string[] files = Directory.GetFiles(path, "*.msg");
            int skipCount = 0;
            while (files.Length > skipCount)
            {
                skipCount = 0;
                foreach (string item in files)
                {
                    if (File.Exists(item))
                    {
                        byte[] data = null;
                        try
                        {
                            data = File.ReadAllBytes(item);
                        }
                        catch
                        {

                        }
                        if (data != null)
                        {
                            if (requeue)
                            {
                                ServiceEventMessage message = messageFormatter.Deserialise(new MemoryStream(data));
                                if ((message != null) && (message.QueueAfterTime.HasValue) && (message.QueueAfterTime.Value > DateTime.UtcNow))
                                {
                                    TimeSpan delay = message.QueueAfterTime.Value.Subtract(DateTime.UtcNow);
                                    if (delay < result)
                                        result = delay;
                                    skipCount++;
                                    continue;
                                }
                            }
                            string messageFilename = Path.ChangeExtension(item, ".trx");
                            if (File.Exists(messageFilename))
                                DeleteMessageFile(messageFilename);
                            File.Move(item, messageFilename);
                            IBasicProperties properties = transactionalChannel.CreateBasicProperties();
                            properties.CorrelationId = hostname;
                            properties.DeliveryMode = 2;
                            properties.ContentType = messageFormatter.ContentType;
                            string filename = Path.GetFileNameWithoutExtension(item);
                            string routingKey = string.Empty;
                            int index = filename.IndexOf('_');
                            if (index != -1)
                            {
                                routingKey = filename.Substring(0, index);
                                int nextIndex = filename.IndexOf('_', index + 1);
                                if (nextIndex == -1)
                                    properties.MessageId = filename.Substring(index + 1);
                                else
                                    properties.MessageId = filename.Substring(index + 1, nextIndex - index - 1);
                            }
                            transactionalChannel.TxSelect();
                            transactionalChannel.BasicPublish(exchange, routingKey, properties, data);
                            transactionalChannel.TxCommit();
                            DeleteMessageFile(messageFilename);
                        }
                    }
                }
                files = Directory.GetFiles(path, "*.msg");
            }
            return result;
        }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:67,代码来源:DALRabbitMQ.cs

示例6: EnsureThreadBoundModelIsInitialized

        void EnsureThreadBoundModelIsInitialized(ITransactionContext context)
        {
            if (threadBoundModel != null && threadBoundModel.IsOpen)
            {
                if (context[CurrentModelKey] == null)
                {
                    context[CurrentModelKey] = threadBoundModel;
                    context.DoCommit += () => threadBoundModel.TxCommit();
                    context.DoRollback += () => threadBoundModel.TxRollback();
                }
                return;
            }

            threadBoundModel = GetConnection().CreateModel();
            threadBoundModel.TxSelect();

            context.DoCommit += () => threadBoundModel.TxCommit();
            context.DoRollback += () => threadBoundModel.TxRollback();

            // ensure any sends withing this transaction will use the thread bound model
            context[CurrentModelKey] = threadBoundModel;
        }
开发者ID:rasmuskl,项目名称:Rebus,代码行数:22,代码来源:RabbitMqMessageQueue.cs


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