Esempio n. 1
0
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            subscribeService.Register(queueConfig.SubscribeAssemblies);
            stoppingToken.Register(() =>
            {
                subscribeService.StopSubscribe();
            });

            subscribeService.StartSubscribe(type =>
            {
                return(serviceProvider.GetService(type));
            });
            return(Task.CompletedTask);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var config = new QueueConfig();

            //config.UseRabbitMQ("127.0.0.1", "test", "test");
            //config.UseRedis("[email protected]:6389");
            config.UseMongoDb("mongodb://*****:*****@127.0.0.1:27017/test");
            var client     = new Publisher(config);
            var subService = new SubscribeService(config);

            subService.Register(System.Reflection.Assembly.GetAssembly(typeof(SubscribeTest)));
            subService.StartSubscribe();
label1:
            client.Publish("timeTest", DateTime.Now);
            client.Publish("intTest", DateTime.Now.Second);
            Console.WriteLine("send ok");
            Console.ReadLine();
            goto label1;
        }