• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# QueueDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中QueueDescription的典型用法代码示例。如果您正苦于以下问题:C# QueueDescription类的具体用法?C# QueueDescription怎么用?C# QueueDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueueDescription类属于命名空间,在下文中一共展示了QueueDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            MefLoader.Initialize();
            // Create the queue if it does not exist already
            string connectionString = CloudConfigurationManager.GetSetting("ServiceBus");
            string queueName = ConfigurationsSelector.GetSetting("Customer.Queue");
            NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            QueueDescription queueDescription = new QueueDescription(queueName)
            {
                MaxSizeInMegabytes = 1024,
                DefaultMessageTimeToLive = TimeSpan.FromMinutes(10),
                EnablePartitioning = false, //I want to ensure the messages will processed in the right order
                EnableDeadLetteringOnMessageExpiration = true,
                LockDuration = TimeSpan.FromMinutes(5)
            };

            if (!namespaceManager.QueueExists(queueName))
                namespaceManager.CreateQueue(queueDescription);

            // Initialize the connection to Service Bus Queue
            _client = QueueClient.CreateFromConnectionString(connectionString, queueName);
            return base.OnStart();
        }
开发者ID:jsucupira,项目名称:table-storage-geo-redundancy-demo,代码行数:26,代码来源:WorkerRole.cs


示例2: Create

		public QueueClient Create(Address address)
		{
			var queueName = address.Queue;
			try
			{
				if (!NamespaceClient.QueueExists(queueName))
				{
					var description = new QueueDescription(queueName)
						{
							LockDuration = LockDuration,
							MaxSizeInMegabytes = MaxSizeInMegabytes,
							RequiresDuplicateDetection = RequiresDuplicateDetection,
							RequiresSession = RequiresSession,
							DefaultMessageTimeToLive = DefaultMessageTimeToLive,
							EnableDeadLetteringOnMessageExpiration = EnableDeadLetteringOnMessageExpiration,
							DuplicateDetectionHistoryTimeWindow = DuplicateDetectionHistoryTimeWindow,
							MaxDeliveryCount = MaxDeliveryCount,
							EnableBatchedOperations = EnableBatchedOperations
						};

					NamespaceClient.CreateQueue(description);
				}
			}
			catch (MessagingEntityAlreadyExistsException)
			{
				// the queue already exists or another node beat us to it, which is ok
			}

			var client = Factory.CreateQueueClient(queueName, ReceiveMode.PeekLock);
			client.PrefetchCount = 100; // todo make configurable
			return client;
		}
开发者ID:modulexcite,项目名称:NServiceBus.WindowsServiceBus,代码行数:32,代码来源:WindowsServicebusQueueClientCreator.cs


示例3: QueueShouldExistAsync

 private async static Task QueueShouldExistAsync(NamespaceManager ns, QueueDescription queueDescription)
 {
     if (!await ns.QueueExistsAsync(queueDescription.Path))
     {
         throw new MessagingEntityNotFoundException("Queue: " + queueDescription.Path);
     }
 }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:7,代码来源:MessagingFactoryQueueExtensions.cs


示例4: Newsletter

        public ActionResult Newsletter(string email)
        {
            var nm = NamespaceManager.CreateFromConnectionString(ConnectionString);

            QueueDescription qd = new QueueDescription(qname);
            qd.MaxSizeInMegabytes = 2048;
            qd.DefaultMessageTimeToLive = new TimeSpan(0, 5, 0);

            if (!nm.QueueExists(qname))
            {
                nm.CreateQueue(qd);
            }

            //Send to the queue
            QueueClient qc = QueueClient.CreateFromConnectionString(ConnectionString, qname);

            // Create amessage with email property
            var bm = new BrokeredMessage();
            bm.Properties["email"] = email;
            qc.Send(bm);

            ViewBag.email = email;

            return View();
        }
开发者ID:djangojazz,项目名称:AzureTesting,代码行数:25,代码来源:HomeController.cs


示例5: QueueMessage

        private static void QueueMessage(string messageType, VirtualMachine virtualMachine)
        {
            if (VirtualMachine.IsValid(virtualMachine) == false)
            {
                throw new ArgumentException("Invalid virtual machine.", "virtualMachine");
            }

            var connectionString = CloudConfigurationManager.GetSetting("ServiceBus.ConnectionString");
            var queueName = CloudConfigurationManager.GetSetting("QueueName");

            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.QueueExists(queueName))
            {
                var queue = new QueueDescription(queueName)
                {
                    DefaultMessageTimeToLive = new TimeSpan(7, 0, 0, 0)
                };

                namespaceManager.CreateQueue(queue);
            }

            var message = PrepareMessage(messageType, virtualMachine);

            var client = QueueClient.CreateFromConnectionString(connectionString, queueName);

            client.Send(message);
        }
开发者ID:jamesology,项目名称:AzureVmFarmer,代码行数:28,代码来源:Messenger.cs


示例6: LoadConfig

        public void LoadConfig()
        {
            Trace.TraceInformation("Initializing and configuring Azure service bus queue");

            string connectionString =
                CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");

            var namespaceManager =
                NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.QueueExists(QueueName))
            {
                namespaceManager.CreateQueue(QueueName);
            }

            // Configure Queue Settings
            QueueDescription qd = new QueueDescription(QueueName)
            {
                MaxSizeInMegabytes = 5120,
                DefaultMessageTimeToLive = new TimeSpan(0, 1, 0)
            };

            WorkHistoryDataTable = new DataSetMobile.WorkHistoryDataTable();

            WorkHistoryTableAdapter = new WorkHistoryTableAdapter();

            Trace.TraceInformation("Creating queue client from service bus connection string");
            MobleQueueClient =
                QueueClient.CreateFromConnectionString(connectionString, QueueName);
        }
开发者ID:richstep,项目名称:ExportAzureTableStorageToSqlServer,代码行数:30,代码来源:MobileProcessingConfig.cs


示例7: Main

        static void Main(string[] args)
        {
            NamespaceManager manager = NamespaceManager.Create(); // Automatycznie bierze informacje z App.config
            //Wolę na początku - wygodniej "zaczynamy" zawsze od zera
            manager.DeleteTopic("obliczenia"); //Kasuje temat i subskrypcje
            manager.DeleteQueue("wynik");

            //Tworzenie Topics - tematu
            TopicDescription td = new TopicDescription("obliczenia");

            //Nie przewidujemy dużego ruchu nie wymagamy partycjonowania
            td.EnablePartitioning = false;
            //Wymagamy wykrywania duplikatów - by klient 2 razy nie wysłał tego samego polecenia
            td.RequiresDuplicateDetection = true;
            //Nie pozwalamy na tematy tylko w pamięci; chcemy żeby klient był pewien że wysłał wiadomość = wiadomość zostanie przetworzona
            td.EnableExpress = false;
            manager.CreateTopic(td); //Tworzenie tematu

            //Suma i średnia będzie wyliczana gdy opowiednia własciwość zostanie zdefiniowana
            manager.CreateSubscription("obliczenia", "suma", new SqlFilter("suma=1"));
            manager.CreateSubscription("obliczenia", "srednia", new SqlFilter("srednia=1"));
            //Ale zawsze będą liczone elementy w komunikacie
            manager.CreateSubscription("obliczenia", "liczba");

            QueueDescription qd = new QueueDescription("wynik");
            qd.RequiresSession = true;
            manager.CreateQueue(qd);
        }
开发者ID:tkopacz,项目名称:MVAFY15-Topic-Queue-ServiceBus,代码行数:28,代码来源:Program.cs


示例8: GetQueuePath

        public string GetQueuePath(QueueDescription queueDescription)
        {
            IEnumerable<string> segments = new[] {_settings.ServiceUri.AbsolutePath.Trim('/'), queueDescription.Path.Trim('/')}
                .Where(x => x.Length > 0);

            return string.Join("/", segments);
        }
开发者ID:phatboyg,项目名称:MassTransit,代码行数:7,代码来源:ServiceBusHost.cs


示例9: Consumer

        public Consumer()
        {
            Console.Write("Your Service Namespace: ");
            string serviceNamespace = Console.ReadLine();
            Console.Write("Your Issuer Name: ");
            string issuerName = Console.ReadLine();
            Console.Write("Your Issuer Secret: ");
            string issuerSecret = Console.ReadLine();

            // Configure queue settings.
            this.queueDescription = new QueueDescription(MyQueuePath);
            // Setting Max Size and TTL for demonstration purpose
            // but can be changed per user discretion to suite their system needs.
            // Refer service bus documentation to understand the limitations.
            // Setting Queue max size to 1GB where as default Max Size is 5GB.
            this.queueDescription.MaxSizeInMegabytes = 1024;
            // Setting message TTL to 5 days where as default TTL is 14 days.
            this.queueDescription.DefaultMessageTimeToLive = TimeSpan.FromDays(5);
            
            // Create management credentials.
            this.credential = new TransportClientEndpointBehavior() 
            {
                TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret)
            };
 
            // Create the URI for the queue.
            this.namespaceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, String.Empty);
            Console.WriteLine("Service Bus Namespace Uri address '{0}'", this.namespaceUri.AbsoluteUri);
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:29,代码来源:PersistentQueueListener.cs


示例10: GetQueryStringOptions

        static IEnumerable<string> GetQueryStringOptions(QueueDescription settings)
        {
            if (settings.EnableExpress)
                yield return "express=true";

            if (settings.AutoDeleteOnIdle > TimeSpan.Zero)
                yield return $"autodelete={settings.AutoDeleteOnIdle.TotalSeconds}";
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:8,代码来源:ServiceBusHostSettingsExtensions.cs


示例11: Connect

        public void Connect(string connectionString, string queueName, QueueDescription queueDescription = null)
        {
            this.VerifyQueue(connectionString, queueName, queueDescription);

            this.serviceBus.Connect(connectionString, queueName);

            this.AddServiceBusSubscription();
        }
开发者ID:sliced-bread,项目名称:Slicedbread.AzureServiceBus.Client,代码行数:8,代码来源:ServiceBusListener.cs


示例12: Equals

 public bool Equals(QueueDescription other)
 {
     if (ReferenceEquals(null, other))
         return false;
     if (ReferenceEquals(this, other))
         return true;
     return Equals(other.Path, Path);
 }
开发者ID:jglozano,项目名称:MassTransit-AzureServiceBus,代码行数:8,代码来源:QueueDescriptionImpl.cs


示例13: GetInputAddress

        public static Uri GetInputAddress(this ServiceBusHostSettings hostSettings, QueueDescription queueDescription)
        {
            var builder = new UriBuilder(hostSettings.ServiceUri);

            builder.Path += queueDescription.Path;
            builder.Query += string.Join("&", GetQueryStringOptions(queueDescription));

            return builder.Uri;
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:9,代码来源:ServiceBusHostSettingsExtensions.cs


示例14: CreateQueue_WhenUserDoesNotHaveManagePermission_UnauthorizedAccessExceptionIsThrown

        public void CreateQueue_WhenUserDoesNotHaveManagePermission_UnauthorizedAccessExceptionIsThrown()
        {
            string queueName = Guid.NewGuid().ToString();
            var queue = new QueueDescription(queueName);

            NamespaceManager nsManager = GetNamespaceManagerWithCustomCredentials(TestUsers.User1);

            Assert.Throws<UnauthorizedAccessException>(() => nsManager.CreateQueue(queue));
        }
开发者ID:nordvall,项目名称:letterbox,代码行数:9,代码来源:NamespaceManagerTests.cs


示例15: EnsureQueueAsync

        public async static Task<QueueClient> EnsureQueueAsync(this MessagingFactory factory, QueueDescription queueDescription, ReceiveMode mode = ReceiveMode.PeekLock)
        {
            await new NamespaceManager(factory.Address, factory.GetSettings().TokenProvider)
                .TryCreateEntity(
                    mgr => QueueCreateAsync(mgr, queueDescription),
                    mgr => QueueShouldExistAsync(mgr, queueDescription));

            return factory.CreateQueueClient(queueDescription.Path, mode);
        }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:9,代码来源:MessagingFactoryQueueExtensions.cs


示例16: CreateAndDeleteQueue_WhenUserHasManagePermission_Success

        public void CreateAndDeleteQueue_WhenUserHasManagePermission_Success()
        {
            string queueName = Guid.NewGuid().ToString();
            var queue = new QueueDescription(queueName);

            NamespaceManager nsManager = ServiceBusHelper.GetNamespaceManager();
            nsManager.CreateQueue(queue);
            nsManager.DeleteQueue(queueName);
        }
开发者ID:nordvall,项目名称:letterbox,代码行数:9,代码来源:NamespaceManagerTests.cs


示例17: CreateQueue

 static void CreateQueue(Uri baseAddress,string queueName,QueueDescription queueDescription,TokenProvider credentials)
 { 
    if(QueueExists(baseAddress,queueName,credentials))
    {
       DeleteQueue(baseAddress,queueName,credentials);
    }  
    NamespaceManager namespaceClient = new NamespaceManager(baseAddress,credentials);
    namespaceClient.CreateQueue(queueDescription);
 }
开发者ID:ittray,项目名称:LocalDemo,代码行数:9,代码来源:ServiceBusHelper+-+Queues.cs


示例18: QueueCreateAsync

        private async static Task QueueCreateAsync(NamespaceManager ns, QueueDescription queueDescription)
        {
            if (!await ns.QueueExistsAsync(queueDescription.Path))
            {
                await ns.CreateQueueAsync(queueDescription);

                ServiceBusEventSource.Log.CreatedQueue(ns.Address.ToString(), queueDescription.Path);
            }
        }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:9,代码来源:MessagingFactoryQueueExtensions.cs


示例19: CreateSendOnlyQueue

        CreateSendOnlyQueue(
            string name)
        {
            var queueDescription = new QueueDescription(name) {
                Status = EntityStatus.ReceiveDisabled
            };

            return await this.CreateQueueInternal(queueDescription);
        }
开发者ID:eesee,项目名称:slinqy,代码行数:9,代码来源:ServiceBusQueueServiceModel.cs


示例20: CreateQueueSafeAsync

        public static async Task<QueueDescription> CreateQueueSafeAsync(this NamespaceManager namespaceManager, QueueDescription queueDescription)
        {
            var create = true;
            try
            {
                queueDescription = await namespaceManager.GetQueueAsync(queueDescription.Path).ConfigureAwait(false);

                create = false;
            }
            catch (MessagingEntityNotFoundException)
            {
            }

            if (create)
            {
                var created = false;
                try
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Creating queue {0}", queueDescription.Path);

                    queueDescription = await namespaceManager.CreateQueueAsync(queueDescription).ConfigureAwait(false);

                    created = true;
                }
                catch (MessagingEntityAlreadyExistsException)
                {
                }
                catch (MessagingException mex)
                {
                    if (mex.Message.Contains("(409)"))
                    {
                    }
                    else
                        throw;
                }

                if (!created)
                    queueDescription = await namespaceManager.GetQueueAsync(queueDescription.Path).ConfigureAwait(false);
            }

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Queue: {0} ({1})", queueDescription.Path,
                    string.Join(", ", new[]
                    {
                        queueDescription.EnableExpress ? "express" : "",
                        queueDescription.RequiresDuplicateDetection ? "dupe detect" : "",
                        queueDescription.EnableDeadLetteringOnMessageExpiration ? "dead letter" : "",
                        queueDescription.RequiresSession ? "session" : ""
                    }.Where(x => !string.IsNullOrWhiteSpace(x))));
            }

            return queueDescription;
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:55,代码来源:NamespaceManagerExtensions.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# QueueItem类代码示例发布时间:2022-05-24
下一篇:
C# QueueContinuationToken类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap