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


C# QueueDescription类代码示例

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


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


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