/// <summary> /// Constructor for use with a Producer /// </summary> /// <param name="outBox">The outbox to store messages - use InMemoryInbox if you do not require a persistent outbox</param> /// <param name="asyncOutBox">The outbox to store messages - use InMemoryInbox if you do not require a persistent outbox</param> /// <param name="producer">The Message producer</param> /// <param name="asyncProducer">The Message producer's async interface</param> public BrighterMessaging(IAmAnOutbox <Message> outBox, IAmAnOutboxAsync <Message> asyncOutBox, IAmAMessageProducer producer, IAmAMessageProducerAsync asyncProducer) { OutBox = outBox; AsyncOutBox = asyncOutBox; Producer = producer; AsyncProducer = asyncProducer; }
/// <summary> /// Constructor for use with a Producer /// </summary> /// <param name="outBox">The outbox to store messages - use InMemoryInbox if you do not require a persistent outbox</param> /// <param name="asyncOutBox">The outbox to store messages - use InMemoryInbox if you do not require a persistent outbox</param> /// <param name="producer">The Message producer</param> /// <param name="asyncProducer">The Message producer's async interface</param> /// <param name="useRequestReplyQueues">Use Request Reply Queues - This will need to set a Channel Factory as well.</param> public BrighterMessaging(IAmAnOutbox <Message> outBox, IAmAnOutboxAsync <Message> asyncOutBox, IAmAMessageProducer producer, IAmAMessageProducerAsync asyncProducer, bool useRequestReplyQueues = true) { OutBox = outBox; AsyncOutBox = asyncOutBox; Producer = producer; AsyncProducer = asyncProducer; UseRequestReplyQueues = useRequestReplyQueues; }
/// <summary> /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues. /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/> /// are handled by adding appropriate <see cref="Policies"/> when choosing this option. /// /// </summary> /// <param name="configuration">The Task Queues configuration.</param> /// <returns>INeedARequestContext.</returns> public INeedARequestContext TaskQueues(MessagingConfiguration configuration) { _useTaskQueues = true; _messageStore = configuration.OutBox; _asyncOutbox = configuration.AsyncOutbox; _messagingGateway = configuration.MessageProducer; _asyncMessagingGateway = configuration.AsyncMessageProducer; _messageMapperRegistry = configuration.MessageMapperRegistry; _messageStoreWriteTimeout = configuration.MessageStoreWriteTimeout; _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout; return(this); }
/// <summary> /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Call{T}(T)"/> using RPC between client and server /// </summary> /// <param name="messagingConfiguration"></param> /// <returns></returns> public INeedARequestContext RequestReplyQueues(MessagingConfiguration configuration) { _useRequestReplyQueues = true; _messageStore = configuration.OutBox; _asyncOutbox = configuration.OutboxAsync; _messagingGateway = configuration.MessageProducer; _asyncMessagingGateway = configuration.MessageProducerAsync; _messageMapperRegistry = configuration.MessageMapperRegistry; _messageStoreWriteTimeout = configuration.MessageStoreWriteTimeout; _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout; _responseChannelFactory = configuration.ResponseChannelFactory; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class. /// </summary> /// <param name="asyncOutbox">The OutBox which supports async/await.</param> /// <param name="asyncmessageProducer">The messaging gateway that supports async/await.</param> /// <param name="messageMapperRegistry">The message mapper registry.</param> /// <param name="messageStoreWriteTimeout">How long to wait when writing to the message store</param> /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param> public MessagingConfiguration( IAmAnOutboxAsync <Message> asyncOutbox, IAmAMessageProducerAsync asyncmessageProducer, IAmAMessageMapperRegistry messageMapperRegistry, int messageStoreWriteTimeout = 300, int messagingGatewaySendTimeout = 300 ) { AsyncOutbox = asyncOutbox; AsyncMessageProducer = asyncmessageProducer; MessageMapperRegistry = messageMapperRegistry; MessageStoreWriteTimeout = messageStoreWriteTimeout; MessagingGatewaySendTimeout = messagingGatewaySendTimeout; }
/// <summary> /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues. /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/> /// are handled by adding appropriate <see cref="Policies"/> when choosing this option. /// /// </summary> /// <param name="configuration">The Task Queues configuration.</param> /// <returns>INeedARequestContext.</returns> public INeedARequestContext TaskQueues(MessagingConfiguration configuration, IAmAnOutbox <Message> outbox) { _useTaskQueues = true; _messagingGateway = configuration.MessageProducer; _outbox = outbox; if (outbox is IAmAnOutboxAsync <Message> ) { _asyncOutbox = (IAmAnOutboxAsync <Message>)outbox; } _asyncMessagingGateway = configuration.MessageProducerAsync; _messageMapperRegistry = configuration.MessageMapperRegistry; _outboxWriteTimeout = configuration.OutboxWriteTimeout; _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class. /// </summary> /// <param name="outboxAsync">The OutBox which supports async/await.</param> /// <param name="asyncmessageProducer">The messaging gateway that supports async/await.</param> /// <param name="messageMapperRegistry">The message mapper registry.</param> /// <param name="outboxWriteTimeout">How long to wait when writing to the outbox</param> /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param> /// <param name="useInbox">Do we want to create an inbox globally i.e. on every handler (as opposed to by hand). Defaults to null, by hand</param> public MessagingConfiguration( IAmAnOutboxAsync <Message> outboxAsync, IAmAMessageProducerAsync asyncmessageProducer, IAmAMessageMapperRegistry messageMapperRegistry, int outboxWriteTimeout = 300, int messagingGatewaySendTimeout = 300, InboxConfiguration useInbox = null ) { OutboxAsync = outboxAsync; MessageProducerAsync = asyncmessageProducer; MessageMapperRegistry = messageMapperRegistry; OutboxWriteTimeout = outboxWriteTimeout; MessagingGatewaySendTimeout = messagingGatewaySendTimeout; UseInbox = useInbox; }
/// <summary> /// Initializes a new instance of the <see cref="CommandProcessor"/> class. /// Use this constructor when only task queue support is required /// </summary> /// <param name="requestContextFactory">The request context factory.</param> /// <param name="policyRegistry">The policy registry.</param> /// <param name="mapperRegistry">The mapper registry.</param> /// <param name="asyncOutbox">The outbox supporting async/await.</param> /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param> /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param> /// <param name="featureSwitchRegistry">The feature switch config provider.</param> public CommandProcessor( IAmARequestContextFactory requestContextFactory, IPolicyRegistry <string> policyRegistry, IAmAMessageMapperRegistry mapperRegistry, IAmAnOutboxAsync <Message> asyncOutbox, IAmAMessageProducerAsync asyncMessageProducer, int messageStoreTimeout = 300, IAmAFeatureSwitchRegistry featureSwitchRegistry = null) { _requestContextFactory = requestContextFactory; _policyRegistry = policyRegistry; _messageStoreTimeout = messageStoreTimeout; _mapperRegistry = mapperRegistry; _asyncOutbox = asyncOutbox; _asyncMessageProducer = asyncMessageProducer; _featureSwitchRegistry = featureSwitchRegistry; }
/// <summary> /// Initializes a new instance of the <see cref="CommandProcessor"/> class. /// Use this constructor when both task queue and command processor support is required /// </summary> /// <param name="subscriberRegistry">The subscriber registry.</param> /// <param name="asyncHandlerFactory">The async handler factory.</param> /// <param name="requestContextFactory">The request context factory.</param> /// <param name="policyRegistry">The policy registry.</param> /// <param name="mapperRegistry">The mapper registry.</param> /// <param name="asyncOutbox">The outbox supporting async/await.</param> /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param> /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param> /// <param name="featureSwitchRegistry">The feature switch config provider.</param> public CommandProcessor( IAmASubscriberRegistry subscriberRegistry, IAmAHandlerFactoryAsync asyncHandlerFactory, IAmARequestContextFactory requestContextFactory, IPolicyRegistry <string> policyRegistry, IAmAMessageMapperRegistry mapperRegistry, IAmAnOutboxAsync <Message> asyncOutbox, IAmAMessageProducerAsync asyncMessageProducer, int messageStoreTimeout = 300, IAmAFeatureSwitchRegistry featureSwitchRegistry = null) : this(subscriberRegistry, asyncHandlerFactory, requestContextFactory, policyRegistry, featureSwitchRegistry) { _mapperRegistry = mapperRegistry; _asyncOutbox = asyncOutbox; _asyncMessageProducer = asyncMessageProducer; _messageStoreTimeout = messageStoreTimeout; _featureSwitchRegistry = featureSwitchRegistry; }
/// <summary> /// Initializes a new instance of the <see cref="CommandProcessor"/> class. /// Use this constructor when both task queue and command processor support is required, and you want to inject a test logger /// </summary> /// <param name="subscriberRegistry">The subscriber registry.</param> /// <param name="handlerFactory">The handler factory.</param> /// <param name="asyncHandlerFactory">The async handler factory.</param> /// <param name="requestContextFactory">The request context factory.</param> /// <param name="policyRegistry">The policy registry.</param> /// <param name="mapperRegistry">The mapper registry.</param> /// <param name="outBox">The outbox.</param> /// <param name="asyncOutbox">The outbox supporting async/await.</param> /// <param name="messageProducer">The messaging gateway.</param> /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param> /// <param name="outboxTimeout">How long should we wait to write to the outbox</param> /// <param name="featureSwitchRegistry">The feature switch config provider.</param> /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param> public CommandProcessor( IAmASubscriberRegistry subscriberRegistry, IAmAHandlerFactory handlerFactory, IAmAHandlerFactoryAsync asyncHandlerFactory, IAmARequestContextFactory requestContextFactory, IPolicyRegistry <string> policyRegistry, IAmAMessageMapperRegistry mapperRegistry, IAmAnOutbox <Message> outBox, IAmAnOutboxAsync <Message> asyncOutbox, IAmAMessageProducer messageProducer, IAmAMessageProducerAsync asyncMessageProducer, int outboxTimeout = 300, IAmAFeatureSwitchRegistry featureSwitchRegistry = null, InboxConfiguration inboxConfiguration = null) : this(subscriberRegistry, handlerFactory, asyncHandlerFactory, requestContextFactory, policyRegistry, featureSwitchRegistry) { _mapperRegistry = mapperRegistry; _outBox = outBox; _asyncOutbox = asyncOutbox; _messageProducer = messageProducer; _asyncMessageProducer = asyncMessageProducer; _outboxTimeout = outboxTimeout; _inboxConfiguration = inboxConfiguration; }