Exemplo n.º 1
0
        public async Task Create(bool verifyResponse)
        {
            int          port   = verifyResponse ? 40905 : 40904;
            TestMqServer server = new TestMqServer();

            server.Initialize(port);
            server.Start();

            TmqClient client = new TmqClient();

            client.Connect("tmq://localhost:" + port);

            TmqResponseCode created = await client.CreateQueue("ch-2", MessageA.ContentType, verifyResponse);

            Assert.Equal(TmqResponseCode.Ok, created);
            await Task.Delay(1000);

            Channel channel = server.Server.Channels.FirstOrDefault(x => x.Name == "ch-2");

            Assert.NotNull(channel);

            ChannelQueue queue = channel.Queues.FirstOrDefault();

            Assert.NotNull(queue);
            Assert.Equal(MessageA.ContentType, queue.Id);
        }
Exemplo n.º 2
0
        public async Task CreateWithProperties()
        {
            TestMqServer server = new TestMqServer();

            server.Initialize(41206);
            server.Start();

            TmqClient client = new TmqClient();
            await client.ConnectAsync("tmq://localhost:41206");

            Assert.True(client.IsConnected);

            TmqResponseCode created = await client.CreateQueue("ch-test", MessageA.ContentType, true, o =>
            {
                o.SendOnlyFirstAcquirer = true;
                o.AcknowledgeTimeout    = TimeSpan.FromSeconds(33);
                o.Status = MessagingQueueStatus.Pull;
            });

            Assert.Equal(TmqResponseCode.Ok, created);

            Channel channel = server.Server.FindChannel("ch-test");

            Assert.NotNull(channel);

            ChannelQueue queue = channel.FindQueue(MessageA.ContentType);

            Assert.NotNull(queue);

            Assert.True(queue.Options.SendOnlyFirstAcquirer);
            Assert.Equal(TimeSpan.FromSeconds(33), queue.Options.AcknowledgeTimeout);
            Assert.Equal(QueueStatus.Pull, queue.Status);
        }
Exemplo n.º 3
0
        private void Connected(SocketBase client)
        {
            Console.WriteLine("producer connection established");
            TmqClient tmq = (TmqClient)client;

            if (_firstConnection)
            {
                _firstConnection = false;
                tmq.CreateQueue("BasicChannel", ModelTypes.ProducerEvent, false).Wait();
            }
        }