Ejemplo n.º 1
0
        public static Message GetMessage(this BusConnection connection, Queue queue)
        {
            using (var channel = connection.ConsumerConnection.CreateModel())
            {
                var result     = channel.BasicGet(queue.Name.Value, false);
                var serializer = new BusSerializer();
                var message    = TestMessage <string> .Create(
                    result,
                    serializer,
                    msg => { },
                    (exception, msg) => { });

                channel.Close();
                return(message);
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            await using (var connection = new SqlConnection("Server=(local);Database=CAP-Test;Trusted_Connection=True;"))
            {
                using var transaction = connection.BeginTransaction(_capPublisher);
                // This is where you would do other work that is going to persist data to your database

                var message = TestMessage.Create($"This is message text created at {DateTime.Now:O}.");

                await _capPublisher.PublishAsync(typeof(TestMessage).FullName, message);

                transaction.Commit();
            }

            return(Content("ok"));
        }