public void Dispose() { _tcs.TrySetCanceled(); _bus?.Dispose(); _activator?.Dispose(); GC.SuppressFinalize(this); }
public void Dispose() { if (_disposing || _disposed) { return; } lock (this) { if (_disposing || _disposed) { return; } try { _disposing = true; _adapter.Dispose(); } finally { _disposed = true; _disposing = false; } } }
protected virtual void Dispose(bool disposing) { if (disposing) { _activator?.Dispose(); } _activator = null; }
static async Task Main() { var key = Encoding.UTF8.GetBytes("gdDbqRpqdRbTs3mhdZh9qCaDaxJXl+e6"); Console.Title = "RebusSample"; var directory = Directory.GetParent(Assembly.GetEntryAssembly().Location).FullName; var activator = new BuiltinHandlerActivator(); activator.Register(() => new Handler()); var configurer = Configure.With(activator); var encryptionFactory = new EncryptionFactory(); var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, ContractResolver = encryptionFactory.GetContractResolver() }; configurer.Serialization(s => { s.UseNewtonsoftJson(settings); }); configurer.EnableJsonEncryption( encryptionFactory: encryptionFactory, encryptStateBuilder: () => ( algorithm: new RijndaelManaged { Key = key }, keyId: "1" ), decryptStateBuilder: (keyId, initVector) => new RijndaelManaged { Key = key, IV = initVector }); configurer.Transport(t => { t.UseFileSystem(directory, "RebusSample"); }); var bus = configurer.Start(); Console.WriteLine("Press any key to exit"); await SendMessage(bus) .ConfigureAwait(false); Console.ReadKey(); bus?.Dispose(); encryptionFactory.Dispose(); activator.Dispose(); }
static void Main(string[] args) { Console.WriteLine("Rebus requester application started"); Configuration = LoadConfiguration(); //ExampleWithoutRebusAsync().Wait(); ExampleUsingRebusAsync().Wait(); _bus.Dispose(); _activator.Dispose(); }
public void SendRec() { var input = "1"; var finished = false; using (var adapter = new BuiltinHandlerActivator()) { var y = 0; var z = 0; const int k = 1000; adapter.Handle <Job>(async reply => { await Console.Out.WriteLineAsync( $"Got reply '{reply.data}' "); input = reply.data; if (y == k - 1) { finished = true; } y++; z = z + int.Parse(reply.data); }); Configure.With(adapter) .Logging(l => l.ColoredConsole(minLevel: LogLevel.Warn)) .Routing(r => r.TypeBased().MapAssemblyOf <Job>("consumer.input")) .Transport(t => t.UseKafka("127.0.0.1:9092", "112", "consumer.input")) .Start(); var j = 0; for (var i = 1; i <= k; i++) { adapter.Bus.Send(new Job(i.ToString())).Wait(); j = j + i; } var x = 0; while (!finished) { if (x > 20) { break; } x++; Thread.Sleep(500); } adapter.Dispose(); y.ShouldBe(k); z.ShouldBe(j); } }
public async Task ItWorks() { _busStartTime = DateTime.UtcNow; _rebusConfigurer.Start(); await Task.Delay(TimeSpan.FromSeconds(5)); _activator.Dispose(); Console.WriteLine(@"Receive attempts: {0} Diffs: {1}", string.Join(Environment.NewLine, _waitedSeconds), string.Join(Environment.NewLine, GetDiffs(_waitedSeconds))); }
public ReservationService(string[] commandLineArguments) { this.commandLineArguments = commandLineArguments; if (Adapter != null) { Adapter.Dispose(); } Adapter = new BuiltinHandlerActivator(); Adapter.Register(x => new ReservationHandler(Adapter.Bus)); Configure.With(Adapter) .Transport(x => x.UseRabbitMq(ConnString, Queue)) .Options(o => o.SimpleRetryStrategy(maxDeliveryAttempts: 1, secondLevelRetriesEnabled: true)) .Routing(r => r.TypeBased().MapAssemblyOf <SendTransactionalEmail>("TransactionalEmailQueue")) .Start(); }
static void Main(string[] args) { Console.WriteLine("Rebus responder application started"); Configuration = LoadConfiguration(); _activator = new BuiltinHandlerActivator(); string rabbitMqConnectionString = Configuration.GetConnectionString("RabbitMq"); ConnectToRebus(rabbitMqConnectionString, _activator); // Register handlers for the messages this service must act on. _activator.Handle <UserLoginRequest>(async msg => { await HandleUserLoginRequest(msg); }); _activator.Handle <ServiceConfigurationRequest>(async msg => { await HandleServiceConfigurationRequest(msg); }); // Subscribe to messages we want to handle _bus.Subscribe <UserLoginRequest>().Wait(); _bus.Subscribe <ServiceConfigurationRequest>().Wait(); if (IsRunningInDocker()) { // Never exit in Docker mode new ManualResetEvent(false).WaitOne(); } else { Console.WriteLine("\nPress a key to exit..."); Console.ReadKey(); } _bus.Dispose(); _activator.Dispose(); }
public Task CloseAsync(CancellationToken cancellationToken) { _activator?.Dispose(); return(Task.CompletedTask); }
protected void Application_End() { Activator.Dispose(); }
public void Stop() { ContainerAdapter.Bus.Dispose(); ContainerAdapter.Dispose(); }
public void Dispose() { _activator.Dispose(); }
public override void Shutdown() { //base.Shutdown(); _activator.Bus.Dispose(); _activator.Dispose(); }
public void Dispose() { HandlerActivator.Dispose(); }
public void Dispose() { _activator?.Bus?.Dispose(); _activator?.Dispose(); }
public void CleanUp() { _builtinHandlerActivator.Dispose(); }