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

C# QueueClient类代码示例

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

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



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

示例1: Initialize

        public void Initialize(string queueName, string connectionString)
        {
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            QueueDescription queue;
            if (!namespaceManager.QueueExists(queueName))
            {
                queue = namespaceManager.CreateQueue(queueName);
                queue.EnableBatchedOperations = false;
                queue.EnableExpress = true;
                queue.DefaultMessageTimeToLive = TimeSpan.FromDays(3);
                //queue.EnableLargeMessages = true;
                queue.MaxDeliveryCount = int.MaxValue;
                //queue.RequiresSession = false;
                queue.SupportOrdering = true;
            }
            else
            {
                queue = namespaceManager.GetQueue(queueName);
            }

            queueClient = QueueClient.CreateFromConnectionString(connectionString, queueName, ReceiveMode.PeekLock);
            queueClient.OnMessage(receivedMessage =>
            {
                try
                {
                    MessageReceived(receivedMessage);
                    Trace.WriteLine("Processing Service Bus message: " + receivedMessage.SequenceNumber.ToString());
                }
                catch (Exception exc)
                {
                    receivedMessage.Abandon();
                    Trace.TraceError(exc.ToString());
                }
            }, new OnMessageOptions { AutoComplete = false, MaxConcurrentCalls = 10000 });
        }
开发者ID:tamifist,项目名称:KinderChat,代码行数:35,代码来源:ServiceBusQueue.cs


示例2: OnStart

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

            // Create the queue if it does not exist already
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            //var retryStrategy = new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
            //var retryPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(retryStrategy);

            try
            {
                if (!namespaceManager.QueueExists(QueueName))
                    namespaceManager.CreateQueue(QueueName);
            }
            catch (MessagingEntityAlreadyExistsException)
            {
                // eat and/or log this one as it's usually caused by a race condition
            }

            // Initialize the connection to Service Bus Queue
            Client = QueueClient.CreateFromConnectionString(connectionString, QueueName, ReceiveMode.PeekLock);
            IsStopped = false;
            return base.OnStart();
        }
开发者ID:ChrisKoenig,项目名称:Azure-ServiceBus,代码行数:26,代码来源:WorkerRole.cs


示例3: 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


示例4: Initialise

        public static void Initialise()
        {
            ServicePointManager.DefaultConnectionLimit = 12;

            string connectionString = CloudConfigurationManager.GetSetting("ServiceBus.QueueConnectionString");
            QueueClient = QueueClient.CreateFromConnectionString(connectionString, QueueName);
        }
开发者ID:robstoll,项目名称:farmfinder,代码行数:7,代码来源:QueueHelper.cs


示例5: StartAsync

        protected override async Task StartAsync()
        {
            InfoLogging(string.Format("{0} - Processing", QueueName));

            _queueClient = await _clientFactory.CreateServicebusQueueClientAsync(QueueName).ConfigureAwait(false);

            var stopWatch = new Stopwatch();

            while (!Token.IsCancellationRequested)
            {
                var messages = await _queueClient
                    .ReceiveBatchAsync(MessageRetrieveCount, MessageRetrieveTimeout)
                    .ConfigureAwait(false);
                var brokeredMessages = messages as IList<BrokeredMessage> ?? messages.ToList();
                if (!brokeredMessages.Any()) continue;

                var correlationId = Guid.NewGuid().ToString();
                DebugLogging(string.Format("{0} - Received {1} new messages", QueueName, brokeredMessages.Count),
                    correlationId);

                stopWatch.Restart();
                await Do(brokeredMessages).ConfigureAwait(false);

                stopWatch.Stop();
                var timeSpan = stopWatch.Elapsed;
                DebugLogging(string.Format("{0} - Processed messages", QueueName), correlationId,
                    timeSpan.TotalSeconds);
            }
        }
开发者ID:proactima,项目名称:AzureWorkers,代码行数:29,代码来源:BaseServiceBusQueueWorker.cs


示例6: QueueSubscriber

 public QueueSubscriber(string connectionString, string queueName, ILogger logger)
 {
     _logger = logger;
     _client = QueueClient.CreateFromConnectionString(connectionString, queueName);
     _queueName = queueName;
     _stopEvent = new ManualResetEvent(false);
 }
开发者ID:RagtimeWilly,项目名称:Astro.CQRS,代码行数:7,代码来源:QueueSubscriber.cs


示例7: OnStart

        public override bool OnStart()
        {
            //Starting Kernel
            Trace.TraceInformation("Starting Kernel");
            IKernel kernel = new StandardKernel();
            this.RegisterServices(kernel);
            Infra.IoC.Kernel.StartKernel(kernel);
            Trace.TraceInformation("Kernel Started");

            Trace.TraceInformation("Starting Logging");
            log4net.Config.XmlConfigurator.Configure();
            Trace.TraceInformation("Log Started");

            //Starting Listening Queue
            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            if (!namespaceManager.QueueExists(QueueName))
            {
                namespaceManager.CreateQueue(QueueName);
            }

            // Initialize the connection to Service Bus Queue
            Client = QueueClient.CreateFromConnectionString(connectionString, QueueName);

            Trace.TraceInformation("Starting Process Queue Service");
            queueProcessorService = Infra.IoC.Kernel.ResolveService<IQueueProcessorService>();
            Trace.TraceInformation("Process Queue Service Started");
            return base.OnStart();
        }
开发者ID:rafaelcruz-net,项目名称:mundipagg,代码行数:29,代码来源:WorkerRole.cs


示例8: OnStart

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

                // Create the queue if it does not exist already
                string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
                var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
                if (!namespaceManager.QueueExists(QueueName))
                {
                    namespaceManager.CreateQueue(QueueName);
                }

                // Initialize the connection to Service Bus Queue
                QueueClient = QueueClient.CreateFromConnectionString(connectionString, QueueName);
            }
            else
            {

            }

            dataSource = new CalculatorDataSource("simulation");
            IsStopped = false;
            return base.OnStart();
        }
开发者ID:andy-thomas,项目名称:AndyMonte,代码行数:27,代码来源:WorkerRole.cs


示例9: ReliableQueueClient

 public ReliableQueueClient(string sbNamespace, TokenProvider tokenProvider, string path, ReceiveMode receiveMode, RetryPolicy<ServiceBusTransientErrorDetectionStrategy> policy)
     : base(sbNamespace, tokenProvider,path,policy)
 {
     //create the queue if it doesn't exist
     bool needsCreation = false;
     try
     {
         needsCreation = !mRetryPolicy.ExecuteAction<bool>(() => mNamespaceManager.QueueExists(path));
     }
     catch (MessagingEntityNotFoundException)
     {
         needsCreation = true;
     }
     if (needsCreation)
     {
         try
         {
             mRetryPolicy.ExecuteAction<QueueDescription>(() => mNamespaceManager.CreateQueue(path));
         }
         catch (MessagingEntityAlreadyExistsException)
         {
             //ignore this exception because queue already exists
         }
     }
     mRetryPolicy.ExecuteAction(() => mQueueClient = mMessagingFactory.CreateQueueClient(path, receiveMode));
 }
开发者ID:HaishiBai,项目名称:ReliableServiceBusClients,代码行数:26,代码来源:ReliableQueueClient.cs


示例10: OnStart

 public override bool OnStart()
 {
     ServicePointManager.DefaultConnectionLimit = 12;
     var connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
     _client = QueueClient.CreateFromConnectionString(connectionString, QueueName);
     return base.OnStart();
 }
开发者ID:dougvdotcom,项目名称:azure-servicebus-poisoned-messages,代码行数:7,代码来源:DeadLetterQueue.cs


示例11: OnStart

        public override bool OnStart()
        {
            //send the traces to table Storage
            var storageConnectionString =
                CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
            var tlistener = new CustomTraceListener(storageConnectionString, "Aggregator");
            Trace.Listeners.Add(tlistener);

            //persistance storage settings also
            ManagerSettings.StorageConnectionString = storageConnectionString;

            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // Create the queue if it does not exist already
            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            if (!namespaceManager.QueueExists(QueueName))
            {
                namespaceManager.CreateQueue(QueueName);
            }

            // Initialize the connection to Service Bus Queue
            _client = QueueClient.CreateFromConnectionString(connectionString, QueueName);
            _isStopped = false;

            _storageConnectionString = CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
            return base.OnStart();
        }
开发者ID:sseyalioglu,项目名称:AzureWebAndWorker_For_PrimeSumFinder_withScale,代码行数:29,代码来源:WorkerRole.cs


示例12: AddToAzureQueue

        public static void AddToAzureQueue(this object o, string queueName, string nameSpace, string issuerName, string issuerKey)
        {
            if (_queueClient == null || queueName.ToLower() != _queueName || nameSpace.ToLower() != _nameSpace || issuerName.ToLower() != _issuerName || issuerKey.ToLower() != _issuerKey)
            {
                _queueName = queueName.ToLower();
                _nameSpace = nameSpace.ToLower();
                _issuerName = issuerName.ToLower();
                _issuerKey = issuerKey.ToLower();

                ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;
                System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;
                System.Net.ServicePointManager.Expect100Continue = false;
                System.Net.ServicePointManager.UseNagleAlgorithm = false;

                var credentials = GetToken(issuerName, issuerKey);

                // Get a client to the queue
                var messagingFactory = MessagingFactory.Create(GetAddress(nameSpace), credentials);
                _queueClient = messagingFactory.CreateQueueClient(queueName);
            }

            BrokeredMessage message = new BrokeredMessage(o);

            _queueClient.Send(message);
        }
开发者ID:eulalie367,项目名称:Helpers,代码行数:25,代码来源:AzureExtensions.cs


示例13: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     lstMensagens.Items.Add("status: Recebendo mensagens...");
     this.Refresh();
     queueClient = QueueClient.Create(QueueName);
     BrokeredMessage message = null;
     while (true)
     {
         try
         {
             message = queueClient.Receive(TimeSpan.FromSeconds(2));
             if (message != null)
             {
                 lstResultado.Items.Add(string.Format("Id: {0}, Body: {1}", message.MessageId, message.GetBody<string>()));
                 message.Complete();
             }
             else break;
         }
         catch (MessagingException error)
         {
             if (!error.IsTransient)
             {
                 lstMensagens.Items.Add("status: " + error.Message);
             }
             else ManipularExcecoes(error);
         }
     }
     queueClient.Close();
 }
开发者ID:lhlima,项目名称:CollaborationProjects,代码行数:29,代码来源:FormMensagem.cs


示例14: CommandQueueSubscriber

 public CommandQueueSubscriber(string connectionString, string queueName, ICommandDispatcher dispatcher, ILogger logger)
 {
     _dispatcher = dispatcher;
     _logger = logger;
     _client = QueueClient.CreateFromConnectionString(connectionString, queueName);
     _stopEvent = new ManualResetEvent(false);
 }
开发者ID:RagtimeWilly,项目名称:Astro.CQRS,代码行数:7,代码来源:CommandQueueSubscriber.cs


示例15: WindowsServiceBusQueueClient

        protected WindowsServiceBusQueueClient(WindowsServiceBusQueueEndpoint endpoint,
                                             IWindowsServiceBusConfiguration sbConfiguration)
            : base(sbConfiguration)
        {
            if (endpoint == null)
                throw new ArgumentNullException("endpoint");

            endpoint.Validate();

            try
            {
                if (NsManager.QueueExists(endpoint.QueueName) == false)
                    NsManager.CreateQueue(endpoint.QueueName);

                QueueClient = QueueClient.CreateFromConnectionString(sbConfiguration.ConnectionString,
                                                                     endpoint.QueueName);
            }
            catch (Exception ex)
            {
                throw new MessagingException(
                    String.Format(
                        "An error occurred while attempting to access the specified Windows service bus queue [{0}]. See inner exception for more details.",
                        endpoint.QueueName),
                    ex);
            }
        }
开发者ID:sonbua,项目名称:Mantle,代码行数:26,代码来源:WindowsServiceBusQueueClient.cs


示例16: OnStart

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

            // Create the queue if it does not exist already
            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            if (!namespaceManager.QueueExists(QueueName))
            {
                namespaceManager.CreateQueue(QueueName);
            }
            // Initialize the connection to Service Bus Queue
            _client = QueueClient.CreateFromConnectionString(connectionString, QueueName);

            var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
            // Create the blob client.
            var blobClient = storageAccount.CreateCloudBlobClient();
            // Retrieve a reference to a container.
            var container = blobClient.GetContainerReference("mycontainer");
            // Create the container if it doesn't already exist.
            container.CreateIfNotExists();
            _blob = container.GetBlockBlobReference("myblob");

            return base.OnStart();
        }
开发者ID:n893,项目名称:ExpInf,代码行数:26,代码来源:WorkerRole.cs


示例17: TestHostUnreachableResponseTime

        public void TestHostUnreachableResponseTime()
        {
            RedisServer.Kill();

            var stopWatch = new Stopwatch();

            try
            {
                using (var client = new QueueClient())
                {
                    var homemadeTask = new TaskMessage
                    {
                        Parameters = "params",
                        Queue = "TestQueue"
                    };

                    stopWatch.Start();
                    client.Enqueue(homemadeTask);
                    stopWatch.Stop();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Elapsed time: {0} ms", stopWatch.ElapsedMilliseconds);
                Console.WriteLine(exception.ToString());
                RedisServer.Start();
                Assert.Pass();
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:29,代码来源:QueueClientTests.cs


示例18: ReceiveQueueMessages

        static void ReceiveQueueMessages(QueueClient Client)
        {
            // Configure the callback options.
            OnMessageOptions options = new OnMessageOptions();
            options.AutoComplete = false;
            options.AutoRenewTimeout = TimeSpan.FromMinutes(1);

            // Callback to handle received messages.
            Client.OnMessage((message) =>
            {
                try
                {
                    // Process message from queue.
                    Console.WriteLine("Body: " + message.GetBody<string>());
                    Console.WriteLine("MessageID: " + message.MessageId);
                    Console.WriteLine("Test Property: " +
                    message.Properties["TestProperty"]);

                    // Remove message from queue.
                    message.Complete();
                }
                catch (Exception)
                {
                    // Indicates a problem, unlock message in queue.
                    message.Abandon();
                }
            }, options);
            Console.ReadLine();
        }
开发者ID:aravindnet,项目名称:AzureServiceBusSample,代码行数:29,代码来源:Program.cs


示例19: WorkInBackgroundController

 static WorkInBackgroundController()
 {
     var serviceBusConnectionString = CloudConfigurationManager.GetSetting(ServiceBusConnectionStringKey);
     QueueName = CloudConfigurationManager.GetSetting(ServiceBusQueueNameKey);
     ServiceBusQueueHandler = new ServiceBusQueueHandler(serviceBusConnectionString);
     QueueClient = ServiceBusQueueHandler.GetQueueClientAsync(QueueName).Result;
 }
开发者ID:smartpcr,项目名称:performance-optimization,代码行数:7,代码来源:WorkInBackgroundController.cs


示例20: TaskOrchestrationClient

 public TaskOrchestrationClient(string connectionString, string orchestrationTopicName)
 {
     this.orchestrationTopicName = orchestrationTopicName;
     this.connectionString = connectionString;
     this.messagingFactory = MessagingFactory.CreateFromConnectionString(this.connectionString);
     this.oxQueueClient = this.messagingFactory.CreateQueueClient(this.orchestrationTopicName);
     this.defaultConverter = new JsonDataConverter();
 }
开发者ID:Frank-Tao,项目名称:durabletask,代码行数:8,代码来源:TaskOrchestrationClient.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# QueueContinuationToken类代码示例发布时间:2022-05-24
下一篇:
C# Queue类代码示例发布时间: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