public IActionResult GetResults(string actionType, string workerId) { var routingKey = RoutingKeys.FormatKey(actionType, workerId); var results = ImMemResultsStorage.Results.Where(m => m.RoutingKey == routingKey); return(new JsonResult(results)); }
/// <summary> /// Determines if this queue has any related routing keys /// </summary> /// <returns></returns> public bool HasRoutingKeys() { if (RoutingKeys == null) { return(false); } return(RoutingKeys.Any()); }
public string[] GetRoutingKeysAsArray() { if (string.IsNullOrEmpty(RoutingKeys)) { return(new string[0]); } return(RoutingKeys.Split(new [] { " " }, StringSplitOptions.RemoveEmptyEntries)); }
/// <summary> /// 获取路由键 /// </summary> /// <param name="routingKey">路由键</param> /// <returns>路由键</returns> public string GetRoutingKey(string routingKey = null) { if (RoutingKeys.IsNullOrLength0()) { return(routingKey); } return(string.IsNullOrWhiteSpace(routingKey) ? RoutingKeys[0] : routingKey); }
public override int GetHashCode() { unchecked { // ReSharper disable NonReadonlyFieldInGetHashCode int hashCode = (Reason != null ? Reason.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Queue != null ? Queue.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Exchange != null ? Exchange.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RoutingKeys != null ? RoutingKeys.GetHashCode() : 0); return(hashCode); // ReSharper restore NonReadonlyFieldInGetHashCode } }
private async Task StartQueueReader() { lock (_sync) { Data = new List <CustomQueueItem <T> >(); _isActive = true; } var factory = new ConnectionFactory { Uri = new Uri(_connectionString) }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.BasicQos(0, (ushort)_prefetchCount, false); channel.QueueDeclare(QueueName, true, false, IsQueueAutoDelete); if (RoutingKeys.Any()) { foreach (var key in RoutingKeys) { channel.QueueBind(QueueName, ExchangeName, key); } } else { channel.QueueBind(QueueName, ExchangeName, ""); } var consumer = new EventingBasicConsumer(channel); consumer.Received += CreateOnMessageReceivedEventHandler(channel); var tag = channel.BasicConsume(QueueName, false, consumer); var writerTask = StartHandler(connection); while (!_cancellationTokenSource.IsCancellationRequested && connection.IsOpen) { await Task.Delay(100); } await writerTask; channel.BasicCancel(tag); connection.Close(); } }
public void BindQueue(IModel channel) { if (string.IsNullOrEmpty(ExchangeName)) { return; } if (RoutingKeys.Count == 0) { RoutingKeys = new List <string>(new[] { "" }); } RoutingKeys .ForEach(x => channel.QueueBind(QueueName, ExchangeName, x, null)); }
public override int GetHashCode() { unchecked { int result = (Broker != null ? Broker.GetHashCode() : 0); result = (result * 397) ^ (VirtualHost != null ? VirtualHost.GetHashCode() : 0); result = (result * 397) ^ (Username != null ? Username.GetHashCode() : 0); result = (result * 397) ^ (Password != null ? Password.GetHashCode() : 0); result = (result * 397) ^ (Exchange != null ? Exchange.GetHashCode() : 0); result = (result * 397) ^ (QueueName != null ? QueueName.GetHashCode() : 0); result = (result * 397) ^ (RoutingKeys != null ? RoutingKeys.GetHashCode() : 0); result = (result * 397) ^ RouteByType.GetHashCode(); return(result); } }
public bool Equals(RabbitMqXDeath other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (Count == other.Count && string.Equals(Exchange, other.Exchange) && string.Equals(Queue, other.Queue) && string.Equals(Reason, other.Reason) && RoutingKeys.All(other.RoutingKeys.Contains) && Time == other.Time); }
public void AddRouteKey(string key) { RoutingKeys.Add(key); }