UNPKG

node-red-contrib-rdkafka

Version:

Node-Red module for Apache Kafka publish/subscribe using the Confluent librdkafka C library

135 lines (123 loc) 5.97 kB
<script type="text/x-red" data-template-name="rdkafka in"> <div class="form-row"> <label for="node-input-broker"><i class="icon-tag"></i> Broker</label> <input type="text" id="node-input-broker"> </div> <div class="form-row"> <label for="node-input-topic"><i class="icon-tasks"></i> Topic</label> <input type="text" id="node-input-topic" placeholder="Topic"> </div> <div class="form-row"> <label for="node-input-cgroup"><i class="icon-tasks"></i> Group ID</label> <input type="text" id="node-input-cgroup" placeholder="Group ID"> </div> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="rdkafka in"> <p>Kafka input node. Connects to a broker and subscribes to the specified topic. The topic may contain Kafka wildcard regular expression. </script> <script type="text/javascript"> RED.nodes.registerType('rdkafka in',{ category: 'input', defaults: { name: {value:""}, topic: {value:"",required:true}, cgroup: {value:"node-red-rdkafka"}, autocommit: {value:true, required:true}, broker: {type:"kafka-broker", required:true} }, color:"#FFFFFF", inputs:0, outputs:1, icon: "kafka.png", label: function() { return this.name||this.topic||"rdkafka"; }, labelStyle: function() { return this.name?"node_label_italic":""; } }); </script> <script type="text/x-red" data-template-name="rdkafka out"> <div class="form-row"> <label for="node-input-broker"><i class="icon-tag"></i> Broker</label> <input type="text" id="node-input-broker"> </div> <div class="form-row"> <label for="node-input-topic"><i class="icon-tasks"></i> Topic</label> <input type="text" id="node-input-topic" placeholder="Topic"> </div> <div class="form-row"> <label for="node-input-key"><i class="icon-tasks"></i> Key</label> <input type="text" id="node-input-key" placeholder="Key"> </div> <div class="form-row"> <label for="node-input-partition"><i class="icon-tasks"></i> Partition</label> <input type="number" id="node-input-partition" placeholder="Partition"> </div> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="rdkafka out"> <p>Connects to a Kafka broker and publishes messages. <p>If you want to publish Kafka messages in Key,Value format then either specify a static key value in the config dialog or (if blank) include a key string in the incoming <code>msg.key</code> field <p>The Kafka topic to which messages are published can be specified as a static topic value in the config dialog or (if blank) included as a topic string in the incoming <code>msg.topic</code> field <p>The Kafka partition to which messages are published can be specified as a static partition value in the config dialog or (if set to -1) included as a topic string in the incoming <code>msg.partition</code> field. If no partition is specified via either method then the default (round robin) Kafka partitioner is used. <p>If you provide a valid timestamp by using the <code>msg.timestamp</code> field it will be added to the message as the event time, otherwise the current publish time will be used. <p>If any values are set in both the configuration window and in the incoming message, then the configuration dialog value has precedence. <p>The output of this node includes key_schema_id, value and <code>offsets</code> which is an array of objects containing the partition, offset, error_code, and error for each of the messages published. For example <code>{ offsets: [ { partition: 0, offset: 1071, error_code: null, error: null } ], key_schema_id: null, value_schema_id: null }</code> </script> <script type="text/javascript"> RED.nodes.registerType('rdkafka out',{ category: 'output', defaults: { name: {value:""}, topic: {value:""}, key: {value:""}, partition: {value:-1}, broker: {type:"kafka-broker", required:true} }, color:"#FFFFFF", inputs:1, outputs:0, icon: "kafka.png", align: "right", label: function() { return this.name||this.topic||"rdkafka"; }, labelStyle: function() { return this.name?"node_label_italic":""; } }); </script> <script type="text/x-red" data-template-name="kafka-broker"> <div class="form-row node-input-broker"> <label for="node-config-input-broker"><i class="icon-bookmark"></i> Broker List</label> <input class="input-append-left" type="text" id="node-config-input-broker" placeholder="localhost:9092" style="width: 40%;" > </div> <div class="form-row"> <label for="node-config-input-clientid"><i class="icon-tag"></i> Client ID</label> <input type="text" id="node-config-input-clientid" placeholder="Leave blank for auto generated"> </div> <div class="form-tips"> <b>Note:</b>The "Broker List" is a list of Kafka Brokers in the form HOST1:PORT1[,HOST2:PORT2[...]] </div> </script> <script type="text/javascript"> RED.nodes.registerType('kafka-broker', { category: 'config', defaults: { broker: { value:"",required:true }, clientid: { value:"" } }, label: function() { if (this.broker == "") { this.broker = "localhost:9092"; } return (this.clientid?this.clientid+"@":"")+this.broker; } }); </script>