/// <summary> /// Constructs the bus with the specified ways of achieving its goals. /// </summary> /// <param name="activateHandlers">The bus will use this to construct handlers for received messages.</param> /// <param name="sendMessages">Will be used to send transport messages when you send, publish, and reply.</param> /// <param name="receiveMessages">Will be used to receive transport messages. If the bus is configured to run with multiple threads, this one should be reentrant.</param> /// <param name="storeSubscriptions">Will be used to store subscription information. Is only relevant if the bus is a publisher, i.e. it publishes messages and other services assume they can subscribe to its messages.</param> /// <param name="storeSagaData">Will be used to store saga data. Is only relevant if one or more handlers are derived from <see cref="Saga"/>.</param> /// <param name="determineMessageOwnership">Will be used to resolve a destination in cases where the message destination is not explicitly specified as part of a send/subscribe operation.</param> /// <param name="serializeMessages">Will be used to serialize and deserialize transport messages.</param> /// <param name="inspectHandlerPipeline">Will be called to inspect the pipeline of handlers constructed to handle an incoming message.</param> /// <param name="errorTracker">Will be used to track failed delivery attempts.</param> /// <param name="storeTimeouts">Optionally provides an internal timeout manager to be used instead of sending timeout requests to an external timeout manager</param> /// <param name="configureAdditionalBehavior"></param> public RebusBus( IActivateHandlers activateHandlers, ISendMessages sendMessages, IReceiveMessages receiveMessages, IStoreSubscriptions storeSubscriptions, IStoreSagaData storeSagaData, IDetermineMessageOwnership determineMessageOwnership, ISerializeMessages serializeMessages, IInspectHandlerPipeline inspectHandlerPipeline, IErrorTracker errorTracker, IStoreTimeouts storeTimeouts, ConfigureAdditionalBehavior configureAdditionalBehavior) { this.activateHandlers = activateHandlers; this.sendMessages = sendMessages; this.receiveMessages = receiveMessages; this.storeSubscriptions = storeSubscriptions; this.determineMessageOwnership = determineMessageOwnership; this.serializeMessages = serializeMessages; this.storeSagaData = storeSagaData; this.inspectHandlerPipeline = inspectHandlerPipeline; this.errorTracker = errorTracker; this.storeTimeouts = storeTimeouts; this.configureAdditionalBehavior = configureAdditionalBehavior; batch = new RebusBatchOperations(determineMessageOwnership, storeSubscriptions, this); routing = new RebusRouting(this); rebusId = Interlocked.Increment(ref rebusIdCounter); continuations = new RebusSynchronizationContext(); log.Info("Rebus bus {0} created", rebusId); if (storeTimeouts == null) { var timeoutManagerEndpointAddress = RebusConfigurationSection .GetConfigurationValueOrDefault(s => s.TimeoutManagerAddress, "rebus.timeout"); log.Info("Using external timeout manager with input queue '{0}'", timeoutManagerEndpointAddress); timeoutManagerAddress = timeoutManagerEndpointAddress; } else { log.Info("Using internal timeout manager"); timeoutManagerAddress = this.receiveMessages.InputQueueAddress; dueTimeoutScheduler = new DueTimeoutScheduler(storeTimeouts, new DeferredMessageReDispatcher(this)); } }
public Worker( IErrorTracker errorTracker, IReceiveMessages receiveMessages, IActivateHandlers activateHandlers, IStoreSubscriptions storeSubscriptions, ISerializeMessages serializeMessages, IStoreSagaData storeSagaData, IInspectHandlerPipeline inspectHandlerPipeline, string workerThreadName, IHandleDeferredMessage handleDeferredMessage, IMutateIncomingMessages mutateIncomingMessages, IStoreTimeouts storeTimeouts, IEnumerable <IUnitOfWorkManager> unitOfWorkManagers, ConfigureAdditionalBehavior configureAdditionalBehavior, MessageLogger messageLogger, RebusSynchronizationContext continuations) { this.receiveMessages = receiveMessages; this.serializeMessages = serializeMessages; this.mutateIncomingMessages = mutateIncomingMessages; this.unitOfWorkManagers = unitOfWorkManagers; this.configureAdditionalBehavior = configureAdditionalBehavior; this.messageLogger = messageLogger; this.continuations = continuations; this.errorTracker = errorTracker; dispatcher = new Dispatcher(storeSagaData, activateHandlers, storeSubscriptions, inspectHandlerPipeline, handleDeferredMessage, storeTimeouts); dispatcher.UncorrelatedMessage += RaiseUncorrelatedMessage; dispatcher.AfterHandling += RaiseAfterHandling; dispatcher.BeforeHandling += RaiseBeforeHandling; dispatcher.OnHandlingError += RaiseOnHandlingError; nullMessageReceivedBackoffHelper = CreateBackoffHelper(configureAdditionalBehavior.BackoffBehavior); workerThread = new Thread(MainLoop) { Name = workerThreadName }; workerThread.Start(); log.Info("Worker {0} created and inner thread started", WorkerThreadName); }
public Worker( IErrorTracker errorTracker, IReceiveMessages receiveMessages, IActivateHandlers activateHandlers, IStoreSubscriptions storeSubscriptions, ISerializeMessages serializeMessages, IStoreSagaData storeSagaData, IInspectHandlerPipeline inspectHandlerPipeline, string workerThreadName, IHandleDeferredMessage handleDeferredMessage, IMutateIncomingMessages mutateIncomingMessages, IStoreTimeouts storeTimeouts, IEnumerable<IUnitOfWorkManager> unitOfWorkManagers, ConfigureAdditionalBehavior configureAdditionalBehavior, MessageLogger messageLogger, RebusSynchronizationContext continuations) { this.receiveMessages = receiveMessages; this.serializeMessages = serializeMessages; this.mutateIncomingMessages = mutateIncomingMessages; this.unitOfWorkManagers = unitOfWorkManagers; this.configureAdditionalBehavior = configureAdditionalBehavior; this.messageLogger = messageLogger; this.continuations = continuations; this.errorTracker = errorTracker; dispatcher = new Dispatcher(storeSagaData, activateHandlers, storeSubscriptions, inspectHandlerPipeline, handleDeferredMessage, storeTimeouts); dispatcher.UncorrelatedMessage += RaiseUncorrelatedMessage; nullMessageReceivedBackoffHelper = CreateBackoffHelper(configureAdditionalBehavior.BackoffBehavior); workerThread = new Thread(MainLoop) { Name = workerThreadName }; workerThread.Start(); log.Info("Worker {0} created and inner thread started", WorkerThreadName); }