Files
doc-exports/docs/fg/umn/functiongraph_01_0394.html
liusiying01 904c1aad8b FG UMN 20250526 version
Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com>
Co-authored-by: liusiying01 <liusiying@huawei.com>
Co-committed-by: liusiying01 <liusiying@huawei.com>
2025-10-06 15:14:20 +00:00

67 lines
15 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<a name="functiongraph_01_0394"></a><a name="functiongraph_01_0394"></a>
<h1 class="topictitle1">Using a RocketMQ Trigger</h1>
<div id="body8662426"><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p1040015498279">This section describes how to create a RocketMQ trigger and configure a RocketMQ event to trigger a function. When a DMS (for RocketMQ) trigger is used, FunctionGraph periodically polls for new messages in a specific topic bound to the exchange of a RocketMQ instance and passes the messages as input parameters to invoke functions. </p>
<div class="section" id="functiongraph_01_0394__en-us_topic_0000001896474261_section111911435385"><h4 class="sectiontitle">Prerequisites</h4><ul id="functiongraph_01_0394__en-us_topic_0000001896474261_ul336161217446"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li63618122442">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_0394__en-us_topic_0000001896474261_li62663245617">An agency with VPC management permissions has been configured for the function. For details about how to create an agency, see <a href="functiongraph_01_0920.html#functiongraph_01_0920">Configuring Agency Permissions</a>.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li16361412154420">You have enabled VPC access. For details, see <a href="functiongraph_01_0222.html#functiongraph_01_0222">Configuring Public Access or VPC Access</a>.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li836215126444">A RocketMQ instance has been created..</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li54501346537">The rules of the security group of the instance have been correctly configured.<ol id="functiongraph_01_0394__en-us_topic_0000001896474261_ol1128191120546"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li12801517195416">In the <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b778473551213">Network</strong> section on the <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b1478473517128">Basic Information</strong> tab page, click the name of the security group.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li171284114548">Click the <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b14542154217129">Inbound Rules</strong> tab to view the inbound rules of the security group.<ol type="a" id="functiongraph_01_0394__en-us_topic_0000001896474261_ol5797192213554"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li424661918552">ACL disabled<p id="functiongraph_01_0394__en-us_topic_0000001896474261_p645083415312"><a name="functiongraph_01_0394__en-us_topic_0000001896474261_li424661918552"></a><a name="en-us_topic_0000001896474261_li424661918552"></a>For intra-VPC access, inbound access through port <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b179521955201212">8100</strong> must be allowed.</p>
<p id="functiongraph_01_0394__en-us_topic_0000001896474261_p345018346537">For public access, inbound access through port <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b773776191313">8100</strong> must be allowed.</p>
</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li14640182714556">ACL enabled<p id="functiongraph_01_0394__en-us_topic_0000001896474261_p745023495315"><a name="functiongraph_01_0394__en-us_topic_0000001896474261_li14640182714556"></a><a name="en-us_topic_0000001896474261_li14640182714556"></a>For intra-VPC access, inbound access through port <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b0633121212137">8100</strong> must be allowed.</p>
<p id="functiongraph_01_0394__en-us_topic_0000001896474261_p1245019345535">For public access, inbound access through port <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b66291813131">8200</strong> must be allowed.</p>
</li></ol>
</li></ol>
</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li122115209157">A topic has been created for the RocketMQ instance..</li></ul>
<div class="note" id="functiongraph_01_0394__en-us_topic_0000001896474261_note18223973812"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p282459143814">When <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b17015538147">VPC Access</strong> is enabled for FunctionGraph, ensure that the VPC selected is the same as the VPC selected when the RocketMQ instance is created.</p>
</div></div>
</div>
<div class="section" id="functiongraph_01_0394__en-us_topic_0000001896474261_section1554127182515"><h4 class="sectiontitle">Creating a RocketMQ Trigger</h4><ol id="functiongraph_01_0394__en-us_topic_0000001896474261_ol857163417517"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li4297667312227"><span>Log in to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_en-us_topic_0000001251907924_b033610517502">Functions</strong> &gt; <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_en-us_topic_0000001251907924_b183361950502">Function List</strong>.</span></li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li5124574412227"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0394__li53812137105421"><span>Choose <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b289510228329">Configuration</strong> &gt; <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b156971032183216">Triggers</strong> and click <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b98432283337">Create Trigger</strong>.</span><p><div class="fignone" id="functiongraph_01_0394__en-us_topic_0000001896474261_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_0394__en-us_topic_0000001896474261_en-us_topic_0000001298507405_en-us_topic_0000001251588440_image94621716114320" src="en-us_image_0000001679340817.png" title="Click to enlarge" class="imgResize"></span></div>
</p></li></ol><ol start="4" id="functiongraph_01_0394__en-us_topic_0000001896474261_ol2055214116529"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li65521013529"><span>Set the following parameters:</span><p><ul id="functiongraph_01_0394__en-us_topic_0000001896474261_ul198741610154619"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li178748102466"><strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b917719781517">Trigger Type</strong>: Select <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b121775701510">Distributed Message Service (DMS) for RocketMQ</strong>.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li10874111018462"><strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b41841529181718">Instance</strong>: Select a RocketMQ instance.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li18911952184619"><strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b492133041718">Topic</strong>: Select a topic you created from the drop-down list.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li95961657141417"><strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b197691912161919">Batch Size</strong>: Maximum number of data records that can be obtained a time. Range: 11,000.</li></ul>
</p></li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li13552121125218"><span>Click <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b979816156195">OK</strong>.</span></li></ol>
<div class="note" id="functiongraph_01_0394__en-us_topic_0000001896474261_note987465616514"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="functiongraph_01_0394__en-us_topic_0000001896474261_ul4513174320193"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li17513343161911">After VPC access is enabled, you need to configure corresponding subnet permissions for the RocketMQ security group. For details about how to configure VPC access, see <a href="functiongraph_01_0222.html#functiongraph_01_0222">Configuring Networks</a>.</li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li0928044101916">A newly created RocketMQ trigger is disabled by default. To use it, click <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b1353713710192">Enable</strong>.</li></ul>
</div></div>
</div>
<div class="section" id="functiongraph_01_0394__en-us_topic_0000001896474261_section1555514276256"><h4 class="sectiontitle">Configuring a RocketMQ Event to Trigger the Function</h4><ol id="functiongraph_01_0394__en-us_topic_0000001896474261_ol186121830125219"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li167520531171"><span>Return to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b163651754161911">Functions</strong> &gt; <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b736565451916">Function List</strong>.</span></li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li125612210156"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li65662241519"><span>On the function details page, select a version.</span></li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li109080051212"><span>On the <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b1155403201">Code</strong> tab page, click <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b155517052011">Test</strong>. The <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b75520122010">Configure Test Event</strong> dialog box is displayed.</span></li><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li9686135433718"><span>Set the parameters described in <a href="#functiongraph_01_0394__en-us_topic_0000001896474261_table1255753935319">Table 1</a> and click <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b4757172172010">Save</strong>.</span><p>
<div class="tablenoborder"><a name="functiongraph_01_0394__en-us_topic_0000001896474261_table1255753935319"></a><a name="en-us_topic_0000001896474261_table1255753935319"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_0394__en-us_topic_0000001896474261_table1255753935319" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Test event information</caption><thead align="left"><tr id="functiongraph_01_0394__en-us_topic_0000001896474261_row155581639145317"><th align="left" class="cellrowborder" valign="top" width="18.04%" id="mcps1.3.4.2.5.2.1.2.3.1.1"><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p655815396539">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="81.96%" id="mcps1.3.4.2.5.2.1.2.3.1.2"><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p1155813985316">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="functiongraph_01_0394__en-us_topic_0000001896474261_row1155883975319"><td class="cellrowborder" valign="top" width="18.04%" headers="mcps1.3.4.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p1655833935311">Configure Test Event</p>
</td>
<td class="cellrowborder" valign="top" width="81.96%" headers="mcps1.3.4.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p11558183955319">You can choose to create a test event or edit an existing one.</p>
<p id="functiongraph_01_0394__en-us_topic_0000001896474261_p191634429549">Use the default option <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b4726111442014">Create new test event</strong>.</p>
</td>
</tr>
<tr id="functiongraph_01_0394__en-us_topic_0000001896474261_row8558103985310"><td class="cellrowborder" valign="top" width="18.04%" headers="mcps1.3.4.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p25584397536">Event Template</p>
</td>
<td class="cellrowborder" valign="top" width="81.96%" headers="mcps1.3.4.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p6558173945319">Select <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b372182012204">Distributed Message Service (DMS) for RocketMQ</strong> and use the built-in event template.</p>
</td>
</tr>
<tr id="functiongraph_01_0394__en-us_topic_0000001896474261_row13558739155318"><td class="cellrowborder" valign="top" width="18.04%" headers="mcps1.3.4.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p455863918538">Event Name</p>
</td>
<td class="cellrowborder" valign="top" width="81.96%" headers="mcps1.3.4.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p6558153955317">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_0394__en-us_topic_0000001896474261_b121059283202">kafka-123test</strong>.</p>
</td>
</tr>
<tr id="functiongraph_01_0394__en-us_topic_0000001896474261_row655883945311"><td class="cellrowborder" valign="top" width="18.04%" headers="mcps1.3.4.2.5.2.1.2.3.1.1 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p255893915311">Event data</p>
</td>
<td class="cellrowborder" valign="top" width="81.96%" headers="mcps1.3.4.2.5.2.1.2.3.1.2 "><p id="functiongraph_01_0394__en-us_topic_0000001896474261_p8558173965316">The system automatically loads the built-in RocketMQ event template, which is used in this example without modifications.</p>
</td>
</tr>
</tbody>
</table>
</div>
</p></li></ol><ol start="6" id="functiongraph_01_0394__en-us_topic_0000001896474261_ol115093303539"><li id="functiongraph_01_0394__en-us_topic_0000001896474261_li13510830135319"><span>Click <strong id="functiongraph_01_0394__en-us_topic_0000001896474261_b1765203862019">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">Configuring Triggers</a></div>
</div>
</div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>