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


C# QueueName类代码示例

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


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

示例1: InitDb

        private static IDbConnectionProvider InitDb(DirectoryInfo directory, QueueName queueName)
        {
            var dbPath = Path.Combine(directory.FullName, queueName + ".db");
            var connectionStringSettings = new ConnectionStringSettings
            {
                Name = dbPath,
                ConnectionString = "Data Source=" + dbPath + "; Version=3",
                ProviderName = "System.Data.SQLite"
            };

            var connectionProvider = new SingletonConnectionProvider(connectionStringSettings);
            var connection = connectionProvider.GetConnection();
            try
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = new SQLiteDialect().CreateMessageQueueingServiceObjectsCommand;
                    command.ExecuteNonQuery();
                }
            }
            finally
            {
                connectionProvider.ReleaseConnection(connection);
            }
            return connectionProvider;
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:27,代码来源:SQLiteMessageQueue.cs

示例2: NextAsync

        public Task<PollerResult<Event>> NextAsync(QueueName name)
        {
            var connection = _connectionProvider.GetConnection();
            var result = new PollerResult<Event>(false , Event.Empty);
            using (var channel = connection.CreateModel())
            {
                var consumer = new QueueingBasicConsumer(channel);
                channel.BasicConsume(name.SubscriptionName, true, consumer);
                BasicDeliverEventArgs eventArgs = null;
                if (consumer.Queue.Dequeue((int)_longPollingTimeout.TotalMilliseconds, 
                    out eventArgs))
                {
                    var @event = new Event()
                    {
                        Body = Encoding.UTF8.GetString(eventArgs.Body),
                        QueueName = name.SubscriptionName,
                        UnderlyingMessage = eventArgs,
                        ContentType = "text/plain", // should it be JSON?
                        EventType = name.SubscriptionName
                    };

                    result = new PollerResult<Event>(true, @event);
                }
                return Task.FromResult(result);
            }

        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:27,代码来源:RabbitMqOperator.cs

示例3: PushBatchAsync

        public async Task PushBatchAsync(IEnumerable<Event> messages)
        {

            const int BatchSize = 50;
            
            var msgs = messages.ToArray();
            if (!msgs.Any())
                return;

            var message = msgs.First();
            var queueName = new QueueName(message.QueueName);
            int i = 0;

            if (queueName.IsSimpleQueue)
            {
                var client = _clientProvider.GetQueueClient(queueName);
                while (i < msgs.Length)
                {
                    await client.SendBatchAsync(msgs.Skip(i).Take(BatchSize).Select(x => x.ToMessage()));
                    i += BatchSize;
                }
            }
            else
            {
                var client = _clientProvider.GetTopicClient(queueName);
                while (i < msgs.Length)
                {
                    await client.SendBatchAsync(msgs.Skip(i).Take(BatchSize).Select(x => x.ToMessage()));
                    i += BatchSize;
                }
            }
        }
开发者ID:FeodorFitsner,项目名称:BeeHive,代码行数:32,代码来源:ServiceBusOperator.cs

示例4: RouteRegistration

 public RouteRegistration(string messageFilter, QueueName destination)
 {
     Condition.Requires(messageFilter, "messageFilter").IsNotNullOrEmpty();
       Condition.Requires(destination, "destination").IsNotNull();
       MessageFilter = messageFilter;
       Destination = destination;
 }
开发者ID:JornWildt,项目名称:Xyperico,代码行数:7,代码来源:RouteRegistration.cs

示例5: SubscribeCommand

 public SubscribeCommand(Type subscribedMessageType, QueueName subscriberQueue)
 {
     Condition.Requires(subscribedMessageType, "subscribedMessageType").IsNotNull();
       Condition.Requires(subscriberQueue, "subscriberQueue").IsNotNull();
       SubscribedMessagesTypeName = subscribedMessageType.AssemblyQualifiedName;
       SubscriberQueueName = subscriberQueue.Name;
 }
开发者ID:JornWildt,项目名称:Xyperico,代码行数:7,代码来源:SubscribeCommand.cs

示例6: MsmqQueueObserver

 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public MsmqQueueObserver(string serviceBusName, QueueName inputQueue, QueueName errorQueue, MsmqQueueTransport queueTransport)
 {
     _serviceBusName = serviceBusName;
     _inputQueue = inputQueue;
     _errorQueue = errorQueue;
     _queueTransport = queueTransport;
 }
开发者ID:paralect,项目名称:Paralect.ServiceBus,代码行数:10,代码来源:MsmqQueueObserver.cs

示例7: SQLMessageQueue

        public SQLMessageQueue(IDbConnectionProvider connectionProvider, ISQLDialect dialect, QueueName queueName,
            IQueueListener listener, QueueOptions options = default(QueueOptions))
        {
            if (connectionProvider == null) throw new ArgumentNullException("connectionProvider");
            if (dialect == null) throw new ArgumentNullException("dialect");
            if (queueName == null) throw new ArgumentNullException("queueName");
            if (listener == null) throw new ArgumentNullException("listener");

            _connectionProvider = connectionProvider;
            _dialect = dialect;
            _queueName = queueName;

            _listener = listener;
            _autoAcknowledge = options.AutoAcknowledge;
            _maxAttempts = options.MaxAttempts <= 0 ? 10 : options.MaxAttempts;
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;

            var concurrencyLimit = options.ConcurrencyLimit <= 0
                ? QueueOptions.DefaultConcurrencyLimit
                : options.ConcurrencyLimit;
            _concurrentMessageProcessingSlot = new SemaphoreSlim(concurrencyLimit);

            _cancellationTokenSource = new CancellationTokenSource();
            _queuedMessages = new BufferBlock<SQLQueuedMessage>(new DataflowBlockOptions
            {
                CancellationToken = _cancellationTokenSource.Token
            });
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:28,代码来源:SQLMessageQueue.cs

示例8: Prepare

        /// <summary>
        /// Stages indexes. Should run only using one process.
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="documentType"></param>
        /// <param name="rebuild"></param>
        /// <exception cref="System.ArgumentNullException">scope</exception>
        public void Prepare(string scope, string documentType = "", bool rebuild = false)
        {
            if (String.IsNullOrEmpty(scope))
                throw new ArgumentNullException("scope");

            foreach (var builder in _indexBuilders)
            {
                // skip not requested indexers or index using all if index is not specified
                if (!String.IsNullOrEmpty(documentType) && !documentType.Equals(builder.DocumentType))
                    continue;

                // Execute builder, which will create partitions and put them in the queue
                var queueName = new QueueName("index-{0}-{1}-in", scope, builder.DocumentType);

                var config = GetBuildConfig(_repository, queueName.Scope, queueName.DocumentType);

                var lastBuild = DateTime.UtcNow;
                var newBuildDate = lastBuild;
                if (config.Status == BuildStatus.NeverStarted.GetHashCode() || rebuild) // build was never started, so set min date
                {
                    rebuild = true;
                    lastBuild = DateTime.MinValue;
                    config.LastBuildDate = DateTime.UtcNow.AddYears(-30); // have to set the date to something repository won't complain
                }
                else
                {
                    lastBuild = config.LastBuildDate.AddSeconds(-30); // make sure we get all the changes 
                }

                // Delete all the records
                if (rebuild)
                {
                    _searchProvider.RemoveAll(queueName.Scope, queueName.DocumentType);
                }

                var partitions = builder.CreatePartitions(queueName.Scope, lastBuild);

                var newPartitionsExist = false; // tells if there are any partitions that has been processed
                foreach (var partition in partitions)
                {
                    newPartitionsExist = true;
                    //_observer.Notify(new ConsumeBegin(msg, consumer, envelope.QueueName));
                   _messageSender.Send(queueName.ToString(), partition);
                }

                var newBuildStatus = BuildStatus.Started;
                if (newPartitionsExist)
                {
                    _messageSender.Send(queueName.ToString(), new SearchIndexStatusMessage(queueName.Scope, queueName.DocumentType, BuildStatus.Completed));
                }
                else
                {
                    newBuildStatus = BuildStatus.Completed;
                }

                config.LastBuildDate = newBuildDate;
                config.Status = newBuildStatus.GetHashCode();
                _repository.UnitOfWork.Commit();
            }
        }
开发者ID:Wdovin,项目名称:vc-community,代码行数:67,代码来源:SearchIndexController.cs

示例9: RabbitMQQueue

        public RabbitMQQueue(QueueName queueName, IQueueListener listener, IConnection connection,
            Encoding encoding = null, QueueOptions options = default(QueueOptions))
        {
            if (queueName == null) throw new ArgumentNullException("queueName");
            if (listener == null) throw new ArgumentNullException("listener");
            if (connection == null) throw new ArgumentNullException("connection");

            _queueName = queueName;
            _queueExchange = _queueName.GetExchangeName();
            _retryQueueName = queueName.GetRetryQueueName();
            _retryExchange = _queueName.GetRetryExchangeName();
            _deadLetterExchange = _queueName.GetDeadLetterExchangeName();

            _listener = listener;
            _connection = connection;
            _encoding = encoding ?? Encoding.UTF8;
            _ttl = options.TTL;
            _maxAttempts = Math.Max(options.MaxAttempts, 1);
            _retryDelay = options.RetryDelay < TimeSpan.Zero ? TimeSpan.Zero : options.RetryDelay;
            _cancellationTokenSource = new CancellationTokenSource();

            var autoAcknowledge = options.AutoAcknowledge;
            var concurrencyLimit = Math.Max(options.ConcurrencyLimit, 1);
            _consumers = new DurableConsumer[concurrencyLimit];
            for (var i = 0; i < _consumers.Length; i++)
            {
                var consumerTag = _queueName + "_" + i;
                _consumers[i] = new DurableConsumer(_connection, queueName, HandleDelivery, consumerTag,
                    autoAcknowledge);
            }
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:31,代码来源:RabbitMQQueue.cs

示例10: Given_ClaimsPrincipal_When_Reading_Principal_Should_Be_Read

        public async Task Given_ClaimsPrincipal_When_Reading_Principal_Should_Be_Read()
        {
            var tempDir = GetTempDirectory();
            var queueName = new QueueName(Guid.NewGuid().ToString());
            var queuePath = Path.Combine(tempDir.FullName, queueName);
            var queueDir = new DirectoryInfo(queuePath);
            if (!queueDir.Exists)
            {
                queueDir.Create();
            }

            var message = new Message(new MessageHeaders
            {
                {HeaderName.ContentType, "text/plain"},
                {HeaderName.MessageId, Guid.NewGuid().ToString()}
            }, "Hello, world!");

            var senderPrincipal = new ClaimsPrincipal(new ClaimsIdentity(new[]
            {
                new Claim("username", "testuser"),
                new Claim("role", "testrole")
            }));

            var file = (await MessageFile.Create(queueDir, message, senderPrincipal)).File;
            var messageFile = new MessageFile(file);
            var readSenderPrincipal = await messageFile.ReadSenderPrincipal();
            var readMessage = await messageFile.ReadMessage();

            Assert.That(readSenderPrincipal, Is.EqualTo(senderPrincipal).Using(new ClaimsPrincipalEqualityComparer()));
            Assert.That(readMessage, Is.EqualTo(message).Using(new MessageEqualityComparer()));
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:31,代码来源:MessageFileTests.cs

示例11: DeleteQueueAsyncAwait

 public async Task DeleteQueueAsyncAwait()
 {
     #region DeleteQueueAsync (await)
     IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
     QueueName queueName = new QueueName("ExampleQueue");
     await queueingService.DeleteQueueAsync(queueName, CancellationToken.None);
     #endregion
 }
开发者ID:charlyraffellini,项目名称:openstack.net,代码行数:8,代码来源:QueueingServiceExamples.cs

示例12: CreateQueue

 public void CreateQueue()
 {
     #region CreateQueueAsync (TPL)
     IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
     QueueName queueName = new QueueName("ExampleQueue");
     Task<bool> task = queueingService.CreateQueueAsync(queueName, CancellationToken.None);
     #endregion
 }
开发者ID:charlyraffellini,项目名称:openstack.net,代码行数:8,代码来源:QueueingServiceExamples.cs

示例13: PublishMessage

 public static async Task PublishMessage(Message message, IPrincipal principal, IConnection connection,
     QueueName queueName, string exchange = "", Encoding encoding = null, int attempts = 0)
 {
     using (var channel = connection.CreateModel())
     {
         await PublishMessage(message, principal, channel, queueName, exchange, encoding, attempts);
     }
 }
开发者ID:tdbrian,项目名称:Platibus,代码行数:8,代码来源:RabbitMQHelper.cs

示例14: CreateQueue

 public Task CreateQueue(QueueName queueName, IQueueListener listener, QueueOptions options = default(QueueOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     if (!_queues.TryAdd(queueName, new InMemoryQueue(listener, options)))
     {
         throw new QueueAlreadyExistsException(queueName);
     }
     return Task.FromResult(true);
 }
开发者ID:tdbrian,项目名称:Platibus,代码行数:8,代码来源:InMemoryMessageQueueingService.cs

示例15: HandlingRule

 /// <summary>
 /// Initializes a new <see cref="HandlingRule"/> with the supplied message
 /// <paramref name="specification"/>, <see cref="MessageHandler"/>, and
 /// <paramref name="queueName"/>.
 /// </summary>
 /// <param name="specification">The message specification that selects messages 
 /// to which the handling rule applies</param>
 /// <param name="messageHandler">The handler to which messages matching the
 /// specification will be routed</param>
 /// <param name="queueName">(Optional) The name of the queue in which matching
 /// messages will be placed while they await handling</param>
 /// <remarks>
 /// If the <paramref name="queueName"/> is ommitted, a default queue name will
 /// be generated based on the MD5 hash of the full type name of the supplied
 /// <paramref name="messageHandler"/>
 /// </remarks>
 /// <seealso cref="GenerateQueueName"/>
 public HandlingRule(IMessageSpecification specification, IMessageHandler messageHandler,
     QueueName queueName = null)
 {
     if (specification == null) throw new ArgumentNullException("specification");
     if (messageHandler == null) throw new ArgumentNullException("messageHandler");
     _specification = specification;
     _messageHandler = messageHandler;
     _queueName = queueName ?? GenerateQueueName(messageHandler);
 }
开发者ID:tdbrian,项目名称:Platibus,代码行数:26,代码来源:HandlingRule.cs


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