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) { this.receiveMessages = receiveMessages; this.serializeMessages = serializeMessages; this.mutateIncomingMessages = mutateIncomingMessages; this.unitOfWorkManagers = unitOfWorkManagers; this.configureAdditionalBehavior = configureAdditionalBehavior; this.messageLogger = messageLogger; 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); }
/// <summary> /// Scans the dlls and creates a dictionary in which each message in IFunctions is referenced to each function. /// </summary> public HandlersContainer(string serviceName, bool lockSaga = true) { lock (o) { this.serviceName = serviceName; this.lockSaga = SettingsUtil.HasSettings(SETTINGS.LOCKSAGAS)? SettingsUtil.GetSettings <bool>(SETTINGS.LOCKSAGAS):lockSaga; AddDependency <ISerializeMessages, JSONSerializer>(); AddDependency <ISagaLocker, SagaAzureStorageLocker>(); AddDependency <ISendMessages, AzureStorageQueueSendTransport>(SolveDependency <ISerializeMessages>()); AddDependency <IPublishEvents, AzureEventHubPublishTransport>(SolveDependency <ISerializeMessages>()); this.serializer = SolveDependency <ISerializeMessages>(); this.sagaLocker = SolveDependency <ISagaLocker>(); AddDependency <ISagaStoragePersistence, SagaAzureStoragePersistence>(this.sagaLocker as ISagaLocker, this.lockSaga); sagaPersistence = SolveDependency <ISagaStoragePersistence>(); messageSender = SolveDependency <ISendMessages>(); var assemblies = new List <Assembly>(); assemblies.Add(Assembly.GetCallingAssembly()); assemblies.AddRange(Assembly.GetCallingAssembly().GetReferencedAssemblies().Select(a => Assembly.Load(a.FullName))); var types = assemblies.SelectMany(a => a.GetTypes()); LookForSagas(types); LookForHandlers(types); this.sagaLocker.CreateLocksContainer(); sagaPersistence.CreateSagaPersistenceTableAsync().Wait(); } }
protected ChannelBase(ICreateEndpoints endpointFactory, ISerializeMessages messageSerializer) { Verify.NotNull(messageSerializer, "messageSerializer"); this.endpointFactory = endpointFactory; this.messageSerializer = messageSerializer; }
public MsmqReceiverEndpoint( MsmqConnector inputQueue, MsmqConnector poisonQueue, ISerializeMessages serializer) { this.inputQueue = inputQueue; this.poisonQueue = poisonQueue; this.serializer = serializer; }
public Worker(IErrorTracker errorTracker, IReceiveMessages receiveMessages, IActivateHandlers activateHandlers, IStoreSubscriptions storeSubscriptions, ISerializeMessages serializeMessages, IStoreSagaData storeSagaData, IInspectHandlerPipeline inspectHandlerPipeline, string workerThreadName, IHandleDeferredMessage handleDeferredMessage, IMutateIncomingMessages mutateIncomingMessages) { this.receiveMessages = receiveMessages; this.serializeMessages = serializeMessages; this.mutateIncomingMessages = mutateIncomingMessages; this.errorTracker = errorTracker; dispatcher = new Dispatcher(storeSagaData, activateHandlers, storeSubscriptions, inspectHandlerPipeline, handleDeferredMessage); dispatcher.UncorrelatedMessage += RaiseUncorrelatedMessage; workerThread = new Thread(MainLoop) { Name = workerThreadName }; workerThread.Start(); log.Info("Worker {0} created and inner thread started", WorkerThreadName); }
public SqlTimeoutStorage(ISerializeObjects objectSerializer, ISerializeMessages messageSerializer) { this.objectSerializer = objectSerializer; this.messageSerializer = messageSerializer; connectionString = Settings.GetSetting(SqlTransportConfiguration.MessagingConnectionStringKey); CreateTableIfNecessary(); }
public MessageReader(FrameReader frameReader, ISerializeMessages serializer) { Verify.NotNull(frameReader, "frameReader"); Verify.NotNull(serializer, "serializer"); this.frameReader = frameReader; this.serializer = serializer; }
public Bus(ISerializeMessages messageSerializer, ITransportMessages messageTransport, IRouteMessageToEndpoint messageRouter, IPublishMessages messagePublisher, IProcessMessages messageProcessor) { this.messageSerializer = messageSerializer; this.messageTransport = messageTransport; this.messageRouter = messageRouter; this.messagePublisher = messagePublisher; this.messageProcessor = messageProcessor; }
public EncryptMessageSerializer(ISerializeMessages inner, byte[] encryptionKey) { if (!KeyIsValid(encryptionKey, KeyLength)) { throw new ArgumentException(Diagnostics.InvalidEncryptionKey, "encryptionKey"); } this.encryptionKey = encryptionKey; this.inner = inner; }
public AzureStorageQueueSendTransport(ISerializeMessages serializer) { this.serializer = serializer; // Create a container if (!containerCreated) { var cloudBlobContainer = cloudBlobClient.GetContainerReference(CONTAINER_NAME.ToLower()); cloudBlobContainer.CreateIfNotExistsAsync().Wait(); containerCreated = true; } }
/// <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="determineDestination">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> public RebusBus(IActivateHandlers activateHandlers, ISendMessages sendMessages, IReceiveMessages receiveMessages, IStoreSubscriptions storeSubscriptions, IStoreSagaData storeSagaData, IDetermineDestination determineDestination, ISerializeMessages serializeMessages, IInspectHandlerPipeline inspectHandlerPipeline) { this.activateHandlers = activateHandlers; this.sendMessages = sendMessages; this.receiveMessages = receiveMessages; this.storeSubscriptions = storeSubscriptions; this.determineDestination = determineDestination; this.serializeMessages = serializeMessages; this.storeSagaData = storeSagaData; this.inspectHandlerPipeline = inspectHandlerPipeline; rebusId = Interlocked.Increment(ref rebusIdCounter); log.Info("Rebus bus created"); }
public static async Task PublishAsync <T>(T input, string topic, ISerializeMessages serializer = null, IPublishEvents publisher = null) where T : class { serializer = serializer ?? new JSONSerializer(); var newContext = new AFBusMessageContext { MessageID = Guid.NewGuid(), TransactionID = Guid.NewGuid(), BodyType = typeof(T).AssemblyQualifiedName }; publisher = publisher ?? new AzureEventHubPublishTransport(serializer); await publisher.PublishEventsAsync(input, topic, newContext).ConfigureAwait(false); }
/// <summary> /// Constructor /// </summary> /// <param name="transport">Message transport used as a backend for this message bus</param> public MessageBus(IMessageTransport transport, IMessageDispatcher dispatcher, ISerializeMessages serializer, IServiceResolver serviceResolver) { log = LogManager.GetLogger("BUS_" + transport.Endpoint); log.Info("Message Bus {0} created", transport.Endpoint); MessageSerializer = serializer; Dispatcher = dispatcher; ServiceLocator = serviceResolver; _transport = transport; _transport.OnMessageArrived += new MessageArrived(_transport_OnMessageArrived); _transport.OnMessageToUnknownDestination += new MessageArrived(_transport_OnMessageToUnknownDestination); SubscriptionService = new DummySubscriptionService(); BatchOutgoingMessagesInTransaction = true; MessageHandlerTransactionScopeOption = TransactionScopeOption.Required; UseTransactionScope = true; DefaultSubscriptionLifetime = TimeSpan.FromHours(48); PublishLocalByDefault = true; }
/// <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="determineDestination">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> public RebusBus(IActivateHandlers activateHandlers, ISendMessages sendMessages, IReceiveMessages receiveMessages, IStoreSubscriptions storeSubscriptions, IStoreSagaData storeSagaData, IDetermineDestination determineDestination, ISerializeMessages serializeMessages, IInspectHandlerPipeline inspectHandlerPipeline, IErrorTracker errorTracker) { this.activateHandlers = activateHandlers; this.sendMessages = sendMessages; this.receiveMessages = receiveMessages; this.storeSubscriptions = storeSubscriptions; this.determineDestination = determineDestination; this.serializeMessages = serializeMessages; this.storeSagaData = storeSagaData; this.inspectHandlerPipeline = inspectHandlerPipeline; this.errorTracker = errorTracker; batch = new RebusBatchOperations(determineDestination, storeSubscriptions, this); routing = new RebusRouting(this); rebusId = Interlocked.Increment(ref rebusIdCounter); log.Info("Rebus bus created"); }
/// <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; nullMessageReceivedBackoffHelper = CreateBackoffHelper(configureAdditionalBehavior.BackoffBehavior); workerThread = new Thread(MainLoop) { Name = workerThreadName }; workerThread.Start(); log.Info("Worker {0} created and inner thread started", WorkerThreadName); }
public virtual SerializationWireup XmlSerializer() { this.messageSerializer = new XmlMessageSerializer(); return this; }
public virtual SerializationWireup BinarySerializer() { this.messageSerializer = new BinaryMessageSerializer(); return this; }
/// <summary> /// Uses the specified implementation of <see cref="ISerializeMessages"/> to serialize transport messages /// </summary> public void Use(ISerializeMessages serializer) { Backbone.SerializeMessages = serializer; }
internal Bus(ISerializeMessages serializer, ISendMessages sender, IPublishEvents publisher) { this.serializer = serializer; this.sender = sender; this.publisher = publisher; }
public virtual SerializationWireup JsonSerializer() { this.messageSerializer = new JsonMessageSerializer(); return this; }
public AzureStorageQueueSendTransport(ISerializeMessages serializer) { this.serializer = serializer; }
public AzureEventHubPublishTransport(ISerializeMessages serializer) { this.serializer = serializer; }
public AzureStorageQueueSendTransportShortMaxDelay(ISerializeMessages serializer) : base(serializer) { this.serializer = serializer; }
public ISubscribeToMessages CreateSubscriber(ISerializeMessages messageSerializer) { return new SubscriberChannel(new EndpointFactory(BufferedFrameReaderFactory.Instance, NullFrameWriterFactory.Instance), messageSerializer); }
public GzipMessageSerializer(ISerializeMessages inner) { this.inner = inner; }
public MessageReceiverForTesting(ISerializeMessages serializer) { this.serializer = serializer; }
public DuplexChannel(ICreateEndpoints endpointFactory, ISerializeMessages messageSerializer) : base(endpointFactory, messageSerializer) { }
public MsmqSenderEndpoint(Func <Uri, MsmqConnector> connectorFactory, ISerializeMessages serializer) { this.connectorFactory = connectorFactory; this.serializer = serializer; }
public SubscriberChannel(ICreateEndpoints endpointFactory, ISerializeMessages messageSerializer) : base(endpointFactory, messageSerializer) { }
public virtual SerializationWireup ProtocolBufferSerializer(params Type[] messageTypes) { this.messageSerializer = new ProtocolBufferSerializer(messageTypes); return this; }
public ISendMessages CreateSender(ISerializeMessages messageSerializer) { return new DuplexChannel(new EndpointFactory(DefaultFrameReaderFactory.Instance, DefaultFrameWriterFactory.Instance), messageSerializer); }
public MsmqSenderEndpoint(Func<Uri, MsmqConnector> connectorFactory, ISerializeMessages serializer) { this.connectorFactory = connectorFactory; this.serializer = serializer; }
public IPublishMessages CreatePublisher(ISerializeMessages messageSerializer) { return new PublisherChannel(new EndpointFactory(NullFrameReaderFactory.Instance, BufferedFrameWriterFactory.Instance), messageSerializer); }
public TransformationMessageSerializer(ISerializeMessages inner, ITransformMessages transformer) { this.transformer = transformer; this.inner = inner; }
public virtual SerializationWireup CustomSerializer(ISerializeMessages serializer) { this.messageSerializer = serializer; return this; }
public virtual SerializationWireup XmlSerializer() { this.messageSerializer = new XmlMessageSerializer(); return(this); }
/// <summary> /// Sends a message to a queue named like the service. /// </summary> public static async Task SendAsync <T>(T input, string serviceName, TimeSpan?initialVisibilityDelay = null, ISerializeMessages serializer = null, ISendMessages sender = null) where T : class { serializer = serializer ?? new JSONSerializer(); sender = sender ?? new AzureStorageQueueSendTransport(serializer); var context = new AFBusMessageContext { MessageID = Guid.NewGuid(), TransactionID = Guid.NewGuid(), BodyType = typeof(T).AssemblyQualifiedName }; if (initialVisibilityDelay != null) { context.MessageDelayedTime = initialVisibilityDelay.Value; context.MessageFinalWakeUpTimeStamp = DateTime.UtcNow + initialVisibilityDelay; } await sender.SendMessageAsync(input, serviceName, context).ConfigureAwait(false); }
public virtual SerializationWireup CustomSerializer(ISerializeMessages serializer) { this.messageSerializer = serializer; return(this); }
public virtual SerializationWireup BinarySerializer() { this.messageSerializer = new BinaryMessageSerializer(); return(this); }
public AzureServiceBusPublishTransport(ISerializeMessages serializer) { this.serializer = serializer; }