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


C# NamespaceManager.QueueExists方法代码示例

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


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

示例1: Main

		static void Main()
		{
			_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
			namespaceManager = NamespaceManager.CreateFromConnectionString(_servicesBusConnectionString);

			if (!namespaceManager.QueueExists(nameof(Step1)))
			{
				namespaceManager.CreateQueue(nameof(Step1));
			}
			if (!namespaceManager.QueueExists(nameof(Step2)))
			{
				namespaceManager.CreateQueue(nameof(Step2));
			}

			JobHostConfiguration config = new JobHostConfiguration();
			config.UseServiceBus();



			var host = new JobHost(config);

			CreateStartMessage();

			host.RunAndBlock();
		}
开发者ID:Cognim,项目名称:Azure-webjobs-and-service-bus-tryout,代码行数:25,代码来源:Program.cs

示例2: Main

        public static void Main(string[] args)
        {
            ServiceNamespace = ConfigurationManager.AppSettings["ServiceNamespace"];
            // Issuer key
            sasKeyValue = ConfigurationManager.AppSettings["SASKey"];            

            // Create management credentials
            TokenProvider credentials = TokenProvider.CreateSharedAccessSignatureTokenProvider(sasKeyName, sasKeyValue);
            NamespaceManager namespaceClient = 
                new NamespaceManager(
                    ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), 
                    credentials);
            QueueDescription myQueue;
            if (!namespaceClient.QueueExists(QUEUE))
            {
                myQueue = namespaceClient.CreateQueue(QUEUE);
            }
            MessagingFactory factory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), credentials);
            QueueClient myQueueClient = factory.CreateQueueClient(QUEUE);

            // Send message
            Poco poco = new Poco();
            poco.Id = "001";
            poco.content = "This is some content";
            BrokeredMessage message = new BrokeredMessage();
            message.Properties.Add("Id", poco.Id);
            message.Properties.Add("Content", poco.content);
            myQueueClient.Send(message);
        }
开发者ID:martin-chambers,项目名称:ContinuousWebJob,代码行数:29,代码来源:Program.cs

示例3: DeleteQueue

        private static void DeleteQueue(NamespaceManager namespaceManager)
        {
            Console.WriteLine("\nRemoving Queue '{0}'...", queueName);

            // Delete if exists
            if (namespaceManager.QueueExists(queueName))
            {
                namespaceManager.DeleteQueue(queueName);
            }
        }
开发者ID:Srinivasanks23,项目名称:ServiceBusSandbox,代码行数:10,代码来源:program.cs

示例4: TryCreateQueueIfNotExists

        private void TryCreateQueueIfNotExists(NamespaceManager namespaceManager, string queueName)
        {
            if (!namespaceManager.QueueExists(queueName))
            {
                var queueDescription = new QueueDescription(queueName)
                {
                    MaxSizeInMegabytes = 5120,
                    DefaultMessageTimeToLive = TimeSpan.FromDays(7),
                    RequiresDuplicateDetection = false,
                    MaxDeliveryCount = 10
                };

                namespaceManager.CreateQueue(queueDescription);
            }
        }
开发者ID:pauliusmaciulis,项目名称:AzureMessaging,代码行数:15,代码来源:QueueClientFactory.cs

示例5: CreateQueue

        public bool CreateQueue(string queueId)
        {
            // Holds credentials and handles tokens from AZS
            TokenProvider tokenProvider = GetTokenProvider();

            Uri uri = GetServiceBusUri();

            var namespaceManager = new NamespaceManager(uri, tokenProvider);

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

            throw new NotImplementedException();
        }
开发者ID:CloudMorph,项目名称:CloudMorph,代码行数:16,代码来源:AzureServiceBusQueueProvider.cs

示例6: PrepareWatchingQueue

        private QueueClient PrepareWatchingQueue()
        {
            var namespaceManagerSetting = new NamespaceManagerSettings()
            {
                TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(ServiceBusIssuerName, ServiceBusIssuerSecret),
            };

            var namespaceManager = new NamespaceManager(ServiceBusAddress, namespaceManagerSetting);
            if (!namespaceManager.QueueExists(_watchingQueueName))
            {
                namespaceManager.CreateQueue(_watchingQueueName);
            }

            var factory = MessagingFactory.Create(ServiceBusAddress, SharedSecretTokenProvider.CreateSharedSecretTokenProvider(ServiceBusIssuerName, ServiceBusIssuerSecret));
            var queueClient = factory.CreateQueueClient(_watchingQueueName);
            return queueClient;
        }
开发者ID:hugebdu,项目名称:MapReduce.JS,代码行数:17,代码来源:MapResultGenerator.cs

示例7: CreateQueuesIfNotExists

        private static void CreateQueuesIfNotExists(NamespaceManager namespaceManager, ServiceBusQueueOptions options)
        {
            foreach (var queue in options.Queues)
            {
                var prefixed = options.GetQueueName(queue);

                if (!namespaceManager.QueueExists(prefixed))
                {
                    var description = new QueueDescription(prefixed);

                    if (options.Configure != null)
                    {
                        options.Configure(description);
                    }

                    namespaceManager.CreateQueue(description);
                }
            }
        }
开发者ID:nisbus,项目名称:Hangfire.Azure.ServiceBusQueue,代码行数:19,代码来源:ServiceBusManager.cs

示例8: MainSync

        public async static Task MainSync()
        {
            ServiceNamespace = ConfigurationManager.AppSettings["ServiceNamespace"];
            // Issuer key
            sasKeyValue = ConfigurationManager.AppSettings["SASKey"];

            // Get test async
            string testId = "56b747d9fdfad82a0cfdce65";

            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://getcmewebapi.azurewebsites.net/");
            Task<string> testTask = client.GetStringAsync("api/v1/Test/" + testId);

            // do other stuff while we're waiting for the test ...

            // Create management credentials
            TokenProvider credentials = TokenProvider.CreateSharedAccessSignatureTokenProvider(sasKeyName, sasKeyValue);
            NamespaceManager namespaceClient =
                new NamespaceManager(
                    ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty),
                    credentials);
            QueueDescription myQueue;
            if (!namespaceClient.QueueExists(QUEUE))
            {
                myQueue = namespaceClient.CreateQueue(QUEUE);
            }
            MessagingFactory factory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), credentials);
            QueueClient myQueueClient = factory.CreateQueueClient(QUEUE);

            // Send message
            BrokeredMessage message = new BrokeredMessage();

            // we need the test now ...
            var testJsonString = await testTask;
            Test test = JObject.Parse(testJsonString).ToObject<Test>();

            message.Properties.Add("TestId", test.Id);
            message.Properties.Add("InputDataId", test.InputDataId);
            message.Properties.Add("DateSetId", test.DateSetId);
            myQueueClient.Send(message);
        }
开发者ID:martin-chambers,项目名称:GetCMEWebAPI,代码行数:41,代码来源:Program.cs

示例9: Main

 static void Main(string[] args)
 {
     GetUserCredentials();
     TokenProvider credentials = null;
     Uri serviceUri = null;
     CreateTokenProviderAndServiceUri(out credentials, out serviceUri);
     MessagingFactory factory = null;
     try
     {
         NamespaceManager namespaceClient = new NamespaceManager(serviceUri, credentials);
         if (namespaceClient == null)
         {
             Console.WriteLine("\nUnexpected Error: NamespaceManager is NULL");
             return;
         }
         Console.WriteLine("\nCreating Queue '{0}'...", QueueName);
         //Eliminar se a queue já existir
         if (namespaceClient.QueueExists(QueueName))
             namespaceClient.DeleteQueue(QueueName);
         namespaceClient.CreateQueue(QueueName);
         QueueClient myQueueClient = CreateQueueClient(serviceUri, credentials, out factory);
         List<BrokeredMessage> messageList = new List<BrokeredMessage>();
         messageList.Add(CreateIssueMessage("1", "First message "));
         messageList.Add(CreateIssueMessage("2", "Second message "));
         messageList.Add(CreateIssueMessage("3", "Third message "));
         SendListOfMessages(messageList, myQueueClient);
     }
     catch (Exception e)
     {
         Console.WriteLine("Unexpected exception {0}", e.ToString());
         throw;
     }
     finally
     {
         if (factory != null)
             factory.Close();
     }
 }
开发者ID:sandrapatfer,项目名称:PROMPT11-10-CloudComputing.sandrapatfer,代码行数:38,代码来源:Program.cs

示例10: ServiceBusConnection

        /// <summary>
        /// Setup and connect to Service Bus.
        /// </summary>
        /// <param name="namespaceManager"></param>
        /// <param name="messagingFactory"></param>
        /// <param name="durableMessageSender"></param>
        private static void ServiceBusConnection(out NamespaceManager namespaceManager, out MessagingFactory messagingFactory, out DurableMessageSender durableMessageSender)
        {
            //Read user credentials.

            //Console.Write("Service Namespace: ");
            //string serviceNamespace = Console.ReadLine();

            //Console.Write("Issuer Name: ");
            //string issuerName = Console.ReadLine();

            //Console.Write("Issuer Key: ");
            //string issuerKey = Console.ReadLine();
            //Console.WriteLine();

            string serviceNamespace = "scoring";
            string issuerName = "owner";
            string issuerKey = "r3JxwjeQwuWwwLasXSQR7tDGx2FCiQLijr9ZBzPCti4=";
            Console.WriteLine("Service Namespace: " + serviceNamespace);
            Console.WriteLine("Issuer Name: " + issuerName);
            Console.WriteLine("Issuer Key: " + issuerKey);

            // Create token provider.
            Uri namespaceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, string.Empty);
            Console.WriteLine("Namespace URI: " + namespaceUri.ToString());
            TokenProvider tokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey);

            // Create namespace manager and create Service Bus queue if it does not exist already.
            namespaceManager = new NamespaceManager(namespaceUri, tokenProvider);
            QueueDescription queueDescription = new QueueDescription(ServiceBusQueueOrTopicName);
            queueDescription.RequiresDuplicateDetection = true;
            if (!namespaceManager.QueueExists(ServiceBusQueueOrTopicName))
            {
                namespaceManager.CreateQueue(queueDescription);
                Console.WriteLine("Created Service Bus queue \"{0}\".", ServiceBusQueueOrTopicName);
            }

            // Create a MessagingFactory.
            messagingFactory = MessagingFactory.Create(namespaceUri, tokenProvider);

            // Create a durable sender.
            durableMessageSender = new DurableMessageSender(messagingFactory, ServiceBusQueueOrTopicName);
        }
开发者ID:NorfolkNChance,项目名称:azuretest,代码行数:48,代码来源:Client.cs

示例11: SetupAsync

        public async Task SetupAsync(Type[] allMessageTypes, Type[] recievingMessageTypes)
        {
            _logger.Debug("Starting the setup of AzureServicebusTransport...");

            _namespaceManager = NamespaceManager.CreateFromConnectionString(_configuration.GetConnectionString());
            _messagingFactory = MessagingFactory.CreateFromConnectionString(_configuration.GetConnectionString());

            _messageTypes = allMessageTypes;

            var sendCommandTypes = _messageTypes
                .Where(t => typeof (IBusCommand)
                    .IsAssignableFrom(t));

            var sendEventTypes = _messageTypes
                .Where(t => typeof(IBusEvent)
                    .IsAssignableFrom(t));

            var recieveCommandTypes = recievingMessageTypes
                .Where(t => typeof(IBusCommand)
                    .IsAssignableFrom(t));

            var recieveEventTypes = recievingMessageTypes
                .Where(t => typeof(IBusEvent)
                    .IsAssignableFrom(t));

            if (_configuration.GetEnableTopicAndQueueCreation())
            {
                foreach (var type in sendCommandTypes)
                {
                    var path = PathFactory.QueuePathFor(type);
                    if (!_namespaceManager.QueueExists(path))
                        await _namespaceManager.CreateQueueAsync(path);

                    var client = _messagingFactory.CreateQueueClient(path);
                    client.PrefetchCount = 10; //todo;: in config?

                    var eventDrivenMessagingOptions = new OnMessageOptions
                    {
                        AutoComplete = true, //todo: in config?
                        MaxConcurrentCalls = 10 //todo: in config?
                    };
                    eventDrivenMessagingOptions.ExceptionReceived += OnExceptionReceived;
                    client.OnMessageAsync(OnMessageRecieved, eventDrivenMessagingOptions);

                    if (!_queues.TryAdd(type, client))
                    {
                        _logger.Error("Could not add the queue with type: {0}", type.FullName);
                    }
                }
                foreach (var type in sendEventTypes)
                {
                    var path = PathFactory.TopicPathFor(type);
                    if (!_namespaceManager.TopicExists(path))
                        _namespaceManager.CreateTopic(path);

                    var client = _messagingFactory.CreateTopicClient(path);

                    if (!_topics.TryAdd(type, client))
                    {
                        _logger.Error("Could not add the topic with type: {0}", type.FullName);
                    }


                }
            }

            _logger.Debug("Setup of AzureServicebusTransport completed!");

            throw new NotImplementedException();
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus-vNext,代码行数:70,代码来源:AzureServicebusTransport.cs

示例12: CreateQueueIfNecessary

        private QueueClient CreateQueueIfNecessary(NamespaceManager namespaceManager, string queueName)
        {
            //Trace.TraceWarning("Does queue exist: " + queueName);
            if (!namespaceManager.QueueExists(queueName))
            {
                Trace.TraceWarning("CreateQueue: " + _connectionString + " " + queueName);
                namespaceManager.CreateQueue(queueName);
            }

            Trace.TraceWarning("Get QueueClient from ConnectionString: " + _connectionString + " " + queueName);
            var qc = QueueClient.CreateFromConnectionString(_connectionString, queueName);
            if (qc == null)
            {
                Trace.TraceError("CreateQueue() failed - queueClient is null");
            }
            return qc;
            //return QueueClient.CreateFromConnectionString(_connectionString, queueName);
        }
开发者ID:JimmyE,项目名称:Shark123,代码行数:18,代码来源:WorkerRole.cs

示例13: GetOrCreateQueue

        private QueueClient GetOrCreateQueue(Uri namespaceUri, TokenProvider tokenProvider)
        {
            NamespaceManager namespaceClient = new NamespaceManager(namespaceUri, tokenProvider);

            // Create queue if not already exist.
            if (!namespaceClient.QueueExists(MyQueuePath))
            {
                namespaceClient.CreateQueue(this.queueDescription);
                Console.WriteLine("Queue created.");
            }
            else
            {
                Console.WriteLine("Queue already exists.");
            }

            MessagingFactory factory = MessagingFactory.Create(namespaceUri, tokenProvider);
            Console.WriteLine("Creating queue client...");
            return factory.CreateQueueClient(MyQueuePath, ReceiveMode.PeekLock);            
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:19,代码来源:PersistentQueueListener.cs

示例14: Exists

        bool Exists(NamespaceManager namespaceClient, string path)
        {
            var key = path;
            logger.InfoFormat("Checking existence cache for '{0}'", path);
            var exists = rememberExistence.GetOrAdd(key, s =>
            {
                logger.InfoFormat("Checking namespace for existance of the queue '{0}'", path);
                return namespaceClient.QueueExists(key);
            });

            logger.InfoFormat("Determined that the queue '{0}' {1}", path, exists ? "exists" : "does not exist");

            return exists;
        }
开发者ID:danielmarbach,项目名称:NServiceBus.AzureServiceBus,代码行数:14,代码来源:AzureServiceBusQueueCreator.cs

示例15: CreateQueueClientIfNotExist

        private QueueClient CreateQueueClientIfNotExist(string p_healthMonitorCommandQueueName, bool p_requiresSession, string p_serviceBusUri, TokenProvider p_tokenProvider, NamespaceManager p_namespaceManager)
        {
            if (!p_namespaceManager.QueueExists(p_healthMonitorCommandQueueName))
            {
                QueueDescription qDesc = new QueueDescription(p_healthMonitorCommandQueueName);
                qDesc.MaxSizeInMegabytes = 5120;
                qDesc.DefaultMessageTimeToLive = TimeSpan.FromDays(14); // on Free tier pricing, max 14 days are allowed
                qDesc.EnableDeadLetteringOnMessageExpiration = false;
                qDesc.LockDuration = TimeSpan.FromMinutes(5);  // default is 30seconds, I have changed it to 5minutes, which is the maximum
                qDesc.RequiresDuplicateDetection = false;
                // 'RequiresSession' cannot be set when creating a Queue IF the namespace 'sqhealthmonitorservicebusqueue-ns' is using free 'Basic' tier.
                qDesc.RequiresSession = p_requiresSession;      // if there is only one consumer of the command queue, no sessionID is required, for the commandResult there are more consumers
                qDesc.EnablePartitioning = true;
                // until this line is the properties that can be set in Azure portal

                qDesc.EnableBatchedOperations = false;      // for low latency, quick response, don't wait miliseconds to batch messages, but send them instantly
                var qDescCreated = p_namespaceManager.CreateQueue(qDesc);
            }
            MessagingFactorySettings mfs = new MessagingFactorySettings();
            mfs.TokenProvider = p_tokenProvider;
            //mfs.TransportType = TransportType.Amqp;       // 400msec latency
            mfs.TransportType = Microsoft.ServiceBus.Messaging.TransportType.NetMessaging;     // 50msec latency
            mfs.NetMessagingTransportSettings.BatchFlushInterval = TimeSpan.Zero;  // instead of 20msec, // latency is 37msec was the minimum I measured (instead of 43msec)
            MessagingFactory factory = MessagingFactory.Create(p_serviceBusUri, mfs);
            var queueClient = factory.CreateQueueClient(p_healthMonitorCommandQueueName, ReceiveMode.PeekLock);
            queueClient.PrefetchCount = 0;  // it is the default too, and it was 0 in the fast and in the slow cases too
            return queueClient;
        }
开发者ID:gyantal,项目名称:SQHealthMonitor,代码行数:28,代码来源:CommandQueueHost.cs


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