Update a consumer group
Modify the timeout period and data consumption order of a consumer group by calling the UpdateConsumerGroup operation.
Prerequisites
-
Simple Log Service is activated. For more information, see Activate Simple Log Service.
-
The Simple Log Service SDK for Python is initialized. For more information, see Initialize Simple Log Service SDK for Python.
Parameter description
def update_consumer_group(self, project, logstore, consumer_group, timeout=None, in_order=None):
Request parameters
|
Parameter |
Type |
Required |
Description |
|
project |
String |
Yes |
The name of the project. |
|
logstore |
String |
Yes |
The name of the logstore. |
|
consumer_group |
String |
Yes |
The name of the consumer group, which must be unique within the logstore. |
|
timeout |
int |
No |
The timeout period, in seconds. If Simple Log Service does not receive a heartbeat from a consumer within this period, the consumer is deleted. Important
Either timeout or in_order must be configured. |
|
in_order |
bool |
No |
Specifies whether to consume data in the order it was written. This parameter affects only the consumption order across shards before and after split or merge operations. Default value: False.
Important
Either timeout or in_order must be configured. |
Response parameters
For information about the response parameters, see UpdateConsumerGroup.
Sample code
from aliyun.log import LogClient
import os
def main():
# In this example, the AccessKey ID and AccessKey Secret are obtained from environment variables.
access_key_id = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
access_key_secret = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
# Specify a Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
client = LogClient(endpoint, access_key_id, access_key_secret)
project = "ali-test-peoject"
logstore = "test-logstore"
consumer_group = "consumer_group_test"
timeout = 30
in_order = False
try:
# Update the consumer group for the specified project.
response = client.update_consumer_group(project, logstore, consumer_group, timeout, in_order)
response.log_print()
except Exception as e:
print(f"An error occurred while updating the consumer group: {e}")
if __name__ == '__main__':
main()
References
-
For more information about log consumption APIs, see the following topics:
-
For more sample code, see Alibaba Cloud Simple Log Service SDK for Python on GitHub.