Beispiel #1
0
 /// <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;
 }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
 /// <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;
 }
Beispiel #4
0
        }        //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
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        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
Beispiel #7
0
 static void SendMessage(ISyncBus bus)
 {
     bus.SendLocal($"Hello there, the time is {DateTime.Now}");
 }
Beispiel #8
0
 public HandlerThatGetsSyncBusInjected(ISyncBus syncBus)
 {
     _syncBus = syncBus;
 }
Beispiel #9
0
 public ShipCreatedDomainEventHandler(ISyncBus bus)
 {
     _bus = bus;
 }