/// <summary> /// Create a rabbitconsumer which will consume message from a PUBLIC exchange. This exchange is supposed to be direct/fanout (otherwise use the raw constructor) /// </summary> /// <param name="settings">Settings used to construct the consumer</param> /// <param name="exchange">the exchange you want to listen to</param> public RabbitConsumer(HareConsumerSettings settings, RabbitExchange exchange) : this(settings) { _myQueue = new RabbitQueue(GetUniqueIdentifier(exchange.Name)) { AutoDelete = true }; RedeclareMyTopology = m => { exchange.Declare(m); _myQueue.Declare(m); m.QueueBind(_myQueue.Name, exchange.Name, "noRKrequired"); }; }
/// <summary> /// Publish to a PUBLIC queue /// </summary> /// <param name="mySettings">Settings used to construct a publisher</param> /// <param name="destinationQueue">public queue you want to connect to</param> public RabbitPublisher(HarePublisherSettings mySettings, RabbitQueue destinationQueue) : this(mySettings) { _destinationQueue = destinationQueue; _myExchange = new RabbitExchange(destinationQueue.Name + "-" + "exchange") { AutoDelete = true }; RedeclareMyTopology = m => { _myExchange.Declare(m); destinationQueue.Declare(m); m.QueueBind(destinationQueue.Name, _myExchange.Name, "noRKneeded"); }; }
/// <summary> /// Raw constructor, you have to do everything yourself /// </summary> /// <param name="mySettings"> </param> /// <param name="exchange">Exchange you will sent message to. It *won't* be created, you have to create it in the redeclareToplogy parameter</param> /// <param name="redeclareTopology">Lambda called everytime we need to recreate the rabbitmq oblects, it should be idempotent</param> public RabbitPublisher(HarePublisherSettings mySettings, RabbitExchange exchange, Action<IModel> redeclareTopology) : this(mySettings) { _myExchange = exchange; RedeclareMyTopology = redeclareTopology; }
/// <summary> /// Publish to a PUBLIC exchange /// </summary> /// <param name="mySettings">Settings used to construct a publisher</param> /// <param name="exchange">public exchange you want to connect to</param> public RabbitPublisher(HarePublisherSettings mySettings, RabbitExchange exchange) : this(mySettings) { _myExchange = exchange; RedeclareMyTopology = _myExchange.Declare; }
/// <summary> /// Publish to a PUBLIC queue /// </summary> /// <param name="mySettings">Settings used to construct a publisher</param> /// <param name="destinationQueue">public queue you want to connect to</param> public RabbitPublisher(HarePublisherSettings mySettings, RabbitQueue destinationQueue) : this(mySettings) { _myExchange = new RabbitExchange(destinationQueue.Name + "-" + "exchange") { AutoDelete = true }; RedeclareMyTopology = m => { _myExchange.Declare(m); destinationQueue.Declare(m); m.QueueBind(destinationQueue.Name, _myExchange.Name, "noRKneeded"); }; }
/// <summary> /// Raw constructor, you have to do everything yourself /// </summary> /// <param name="mySettings"> </param> /// <param name="exchange">Exchange you will sent message to. It *won't* be created, you have to create it in the redeclareToplogy parameter</param> /// <param name="redeclareTopology">Lambda called everytime we need to recreate the rabbitmq oblects, it should be idempotent</param> public RabbitPublisher(HarePublisherSettings mySettings, RabbitExchange exchange, Action <IModel> redeclareTopology) : this(mySettings) { _myExchange = exchange; RedeclareMyTopology = redeclareTopology; }