> For the complete documentation index, see [llms.txt](https://smallso.gitbook.io/tencent-cloud-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/function-trigger/use-message-queue-topic.md).

# use\_message\_queue\_topic 方法

## 简要

配置使用消息队列主题触发器。[什么是消息队列主题触发器？](https://cloud.tencent.com/document/product/583/11517)

```python
def use_message_queue_topic(self,
    topic_name: str,
    topic_instance_id: str = None,
    topic_requirement_context = None
)
```

## 参数

该方法具有以下参数，其参数、参数类型和参数描述如下：

| 参数                          | 类型                                                                                                                                                            | 必选 | 描述                     |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -- | ---------------------- |
| topic\_name                 | str                                                                                                                                                           | 是  | 消息队列主题名称。              |
| topic\_instance\_id         | str                                                                                                                                                           | 否  | 消息队列主题所属的消息队列实例唯一标识符。  |
| topic\_requirement\_context | [MessageQueueTopicTriggerFilter](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/data-types/message-queue-topic-trigger-filter) | 否  | 包含消息队列主题消息过滤描述结构的字典实例。 |

{% hint style="warning" %}
请注意，该方法参数 topic\_instance\_id 和 topic\_requirement\_context 是保留参数，这些参数应始终忽略或设置为 None，否则将引发 NotImplementedError 异常。
{% endhint %}

## 返回值

该方法返回当前代表触发器配置的 [FunctionTrigger](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/function-trigger) 类实例本身。

## 异常

该方法可能会主动引发的异常类型如下：

#### ValueError

参数值或类型不符合预期。

#### NotImplementedError

保留参数被设置为非预期值。

## 示例

下面我们将通过一段 Python 代码向您演示如何使用该方法：

```python
functions.FunctionTrigger.use_message_queue_topic(
    topic_name = 'test-queue-topic'
)
```

## 适用于

#### Tencent Cloud SDK for Python

产品软件包：tencent-cloud-sdk-serverless-functions >= 0.1.1
