예제 #1
0
    static void Main(string[] args)
    {
      var obj = new RedisTransportMessage()
      {
        Headers = new Dictionary<string, object>
        {
          { "trololol", "lololol" },
          { "derpderp ", new Test2() { Lol = "x" } }
        },
        Body = new Test2
        {
          Lol = "dfdsf"
        }
      };

      var serialized = JsonConvert.SerializeObject(obj);

      var x = JsonConvert.DeserializeObject<RedisTransportMessage>(serialized);

      var bus = new RedisBus("localhost");

      bus.Send(new Test2
      {
        Lol = "herpderp"
      });

      Console.ReadLine();
    }
예제 #2
0
        static void Main(string[] args)
        {
            var obj = new RedisTransportMessage()
            {
                Headers = new Dictionary <string, object>
                {
                    { "trololol", "lololol" },
                    { "derpderp ", new Test2()
                      {
                          Lol = "x"
                      } }
                },
                Body = new Test2
                {
                    Lol = "dfdsf"
                }
            };

            var serialized = JsonConvert.SerializeObject(obj);

            var x = JsonConvert.DeserializeObject <RedisTransportMessage>(serialized);

            var bus = new RedisBus("localhost");

            bus.Send(new Test2
            {
                Lol = "herpderp"
            });

            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var bus = new RedisBus("localhost");

            bus.StartListening();

            Console.ReadLine();
        }
예제 #4
0
    static void Main(string[] args)
    {

      var bus = new RedisBus("localhost");

      bus.StartListening();

      Console.ReadLine();

    }
예제 #5
0
 public SubscribeToRedisCacheSignals(RedisBus redisBus, ICacheSignal cacheSignal)
 {
     _redisBus    = redisBus;
     _cacheSignal = cacheSignal;
 }
예제 #6
0
        static async Task MainAsync()
        {
            var redisConnection = "string";

            var multiplexer = ConnectionMultiplexer.Connect(redisConnection);
            //Initiate the client
            var client = new RedisBus(new RedisConfiguration(redisConnection));

            client.EnableAttachments(new RedisAttachmentProvider(multiplexer, new RedisConfiguration(redisConnection)));

            var knightBusHost = new KnightBusHost()
                                //Enable the Redis Transport
                                .UseTransport(new RedisTransport(redisConnection))
                                .Configure(configuration => configuration
                                           //Enable reading attachments from Redis
                                           .UseRedisAttachments(multiplexer, new RedisConfiguration(redisConnection))
                                           //Enable the saga store
                                           .UseRedisSagaStore(multiplexer, new RedisConfiguration(redisConnection))
                                           //Register our message processors without IoC using the standard provider
                                           .UseDependencyInjection(new StandardDependecyInjection()
                                                                   .RegisterProcessor(new SampleRedisMessageProcessor())
                                                                   .RegisterProcessor(new SampleRedisAttachmentProcessor())
                                                                   .RegisterProcessor(new RedisEventProcessor())
                                                                   .RegisterProcessor(new RedisEventProcessorTwo())
                                                                   .RegisterProcessor(new RedisEventProcessorThree())
                                                                   .RegisterProcessor(new RedisSagaProcessor(client))
                                                                   )
                                           .AddMiddleware(new PerformanceLogging())
                                           );

            //Start the KnightBus Host, it will now connect to the Redis and listen
            await knightBusHost.StartAsync(CancellationToken.None);

            //Start the saga
            await client.SendAsync(new SampleRedisSagaStarterCommand());


            //Send some Messages and watch them print in the console
            var messageCount = 10;
            var sw           = new Stopwatch();

            var commands = Enumerable.Range(0, messageCount).Select(i => new SampleRedisCommand
            {
                Message = $"Hello from command {i}"
            }).ToList();

            sw.Start();
            await client.SendAsync <SampleRedisCommand>(commands);

            Console.WriteLine($"Elapsed {sw.Elapsed}");
            Console.ReadKey();


            //var attachmentCommands = Enumerable.Range(0, 10).Select(i => new SampleRedisAttachmentCommand()
            //{
            //    Message = $"Hello from command with attachment {i}",
            //    Attachment = new MessageAttachment($"file{i}.txt", "text/plain", new MemoryStream(Encoding.UTF8.GetBytes($"this is a stream from Message {i}")))
            //}).ToList();
            //await client.SendAsync<SampleRedisAttachmentCommand>(attachmentCommands);



            //var events = Enumerable.Range(0, 10).Select(i => new SampleRedisEvent
            //{
            //    Message = $"Hello from event {i}"
            //}).ToList();
            //await client.PublishAsync<SampleRedisEvent>(events);
            Console.ReadKey();
        }