/// <summary> /// Creates the fake advanced API, using the given implementation(s). All arguments are optional /// </summary> public FakeAdvancedApi(IWorkersApi workers = null, ITopicsApi topics = null, IRoutingApi routing = null, ITransportMessageApi transportMessage = null, IDataBus dataBus = null, ISyncBus syncBus = null) { _workers = workers; _topics = topics; _routing = routing; _transportMessage = transportMessage; _dataBus = dataBus; _syncBus = syncBus; }
static void SendSomeMessages(ISyncBus bus) { var random = RandomFactory.Value; foreach (var str in Enumerable.Range(0, random.Next(1000)).Select(n => $"THIS IS MESSAGE {n % 13}")) { bus.SendLocal(str); } }
} //func public virtual ISyncBus GetConnectionForPublish(string connectionString, string topicName, BuiltinHandlerActivator activator) { string defaultQueue = "default"; Configure .With(activator) .Transport(t => t.UseAzureServiceBus(connectionString, defaultQueue)) .Options(o => o.Decorate <ITopicNameConvention>(bean => new TopicNameResolver(topicName))) .Start(); ISyncBus bus = activator.Bus.Advanced.SyncBus; return(bus); } //func
static void SendSomeMessages(ISyncBus bus) { var now = DateTime.Now; bus.SendLocal($"Outside context msg 1, the time is {now}"); using (var context = new CustomDbContext()) { // send some messages bus.SendLocal($"Custom db context msg 1, the time is {now}"); bus.SendLocal($"Custom db context msg 2, the time is {now}"); bus.SendLocal($"Custom db context msg 3, the time is {now}"); bus.SendLocal($"Custom db context msg 4, the time is {now}"); bus.SendLocal($"Custom db context msg 5, the time is {now}"); context.Commit(); } }
public void SendMessage(object message, string topicName) { using (var tx = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled)) { string connectionString = this.ConnectioString; using (BuiltinHandlerActivator activator = new BuiltinHandlerActivator()) { ISyncBus bus = this.GetConnectionForPublish(connectionString, topicName, activator); string json = JsonSerializer.Serialize(message); FileMessage clienteManagerClienteMessage = new FileMessage(); clienteManagerClienteMessage.Message = json; bus.Publish(clienteManagerClienteMessage); } tx.Complete(); } } //func
static void SendMessage(ISyncBus bus) { bus.SendLocal($"Hello there, the time is {DateTime.Now}"); }
public HandlerThatGetsSyncBusInjected(ISyncBus syncBus) { _syncBus = syncBus; }
public ShipCreatedDomainEventHandler(ISyncBus bus) { _bus = bus; }