forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
61 lines
12 KiB
HTML
61 lines
12 KiB
HTML
<a name="functiongraph_01_1838"></a><a name="functiongraph_01_1838"></a>
|
|
|
|
<h1 class="topictitle1">Using an Open-Source Kafka Trigger</h1>
|
|
<div id="body32001227"><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p196mcpsimp">This section describes how to create an open-source Kafka trigger and configure an event to trigger a function.</p>
|
|
<p id="functiongraph_01_1838__en-us_topic_0000001510377965_p197mcpsimp">If you use an open-source Kafka trigger for a function, FunctionGraph periodically polls messages from a specific topic in Kafka and passes the messages as an input parameter to invoke the function.</p>
|
|
<div class="note" id="functiongraph_01_1838__en-us_topic_0000001510377965_note1644716575555"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p344725714551">For details about the differences between DMS for Kafka and open-source Kafka, see <a href="https://docs.otc.t-systems.com/distributed-message-service/umn/service_overview/comparing_dms_for_kafka_and_open-source_kafka.html#kafka-pd-200720001" target="_blank" rel="noopener noreferrer">Comparing DMS for Kafka and Open-Source Kafka</a>.</p>
|
|
</div></div>
|
|
<div class="section" id="functiongraph_01_1838__en-us_topic_0000001510377965_section198mcpsimp"><h4 class="sectiontitle">Prerequisites</h4><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p200mcpsimp">Before creating a trigger, ensure that you have prepared the following:</p>
|
|
<ul id="functiongraph_01_1838__en-us_topic_0000001510377965_ul201mcpsimp"><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li202mcpsimp">You have created a function.</li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li203mcpsimp">You have enabled VPC access for the function. For details, see <a href="functiongraph_01_0222.html#functiongraph_01_0222">Configuring the Network</a>.</li></ul>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_1838__en-us_topic_0000001510377965_section204mcpsimp"><h4 class="sectiontitle">Creating an Open-Source Kafka Trigger</h4><ol id="functiongraph_01_1838__en-us_topic_0000001510377965_ol206mcpsimp"><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li207mcpsimp"><span>Log in to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b629673154611">Functions</strong> > <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b172961931174619">Function List</strong>.</span></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li209mcpsimp"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li210mcpsimp"><span>Choose <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b1383655013461">Configuration</strong> > <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b383613509465">Triggers</strong> and click <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b138362050154620">Create Trigger</strong>.</span><p><div class="fignone" id="functiongraph_01_1838__en-us_topic_0000001510377965_fig0802435145013"><span class="figcap"><b>Figure 1 </b>Creating a trigger</span><br><span><img id="functiongraph_01_1838__en-us_topic_0000001510377965_image138021035135013" src="en-us_image_0000001630743710.png"></span></div>
|
|
</p></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li213mcpsimp"><span>Set the following parameters:</span><p><ul id="functiongraph_01_1838__en-us_topic_0000001510377965_ul214mcpsimp"><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li215mcpsimp"><strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b965319344717">Trigger Type</strong>: Select <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b116531135472">Kafka (OPENSOURCEKAFKA)</strong>.</li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li216mcpsimp"><strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b456332812472">Connection Address</strong>: Addresses of brokers running Kafka. Separate the addresses with commas (,).</li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li217mcpsimp"><strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b15485193635020">Topic</strong>: Enter one or more topics.</li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li218mcpsimp"><strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b196335295519">Batch Size</strong>: Maximum number of data records that can be processed by the function at a time.</li></ul>
|
|
</p></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li219mcpsimp"><span>Click <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b1263234945118">OK</strong>.</span><p><div class="note" id="functiongraph_01_1838__en-us_topic_0000001510377965_note220mcpsimp"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p221mcpsimp">The network configuration must be the same as that of the ECS where Kafka is deployed, including the VPC and subnet.</p>
|
|
</div></div>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_1838__en-us_topic_0000001510377965_section224mcpsimp"><h4 class="sectiontitle">Enabling a Kafka Trigger</h4><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p226mcpsimp">By default, open-source Kafka triggers are disabled. To use such a trigger, click <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b841965125411">Enable</strong> on the <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b326313319543">Trigger</strong> page.</p>
|
|
<div class="note" id="functiongraph_01_1838__en-us_topic_0000001510377965_note228mcpsimp"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p229mcpsimp">If a trigger cannot be disabled, contact technical support.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_1838__en-us_topic_0000001510377965_section523112114159"><h4 class="sectiontitle">Configuring a Kafka Event to Trigger the Function</h4><ol id="functiongraph_01_1838__en-us_topic_0000001510377965_ol271mcpsimp"><li id="functiongraph_01_1838__en-us_topic_0000001510377965_p230mcpsimp"><span>Return to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b100061956791530">Functions</strong> > <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b92346344191530">Function List</strong>.</span></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li233mcpsimp"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li234mcpsimp"><span>On the function details page, select a version.</span></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li235mcpsimp"><span>On the <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b13205103245615">Code</strong> tab page, click <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b182051324568">Test</strong>. The <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b192051032195619">Configure Test Event</strong> dialog box is displayed.</span></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li236mcpsimp"><span>Set the parameters described in <a href="#functiongraph_01_1838__en-us_topic_0000001510377965__table15199135171812">Table 1</a> and click <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b24267572002">Save</strong>.</span><p>
|
|
<div class="tablenoborder"><a name="functiongraph_01_1838__en-us_topic_0000001510377965__table15199135171812"></a><a name="en-us_topic_0000001510377965__table15199135171812"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_1838__en-us_topic_0000001510377965__table15199135171812" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Test event information</caption><thead align="left"><tr id="functiongraph_01_1838__en-us_topic_0000001510377965_row243mcpsimp"><th align="left" class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.3.7.2.5.2.1.2.3.1.1"><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p245mcpsimp">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="72%" id="mcps1.3.7.2.5.2.1.2.3.1.2"><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p247mcpsimp">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="functiongraph_01_1838__en-us_topic_0000001510377965_row249mcpsimp"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.7.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p251mcpsimp">Configure Test Event</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.7.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p253mcpsimp">You can choose to create a test event or edit an existing one.</p>
|
|
<p id="functiongraph_01_1838__en-us_topic_0000001510377965_p254mcpsimp">Use the default option <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b746410178114">Create new test event</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_1838__en-us_topic_0000001510377965_row255mcpsimp"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.7.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p257mcpsimp">Event Template</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.7.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p259mcpsimp">Select <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b1427132117117">Kafka (OPENSOURCEKAFKA)</strong> to use the built-in Kafka event template.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_1838__en-us_topic_0000001510377965_row260mcpsimp"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.7.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p262mcpsimp">Event Name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.7.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p264mcpsimp">The event name can contain 1 to 25 characters and must start with a letter and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. For example, <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b556010267118">kafka-123test</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_1838__en-us_topic_0000001510377965_row265mcpsimp"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.7.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p267mcpsimp">Event data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.7.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_1838__en-us_topic_0000001510377965_p269mcpsimp">The system automatically loads the built-in Kafka event template, which is used in this example without modifications.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</p></li><li id="functiongraph_01_1838__en-us_topic_0000001510377965_li270mcpsimp"><span>Click <strong id="functiongraph_01_1838__en-us_topic_0000001510377965_b1048034711819">Test</strong>. The function test result is displayed.</span></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_01_0200.html">Creating Triggers</a></div>
|
|
</div>
|
|
</div>
|
|
|