using System; using System.Linq.Expressions; using System.Threading.Tasks; using Tapeti.Config; // ReSharper disable UnusedMember.Global namespace Tapeti { /// /// Allows publishing of messages. /// public interface IPublisher { /// /// Publish the specified message. Transport details are determined by the Tapeti configuration. /// /// The message to send Task Publish(object message); /// /// Publish the specified request message and handle the response with the controller method as specified /// by the responseMethodSelector expression. The response method or controller must have a valid queue attribute. /// /// /// The response method is called on a new instance of the controller, as is the case with a regular message. /// To preserve state, use the Tapeti.Flow extension instead. /// /// An expression defining the method which handles the response. Example: c => c.HandleResponse /// The message to send Task PublishRequest(TRequest message, Expression>> responseMethodSelector) where TController : class; /// /// Publish the specified request message and handle the response with the controller method as specified /// by the responseMethodSelector expression. The response method or controller must have a valid queue attribute. /// /// /// The response method is called on a new instance of the controller, as is the case with a regular message. /// To preserve state, use the Tapeti.Flow extension instead. /// /// An expression defining the method which handles the response. Example: c => c.HandleResponse /// The message to send Task PublishRequest(TRequest message, Expression>> responseMethodSelector) where TController : class; /// /// Sends a message directly to the specified queue. Not recommended for general use. /// /// The name of the queue to publish the message to /// The message to send Task SendToQueue(string queueName, object message); } /// /// /// Low-level publisher for Tapeti internal use. /// /// /// Tapeti assumes every implementation of IPublisher can also be cast to an IInternalPublisher. /// The distinction is made on purpose to trigger code-smells in non-Tapeti code when casting. /// public interface IInternalPublisher : IPublisher { /// /// Publishes a message. The exchange and routing key are determined by the registered strategies. /// /// An instance of a message class /// Metadata to include in the message /// If true, an exception will be raised if the message can not be delivered to at least one queue Task Publish(object message, IMessageProperties properties, bool mandatory); /// /// Publishes a message directly to a queue. The exchange and routing key are not used. /// /// An instance of a message class /// The name of the queue to send the message to /// Metadata to include in the message /// If true, an exception will be raised if the message can not be delivered to the queue /// Task PublishDirect(object message, string queueName, IMessageProperties properties, bool mandatory); } }