void AddPublisherBinding() { if (_publisher != null) return; _publisher = new RabbitMqPublisher(); _connectionHandler.AddBinding(_publisher); }
public PaymentsWriteService(PaymentsRepository paymentsRepository, ILogger <PaymentsWriteService> logger, Mapper mapper, TransactionsWriteClient transactionsClient, LoansWriteClient loansClient, RabbitMqPublisher projectionChannel) { this.paymentsRepository = paymentsRepository; this.logger = logger; this.mapper = mapper; this.transactionsClient = transactionsClient; this.loansClient = loansClient; this.projectionChannel = projectionChannel; }
public PicturesController(Models.AppContext context, RabbitMqPublisher rabbitMqPublisher) { _context = context; _rabbitMqPublisher = rabbitMqPublisher; }
public TransactionsWriteService(TransactionsRepository transactionsRepository, ILogger <TransactionsWriteService> logger, Mapper mapper, RabbitMqPublisher projectionChannel) { this.transactionsRepository = transactionsRepository; this.logger = logger; this.mapper = mapper; this.projectionChannel = projectionChannel; }
static async Task Main(string[] args) { Customer customer = new() { Name = "The Customer", Orders = new() { new() { Id = "order1" }, new() { Id = "order2" }, } }; ConnectionFactory factory = new() { //Uri = "amqp://*****:*****@hostName:port/vhost"; HostName = "localhost", UserName = "******", Password = "******", RequestedHeartbeat = TimeSpan.FromSeconds(15), }; const string exchange = "test_exchange"; const string queuePrefix = "test_queue_"; const string routingKey = "test.message"; using var sub1 = (await RabbitMqSubscriber.CreateAsync(factory, new() { Exchange = exchange, Queue = queuePrefix + "1", RoutingKey = routingKey })) .Subscribe((bytes, isRedelivered) => { string message; Customer customer; if (bytes.Length < 20) { message = Encoding.UTF8.GetString(bytes); } else { customer = Deserialize <Customer>(bytes); message = customer.Name; } Console.WriteLine($"1 -> {message}"); }); using var sub2 = (await RabbitMqSubscriber.CreateAsync(factory, new() { Exchange = exchange, Queue = queuePrefix + "2", RoutingKey = routingKey })) .Subscribe((bytes, isRedelivered) => Handler(bytes, isRedelivered)); using var pub = await RabbitMqPublisher.CreateAsync(factory, new() { Exchange = exchange, RoutingKey = routingKey }); var count = 1; while (true) { try { if (await pub.PublishAsync(Encoding.UTF8.GetBytes($"Message {count}")) && await pub.PublishAsync(Serialize(customer))) { count++; } } catch (Exception e) { } Thread.Sleep(5000); } //Console.ReadKey(); }
public WeatherForecastController(ILogger <WeatherForecastController> logger, RabbitMqPublisher publisher) { _logger = logger; _publisher = publisher; }
public LoansWriteService(LoansRepository loansRepository, ILogger <LoansWriteService> logger, Mapper mapper, PaymentsWriteClient paymentsClient, RabbitMqPublisher projectionChannel) { this.loansRepository = loansRepository; this.logger = logger; this.mapper = mapper; this.paymentsClient = paymentsClient; this.projectionChannel = projectionChannel; }
public PaymentAcceptedEventHandler(RabbitMqPublisher rabbitMqPublisher, ILogger <PaymentAcceptedEventHandler> logger) { _rabbitMqPublisher = rabbitMqPublisher; _logger = logger; }