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


C# QueueClient类代码示例

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


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


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