forked from docs/doc-exports
Reviewed-by: Antonova, Ekaterina <ekantono@noreply.gitea.eco.tsi-dev.otc-service.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
50 lines
7.6 KiB
HTML
50 lines
7.6 KiB
HTML
<a name="kafka_ug_0046"></a><a name="kafka_ug_0046"></a>
|
|
|
|
<h1 class="topictitle1">Deleting Kafka Messages</h1>
|
|
<div id="body0000001671590185"><div class="section" id="kafka_ug_0046__section692118296401"><h4 class="sectiontitle">Scenario</h4><p id="kafka_ug_0046__p810185372517">This section describes how to delete messages on the console.</p>
|
|
<div class="notice" id="kafka_ug_0046__note1788513120261"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="kafka_ug_0046__p138851117268">Deleted messages cannot be recovered.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="kafka_ug_0046__section48141432610"><h4 class="sectiontitle">Prerequisites</h4><p id="kafka_ug_0046__p11949181715269">Before deleting a message, set the <strong id="kafka_ug_0046__b8684411889">auto.offset.reset</strong> parameter in the code of consumption. <strong id="kafka_ug_0046__b174819461581">auto.offset.reset</strong> specifies the consumption policy of a consumer when there is no initial offset in Kafka or the current offset does not exist (for example, the current offset has been deleted). Options:</p>
|
|
<ul id="kafka_ug_0046__ul1377172718324"><li id="kafka_ug_0046__li8777271321"><strong id="kafka_ug_0046__b151671843687">latest</strong>: The offset is automatically reset to the latest offset.</li><li id="kafka_ug_0046__li172238433324"><strong id="kafka_ug_0046__b114171839985">earliest</strong>: The offset is automatically reset to the earliest offset.</li><li id="kafka_ug_0046__li264015812324"><strong id="kafka_ug_0046__b1792336181">none</strong>: The system throws an exception to the consumer.</li></ul>
|
|
<div class="notice" id="kafka_ug_0046__note4165350105310"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="kafka_ug_0046__p142211837185315">If this parameter is set to <strong id="kafka_ug_0046__b169143628135637">latest</strong>, the producer may start to send messages to new partitions (if any) before the consumer resets to the initial offset. As a result, some messages will be lost.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="kafka_ug_0046__section13940195114017"><h4 class="sectiontitle">Deleting Kafka Messages</h4><ol id="kafka_ug_0046__ol52571237194117"><li id="kafka_ug_0046__li10427115412419"><span>Log in to the console.</span></li><li id="kafka_ug_0046__li14905725134512"><span>Click <span><img id="kafka_ug_0046__kafka-ug-180604014_image129423217218" src="en-us_image_0143929918.png"></span> in the upper left corner to select a region.</span><p><div class="note" id="kafka_ug_0046__kafka-ug-180604014_note596412409275"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="kafka_ug_0046__kafka-ug-180604014_p11964174020277">Select the region where your Kafka instance is located.</p>
|
|
</div></div>
|
|
</p></li><li id="kafka_ug_0046__li189561034172215"><span>Click <strong id="kafka_ug_0046__b29186616635637">Service List</strong> and choose <strong id="kafka_ug_0046__b166553178635637">Application</strong> > <strong id="kafka_ug_0046__b100693343035637">Distributed Message Service</strong>. The Kafka instance list is displayed.</span></li><li id="kafka_ug_0046__li1489192711531"><span>Click the desired Kafka instance to view its details.</span></li><li id="kafka_ug_0046__li359717710439"><span>In the navigation pane, choose <strong id="kafka_ug_0046__b46984610919">Topics</strong>.</span></li><li id="kafka_ug_0046__li3204724441"><span>Perform either of the following steps to display the <strong id="kafka_ug_0046__b91494918258">Delete Message</strong> dialog box:</span><p><ul id="kafka_ug_0046__ul6202524944"><li id="kafka_ug_0046__li17648629047">If ciphertext access has not been enabled for the instance, click <strong id="kafka_ug_0046__b111192362613">Delete Messages</strong> in the row that contains the topic whose messages you want to delete.</li><li id="kafka_ug_0046__li12202724247">If ciphertext access has been enabled for the instance, choose <strong id="kafka_ug_0046__b14483191692617">More</strong> > <strong id="kafka_ug_0046__b1448391642610">Delete Messages</strong> in the row that contains the topic whose messages you want to delete.</li></ul>
|
|
</p></li><li id="kafka_ug_0046__li17980512511"><span>Set the parameters for deleting messages, as shown in <a href="#kafka_ug_0046__table10182314115320">Table 1</a>.</span><p><div class="fignone" id="kafka_ug_0046__fig63101639173614"><span class="figcap"><b>Figure 1 </b>Deleting messages</span><br><span><img id="kafka_ug_0046__image44932354564" src="en-us_image_0000001781630389.png"></span></div>
|
|
|
|
<div class="tablenoborder"><a name="kafka_ug_0046__table10182314115320"></a><a name="table10182314115320"></a><table cellpadding="4" cellspacing="0" summary="" id="kafka_ug_0046__table10182314115320" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters for deleting a message</caption><thead align="left"><tr id="kafka_ug_0046__row2182314165314"><th align="left" class="cellrowborder" valign="top" width="24.05%" id="mcps1.3.3.2.7.2.2.2.3.1.1"><p id="kafka_ug_0046__p12182121414531">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="75.94999999999999%" id="mcps1.3.3.2.7.2.2.2.3.1.2"><p id="kafka_ug_0046__p1418271485320">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="kafka_ug_0046__row91821714115311"><td class="cellrowborder" valign="top" width="24.05%" headers="mcps1.3.3.2.7.2.2.2.3.1.1 "><p id="kafka_ug_0046__p1518241419531">Partition</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="75.94999999999999%" headers="mcps1.3.3.2.7.2.2.2.3.1.2 "><p id="kafka_ug_0046__p14182151445310">Select the ID of the partition where the message is located.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="kafka_ug_0046__row8182181425314"><td class="cellrowborder" valign="top" width="24.05%" headers="mcps1.3.3.2.7.2.2.2.3.1.1 "><p id="kafka_ug_0046__p9182101435319">Offset</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="75.94999999999999%" headers="mcps1.3.3.2.7.2.2.2.3.1.2 "><p id="kafka_ug_0046__p418241419532">Enter the offset. Data before this offset will be deleted.</p>
|
|
<div class="note" id="kafka_ug_0046__note575445418593"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="kafka_ug_0046__ul5179459193612"><li id="kafka_ug_0046__li1017955915364">If <strong id="kafka_ug_0046__b59041462316">Offset</strong> is set to <strong id="kafka_ug_0046__b126421711132318">-1</strong>, all messages in the partition will be deleted.</li><li id="kafka_ug_0046__li33651628113716">If the offset you entered is not between the earliest offset and the latest offset of the specified partition, no messages will be deleted.</li></ul>
|
|
</div></div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p id="kafka_ug_0046__p723175873314">To delete messages from multiple partitions, click <strong id="kafka_ug_0046__b818574112276">Add Partition</strong> and specify the partition and offset for the messages to be deleted. 10 partitions can be deleted at most at a time.</p>
|
|
</p></li><li id="kafka_ug_0046__li5992081534"><span>Click <strong id="kafka_ug_0046__b11502141714306">OK</strong>. The <strong id="kafka_ug_0046__b19305535173015">Deletion Result</strong> dialog box is displayed. Click <strong id="kafka_ug_0046__b3589183963015">OK</strong> to delete the messages.</span><p><div class="fignone" id="kafka_ug_0046__fig976244011522"><span class="figcap"><b>Figure 2 </b>Deletion result</span><br><span><img id="kafka_ug_0046__image187622408528" src="en-us_image_0000001803937277.png"></span></div>
|
|
</p></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="kafka-ug-0720002.html">Managing Messages</a></div>
|
|
</div>
|
|
</div>
|
|
|