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>
58 lines
13 KiB
HTML
58 lines
13 KiB
HTML
<a name="functiongraph_01_0214"></a><a name="functiongraph_01_0214"></a>
|
|
|
|
<h1 class="topictitle1">Using a Kafka Trigger</h1>
|
|
<div id="body32001227"><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p20317235111217">This section describes how to create a Kafka trigger and configure a Kafka event to trigger a function.</p>
|
|
<p id="functiongraph_01_0214__en-us_topic_0000001298667457_p2088864610557">After a Kafka trigger is used, FunctionGraph periodically polls for new messages in a specific topic in a Kafka instance and passes the messages as input parameters to invoke functions. For details about the DMS for Kafka event source, see section "Supported Event Sources".</p>
|
|
<div class="note" id="functiongraph_01_0214__en-us_topic_0000001298667457_note181663316589"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_01_0214__en-us_topic_0000001298667457_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_0214__en-us_topic_0000001298667457_section134592267445"><h4 class="sectiontitle">Prerequisites</h4><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p244611039529">Before creating a trigger, ensure that you have prepared the following:</p>
|
|
<ul id="functiongraph_01_0214__en-us_topic_0000001298667457_ul10299171374519"><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li518520411145">You have created a function. For details, see <a href="functiongraph_01_0153.html#functiongraph_01_0153">Creating a Function from Scratch</a>.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li2074581653516">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><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li19782151385815">You have created a Kafka instance. For details, see "Creating an Instance" in the <em id="functiongraph_01_0214__en-us_topic_0000001298667457_i12941920152614">Distributed Message Service for Kafka User Guide</em>.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li148271726193212">You have created a topic under a Kafka instance. For details, see section "Creating a Topic" in the <em id="functiongraph_01_0214__en-us_topic_0000001298667457_i1727819500191">Distributed Message Service for Kafka User Guide</em>.</li></ul>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_0214__en-us_topic_0000001298667457_section3956183013126"><h4 class="sectiontitle">Creating a Kafka Trigger</h4><ol id="functiongraph_01_0214__en-us_topic_0000001298667457_ol1451315571315"><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li4297667312227"><span>Log in to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001251907924_b033610517502">Functions</strong> > <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001251907924_b183361950502">Function List</strong>.</span></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li5124574412227"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0214__li53812137105421"><span>Choose <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b289510228329">Configuration</strong> > <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b156971032183216">Triggers</strong> and click <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b98432283337">Create Trigger</strong>.</span><p><div class="fignone" id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001298507405_en-us_topic_0000001251588440_fig546212168431"><span class="figcap"><b>Figure 1 </b>Creating a trigger</span><br><span><img id="functiongraph_01_0214__en-us_topic_0000001298667457_en-us_topic_0000001298507405_en-us_topic_0000001251588440_image94621716114320" src="en-us_image_0000001679340817.png"></span></div>
|
|
</p></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li6898858114818"><span>Set the following parameters:</span><p><ul id="functiongraph_01_0214__en-us_topic_0000001298667457_ul19886115864815"><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li3886165812480"><strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b14231916192416">Trigger Type</strong>: Select <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b542341618245">DMS (for Kafka)</strong>.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li11102312164917"><strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b17062036102416">Instance</strong>: Select a Kafka premium instance.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li143188371495"><strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b14552151110253">Topic</strong>: Select a topic of the Kafka premium instance.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li2081154774920"><strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b1673920916309">Batch Size</strong>: Set the number of messages to be retrieved from a topic each time.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li57376541496"><strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b141031911310">Username</strong>: Enter the username of the instance if SSL has been enabled for it.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li751116145017"><strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b105708155138">Password</strong>: Enter the password of the instance if SSL has been enabled for it.</li></ul>
|
|
</p></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li522552101114"><span>Click <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b194521936132710">OK</strong>.</span><p><div class="note" id="functiongraph_01_0214__en-us_topic_0000001298667457_note98311553266"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="functiongraph_01_0214__en-us_topic_0000001298667457_ul119014587360"><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li13190155819368">After VPC access is enabled, you need to configure corresponding subnet permissions for the Kafka security group. For details about how to configure VPC access, see <a href="functiongraph_01_0222.html#functiongraph_01_0222">Configuring the Network</a>.</li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li1979611643713">You can create a Kafka trigger with multiple topics. You do not need to create one such trigger for each topic in the same instance.<div class="fignone" id="functiongraph_01_0214__en-us_topic_0000001298667457_fig19829161015416"><span class="figcap"><b>Figure 2 </b>Selecting multiple topics</span><br><span><img id="functiongraph_01_0214__en-us_topic_0000001298667457_image582911019419" src="en-us_image_0000001659754612.png"></span></div>
|
|
</li></ul>
|
|
</div></div>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_0214__en-us_topic_0000001298667457_section8958730121211"><h4 class="sectiontitle">Configuring a Kafka Event to Trigger the Function</h4><ol id="functiongraph_01_0214__en-us_topic_0000001298667457_ol1450442693518"><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li8924102413417"><span>Return to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b4124661291523">Functions</strong> > <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b47819407491523">Function List</strong>.</span></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li125612210156"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li65662241519"><span>On the function details page, select a version.</span></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li109080051212"><span>On the <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b19467155115345">Code</strong> tab page, click <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b81852559343">Test</strong>. The <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b14437121613375">Configure Test Event</strong> dialog box is displayed.</span></li><li id="functiongraph_01_0214__en-us_topic_0000001298667457_li9686135433718"><span>Set the parameters described in <a href="#functiongraph_01_0214__en-us_topic_0000001298667457_table15199135171812">Table 1</a> and click <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b10874174015273">Save</strong>.</span><p>
|
|
<div class="tablenoborder"><a name="functiongraph_01_0214__en-us_topic_0000001298667457_table15199135171812"></a><a name="en-us_topic_0000001298667457_table15199135171812"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_0214__en-us_topic_0000001298667457_table15199135171812" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Test event information</caption><thead align="left"><tr id="functiongraph_01_0214__en-us_topic_0000001298667457_row31976510182"><th align="left" class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.3.6.2.5.2.1.2.3.1.1"><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p71977514187">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="72%" id="mcps1.3.6.2.5.2.1.2.3.1.2"><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p8197165171812">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="functiongraph_01_0214__en-us_topic_0000001298667457_row219735171814"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p3197850189">Configure Test Event</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.6.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p819718513189">You can choose to create a test event or edit an existing one.</p>
|
|
<p id="functiongraph_01_0214__en-us_topic_0000001298667457_p019785141810">Use the default option <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b104194975910">Create new test event</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_0214__en-us_topic_0000001298667457_row019845151817"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p1619715519182">Event Template</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.6.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p519812511182">Select <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b7804113654117">DMS (for Kafka)</strong> to use the built-in Kafka event template.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_0214__en-us_topic_0000001298667457_row01981653188"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p619865201814">Event Name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.6.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p1843184212400">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_0214__en-us_topic_0000001298667457_b485614713187">kafka-123test</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_0214__en-us_topic_0000001298667457_row71991752189"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p81983518186">Event data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.6.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0214__en-us_topic_0000001298667457_p1419810515185">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_0214__en-us_topic_0000001298667457_li118163165164"><span>Click <strong id="functiongraph_01_0214__en-us_topic_0000001298667457_b24331802144">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>
|
|
|