static void Main(string[] args) { var container = new TinyIoCContainer(); var messageMapperFactory = new TinyIoCMessageMapperFactory(container); var messageMapperRegistry = new MessageMapperRegistry(messageMapperFactory) { { typeof(GreetingEvent), typeof(GreetingEventMessageMapper) } }; var messageStore = new InMemoryMessageStore(); var redisConnection = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTImeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; var producer = new RedisMessageProducer(redisConnection); var builder = CommandProcessorBuilder.With() .Handlers(new HandlerConfiguration()) .DefaultPolicy() .TaskQueues(new MessagingConfiguration(messageStore, producer, messageMapperRegistry)) .RequestContextFactory(new InMemoryRequestContextFactory()); var commandProcessor = builder.Build(); commandProcessor.Post(new GreetingEvent("Ian")); }
public RedisMessageConsumerTimeoutOnGetClient( RedisMessagingGatewayConfiguration redisMessagingGatewayConfiguration, string queueName, string topic) : base(redisMessagingGatewayConfiguration, queueName, topic) { }
public RedisMessageProducerSendTests() { var configuration = new RedisMessagingGatewayConfiguration { ServerList = "localhost", AllowAdmin = false, ConnectRetry = 3, ConnectTimeout = 5000, Proxy = Proxy.None, SyncTimeout = 1000 }; var options = ConfigurationOptions.Parse(configuration.ServerList); options.AllowAdmin = configuration.AllowAdmin; options.ConnectRetry = configuration.ConnectRetry; options.ConnectTimeout = configuration.ConnectTimeout; options.SyncTimeout = configuration.SyncTimeout; options.Proxy = configuration.Proxy; var connectionMultiplexer = ConnectionMultiplexer.Connect(options); _messageProducer = new RedisMessageProducer(connectionMultiplexer); _messageConsumer = new RedisMessageConsumer(connectionMultiplexer, QueueName, Topic); _message = new Message( new MessageHeader(Guid.NewGuid(), Topic, MessageType.MT_COMMAND), new MessageBody("test content") ); }
public RedisFixture() { RedisMessagingGatewayConfiguration configuration = RedisMessagingGatewayConfiguration(); MessageProducer = new RedisMessageProducer(configuration); MessageConsumer = new RedisMessageConsumer(configuration, QueueName, Topic); }
private static IHostBuilder CreateHostBuilder(string[] args) => new HostBuilder() .ConfigureServices((context, collection) => { var redisConnection = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTimeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; collection.AddBrighter() .UseInMemoryOutbox() .UseExternalBus(new RedisProducerRegistryFactory( redisConnection, new RedisMessagePublication[] { new RedisMessagePublication { Topic = new RoutingKey("greeting.event") } } ).Create()) .AutoFromAssemblies(); });
private static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext() .WriteTo.Console() .CreateLogger(); var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <ILoggerFactory>(new SerilogLoggerFactory()); var redisConnection = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTimeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; var producer = new RedisMessageProducer(redisConnection); serviceCollection.AddBrighter(options => { var outBox = new InMemoryOutbox(); options.BrighterMessaging = new BrighterMessaging(outBox, producer); }).AutoFromAssemblies(); var serviceProvider = serviceCollection.BuildServiceProvider(); var commandProcessor = serviceProvider.GetService <IAmACommandProcessor>(); commandProcessor.Post(new GreetingEvent("Ian")); }
public RmqMessageConsumerOperationInterruptedTests() { var configuration = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTImeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; _messageConsumer = new RedisMessageConsumer(configuration, QueueName, Topic); }
public RmqMessageConsumerRedisNotAvailableTests() { var configuration = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTImeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; _messageConsumer = new RedisMessageConsumerSocketErrorOnGetClient(configuration, QueueName, Topic); }
public static RedisMessagingGatewayConfiguration RedisMessagingGatewayConfiguration() { var configuration = new RedisMessagingGatewayConfiguration { RedisConnectionString = "redis://localhost:6379?ConnectTimeout=1000&SendTimeout=1000", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10), DefaultRetryTimeout = 3000 }; return(configuration); }
public static async Task Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext() .WriteTo.Console() .CreateLogger(); var host = new HostBuilder() .ConfigureServices((hostContext, services) => { var subscriptions = new Subscription[] { new Subscription <GreetingEvent>( new SubscriptionName("paramore.example.greeting"), new ChannelName("greeting.event"), new RoutingKey("greeting.event"), timeoutInMilliseconds: 200) }; //create the gateway var redisConnection = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTImeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; var redisConsumerFactory = new RedisMessageConsumerFactory(redisConnection); services.AddServiceActivator(options => { options.Subscriptions = subscriptions; options.ChannelFactory = new ChannelFactory(redisConsumerFactory); }) .UseInMemoryOutbox() .UseExternalBus(new RedisMessageProducer(redisConnection)) .AutoFromAssemblies(); services.AddHostedService <ServiceActivatorHostedService>(); }) .UseConsoleLifetime() .UseSerilog() .Build(); await host.RunAsync(); }
public RedisMessageProducerSendTests() { var configuration = new RedisMessagingGatewayConfiguration { ServerList = "localhost", AllowAdmin = false, ConnectRetry = 3, ConnectTimeout = 5000, Proxy = Proxy.None, SyncTimeout = 1000 }; _messageProducer = new RedisMessageProducer(configuration); _messageConsumer = new RedisMessageConsumer(configuration, QueueName, Topic); _message = new Message(new MessageHeader(Guid.NewGuid(), Topic, MessageType.MT_COMMAND), new MessageBody("test content")); }
public RedisMessageProducerSendTests() { var configuration = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTImeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; _messageProducer = new RedisMessageProducer(configuration); _messageConsumer = new RedisMessageConsumer(configuration, QueueName, Topic); _message = new Message( new MessageHeader(Guid.NewGuid(), Topic, MessageType.MT_COMMAND), new MessageBody("test content") ); }
public void When_overriding_client_configuration_via_the_gateway() { var configuration = new RedisMessagingGatewayConfiguration { BackoffMultiplier = 5, BufferLength = 4096, BufferPoolMaxSize = 1024, DeactivatedClientsExpiry = TimeSpan.Zero, DefaultConnectTimeout = 10, DefaultIdleTimeOutSecs = 360, DefaultReceiveTimeout = 30, DefaultRetryTimeout = 10, DefaultSendTimeout = 10, DisableVerboseLogging = false, HostLookupTimeoutMs = 400, MaxPoolSize = 50, MessageTimeToLive = TimeSpan.FromMinutes(30), VerifyMasterConnections = false }; var gateway = new TestRedisGateway(configuration); //Redis Config is static, so we can just look at the values we should have initialized RedisConfig.BackOffMultiplier.Should().Be(configuration.BackoffMultiplier.Value); RedisConfig.BufferLength.Should().Be(configuration.BufferLength.Value); RedisConfig.BackOffMultiplier.Should().Be(configuration.BackoffMultiplier.Value); RedisConfig.DeactivatedClientsExpiry.Should().Be(configuration.DeactivatedClientsExpiry.Value); RedisConfig.DefaultConnectTimeout.Should().Be(configuration.DefaultConnectTimeout.Value); RedisConfig.DefaultIdleTimeOutSecs.Should().Be(configuration.DefaultIdleTimeOutSecs.Value); RedisConfig.DefaultReceiveTimeout.Should().Be(configuration.DefaultReceiveTimeout.Value); RedisConfig.DefaultSendTimeout.Should().Be(configuration.DefaultSendTimeout.Value); RedisConfig.DisableVerboseLogging.Should().Be(configuration.DisableVerboseLogging.Value); RedisConfig.HostLookupTimeoutMs.Should().Be(configuration.HostLookupTimeoutMs.Value); RedisConfig.DefaultMaxPoolSize.Should().Be(configuration.MaxPoolSize.Value); gateway.MessageTimeToLive.Should().Be(configuration.MessageTimeToLive.Value); RedisConfig.VerifyMasterConnections.Should().Be(configuration.VerifyMasterConnections.Value); }
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .WriteTo.LiterateConsole() .CreateLogger(); var container = new TinyIoCContainer(); var handlerFactory = new TinyIocHandlerFactory(container); var messageMapperFactory = new TinyIoCMessageMapperFactory(container); container.Register <IHandleRequests <GreetingEvent>, GreetingEventHandler>(); var subscriberRegistry = new SubscriberRegistry(); subscriberRegistry.Register <GreetingEvent, GreetingEventHandler>(); //create policies var retryPolicy = Policy .Handle <Exception>() .WaitAndRetry(new[] { TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(150) }); var circuitBreakerPolicy = Policy .Handle <Exception>() .CircuitBreaker(1, TimeSpan.FromMilliseconds(500)); var policyRegistry = new PolicyRegistry { { CommandProcessor.RETRYPOLICY, retryPolicy }, { CommandProcessor.CIRCUITBREAKER, circuitBreakerPolicy } }; //create message mappers var messageMapperRegistry = new MessageMapperRegistry(messageMapperFactory) { { typeof(GreetingEvent), typeof(GreetingEventMessageMapper) } }; //create the gateway var redisConnection = new RedisMessagingGatewayConfiguration { RedisConnectionString = "localhost:6379?connectTimeout=1&sendTImeout=1000&", MaxPoolSize = 10, MessageTimeToLive = TimeSpan.FromMinutes(10) }; var redisConsumerFactory = new RedisMessageConsumerFactory(redisConnection); var dispatcher = DispatchBuilder.With() .CommandProcessor(CommandProcessorBuilder.With() .Handlers(new HandlerConfiguration(subscriberRegistry, handlerFactory)) .Policies(policyRegistry) .NoTaskQueues() .RequestContextFactory(new InMemoryRequestContextFactory()) .Build()) .MessageMappers(messageMapperRegistry) .DefaultChannelFactory(new InputChannelFactory(redisConsumerFactory)) .Connections(new Connection[] { new Connection <GreetingEvent>( new ConnectionName("paramore.example.greeting"), new ChannelName("greeting.event"), new RoutingKey("greeting.event"), timeoutInMilliseconds: 200) }).Build(); dispatcher.Receive(); Console.WriteLine("Press Enter to stop ..."); Console.ReadLine(); dispatcher.End().Wait(); }
/// <summary> /// Initializes a new instance of the <see cref="RmqMessageConsumerFactory"/> class. /// </summary> public RedisMessageConsumerFactory(RedisMessagingGatewayConfiguration configuration) { _configuration = configuration; }
public TestRedisGateway(RedisMessagingGatewayConfiguration redisMessagingGatewayConfiguration) : base(redisMessagingGatewayConfiguration) { OverrideRedisClientDefaults(); }
public RedisMessageConsumer(RedisMessagingGatewayConfiguration configuration, string queueName, string topic) { throw new System.NotImplementedException(); }