/// <summary> /// Implements RPC over an asynchronous message bus. While the publisher does not block /// and can complete other unrelated work, the publisher is synchronous in terms that they /// can't complete their entire work until the response is received. /// </summary> /// <param name="queueName">The name of the queue on which the subscriber will receive commands.</param> /// <param name="actionNamespace">For a given RPC command, identifies to the consumer the associated action.</param> /// <param name="busName">The bus name key used to lookup connection.</param> /// <param name="settings">Optional delegate called allowing caller to set /// additional exchange properties.</param> /// <typeparam name="TMessage">The command type associated with the queue.</typeparam> protected void DefineRpcQueue <TMessage>(string queueName, string actionNamespace, string busName, Action <ExchangeMeta <TMessage> > settings = null) where TMessage : ICommand { if (string.IsNullOrWhiteSpace(actionNamespace)) { throw new ArgumentException("RPC Action Namespace not Specified.", nameof(actionNamespace)); } var publisherStrategy = new RpcPublisherStrategy(); var exchange = ExchangeMeta.DefineDefault <TMessage>(busName, queueName, config => { config.IsAutoDelete = true; config.IsDurable = false; config.IsPassive = false; config.IsExclusive = false; }); exchange.IsAutoDelete = true; exchange.IsRpcExchange = true; exchange.ActionNamespace = actionNamespace; exchange.SetPublisherStrategy(publisherStrategy); _exchanges.Add(exchange); settings?.Invoke(exchange); }
public QueueMeta CreateQueueMeta(SubscriberQueueAttribute attribute) { var exchange = ExchangeMeta.DefineDefault(attribute.BusName, attribute.QueueName, config => { config.IsAutoDelete = false; config.IsDurable = true; config.IsPassive = false; config.IsExclusive = false; }); return(exchange.QueueMeta); }
public QueueMeta CreateQueueMeta(SubscriberQueueAttribute attribute) { var rpcAttribute = (RpcQueueAttribute)attribute; var exchange = ExchangeMeta.DefineDefault(rpcAttribute.BusName, rpcAttribute.QueueName, config => { config.IsAutoDelete = true; config.IsDurable = false; config.IsPassive = false; config.IsExclusive = false; }); exchange.IsRpcExchange = true; exchange.ActionNamespace = rpcAttribute.ActionNamespace; return(exchange.QueueMeta); }
/// <summary> /// Defines a work queue. For the other type of exchanges, the publisher does not know /// the consumers subscribing to the queues defined on the exchange. A work queue is used /// to make a request of another service by sending a command to the queue for processing. /// The processing is asynchronous and the publisher does not wait for a response. This /// should be used by a publisher to submit a time consuming task to a specific service /// for processing. /// </summary> /// <param name="queueName">The name of the queue on which the consuming service will receive commands.</param> /// <param name="busName">The bus name key used to lookup connection.</param> /// <param name="settings">Optional delegate called allowing caller to set /// additional exchange properties.</param> /// <typeparam name="TMessage">The command type associated with the queue.</typeparam> protected void DefineWorkQueue <TMessage>(string queueName, string busName, Action <ExchangeMeta <TMessage> > settings = null) where TMessage : ICommand { var exchange = ExchangeMeta.DefineDefault <TMessage>(busName, queueName, config => { config.IsAutoDelete = false; config.IsDurable = true; config.IsPassive = false; config.IsExclusive = false; }); exchange.RouteKey = queueName; _exchanges.Add(exchange); settings?.Invoke(exchange); }
public void CanSpecifyQueueSettings_InConfiguration() { ContainerFixture.Test(fixture => { fixture.Arrange .Configuration(TestSetup.AddValidBusConfigWithQueueSettings) .Container(c => { c.WithRabbitMqHost(); }) .Assert.PluginModule <MockBusModule>(m => { var queueMeta = ExchangeMeta.DefineDefault("TestBus1", "TestQueueName").QueueMeta; m.ApplyQueueSettings(queueMeta); Assert.True(queueMeta.IsPassive); Assert.Equal(20000, queueMeta.PerQueueMessageTtl); Assert.Equal("TestDeadLetterExchange", queueMeta.DeadLetterExchange); Assert.Equal("TestDeadLetterRoutingKey", queueMeta.DeadLetterRoutingKey); Assert.Equal((byte)10, queueMeta.MaxPriority); Assert.Equal(5, queueMeta.PrefetchCount); Assert.Equal(2, queueMeta.Priority); }); }); }