public void ProductionExceptionFatalHandlerFailTest()
        {
            bool errorState = false;
            var  _return    = new List <KeyValuePair <string, string> >();
            var  config     = new StreamConfig <StringSerDes, StringSerDes>();
            var  dt         = DateTime.Now;
            var  timeout    = TimeSpan.FromSeconds(10);

            config.ApplicationId               = "test";
            config.BootstrapServers            = "127.0.0.1";
            config.PollMs                      = 10;
            config.ProductionExceptionHandler += (r) => ExceptionHandlerResponse.FAIL;

            var options = new ProducerSyncExceptionOptions {
                IsFatal = true
            };
            var supplier = new ProducerSyncException(options);

            var builder = new StreamBuilder();

            builder
            .Stream <string, string>("test")
            .To("test-output");

            builder.Stream <string, string>("test-output")
            .Peek((k, v) => _return.Add(KeyValuePair.Create(k, v)));

            var t = builder.Build();

            using (var driver = new TopologyTestDriver(t.Builder, config,
                                                       TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY, supplier))
            {
                var inputtopic = driver.CreateInputTopic <string, string>("test");
                inputtopic.PipeInput("coucou");
                inputtopic.PipeInput("coucou");
                while (!errorState)
                {
                    errorState = driver.IsError;
                    Thread.Sleep(10);
                    if (DateTime.Now > dt + timeout)
                    {
                        break;
                    }
                }

                Assert.IsTrue(driver.IsError);
            }

            Assert.AreEqual(new List <KeyValuePair <string, string> >(), _return);
        }
        public void ProductionExceptionRecoverableHandlerFailTest()
        {
            var _return = new List <KeyValuePair <string, string> >();
            var config  = new StreamConfig <StringSerDes, StringSerDes>();
            var dt      = DateTime.Now;
            var timeout = TimeSpan.FromSeconds(10);

            config.ApplicationId               = "test";
            config.BootstrapServers            = "127.0.0.1";
            config.PollMs                      = 10;
            config.ProductionExceptionHandler += (r) => ExceptionHandlerResponse.FAIL;

            var options = new ProducerSyncExceptionOptions {
                IsRecoverable = true
            };
            var supplier = new ProducerSyncException(options);

            var builder = new StreamBuilder();

            builder
            .Stream <string, string>("test")
            .To("test-output");

            builder.Stream <string, string>("test-output")
            .Peek((k, v) => _return.Add(KeyValuePair.Create(k, v)));

            var t = builder.Build();

            using (var driver = new TopologyTestDriver(t.Builder, config,
                                                       TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY, supplier))
            {
                var inputtopic  = driver.CreateInputTopic <string, string>("test");
                var outputTopic = driver.CreateOuputTopic <string, string>("test-output");
                inputtopic.PipeInput("coucou");
                inputtopic.PipeInput("coucou");
                while (_return.Count == 0)
                {
                    ;
                }
                var expected = new List <KeyValuePair <string, string> >();
                expected.Add(KeyValuePair.Create <string, string>(null, "coucou"));
                Assert.AreEqual(expected, _return);
            }
        }
 public KafkaProducerException(SyncProducer syncProducer, ProducerSyncExceptionOptions options)
     : this(syncProducer)
 {
     this.options = options;
 }
 public ProducerSyncException(ProducerSyncExceptionOptions options)
 {
     this.options = options;
 }