Пример #1
0
        /// <summary>
        /// Initialize connections
        ///  - Kafka Consumer
        ///  - Reentrancy to InterSystems IRIS
        /// </summary>
        public override void OnInit()
        {
            LOGINFO("Initialization started");
            var conf = new ConsumerConfig
            {
                GroupId          = "test-consumer-group",
                BootstrapServers = SERVERS,
                // Note: The AutoOffsetReset property determines the start offset in the event
                // there are not yet any committed offsets for the consumer group for the
                // topic/partitions of interest. By default, offsets are committed
                // automatically, so in this example, consumption will only start from the
                // earliest message in the topic 'my-topic' the first time you run the program.
                AutoOffsetReset = AutoOffsetReset.Earliest
            };

            consumer = new ConsumerBuilder <Ignore, string>(conf).Build();

            consumer.Subscribe(TOPIC);

            if (TargetConfigNames != null)
            {
                targets = TargetConfigNames.Split(",");
            }
            iris = GatewayContext.GetIRIS();

            LOGINFO("Initialized!");
        }
        // Write a message that comes from Kafka to a SQL table in IRIS using ObjectScript
        public void processMessage(ConsumeResult <Ignore, string> cr)
        {
            var iris = GatewayContext.GetIRIS();
            var test = (IRISObject)iris.ClassMethodObject("Example.Messages", "%New");

            test.Set("Body", cr.Message.Value);
            test.InvokeVoid("%Save");
        }