## Create a Queue Consumer `queues.consumers.create(strqueue_id, ConsumerCreateParams**kwargs) -> Consumer` **post** `/accounts/{account_id}/queues/{queue_id}/consumers` Creates a new consumer for a Queue ### Parameters - `account_id: str` A Resource identifier. - `queue_id: str` A Resource identifier. - `script_name: str` Name of a Worker - `type: Literal["worker"]` - `"worker"` - `dead_letter_queue: Optional[str]` - `settings: Optional[MqWorkerConsumerRequestSettings]` - `batch_size: Optional[float]` The maximum number of messages to include in a batch. - `max_concurrency: Optional[float]` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `max_retries: Optional[float]` The maximum number of retries - `max_wait_time_ms: Optional[float]` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `retry_delay: Optional[float]` The number of seconds to delay before making the message available for another attempt. ### Returns - `Consumer` Response body representing a consumer - `class MqWorkerConsumerResponse: …` - `consumer_id: Optional[str]` A Resource identifier. - `created_on: Optional[datetime]` - `dead_letter_queue: Optional[str]` Name of the dead letter queue, or empty string if not configured - `queue_name: Optional[str]` - `script_name: Optional[str]` Name of a Worker - `settings: Optional[MqWorkerConsumerResponseSettings]` - `batch_size: Optional[float]` The maximum number of messages to include in a batch. - `max_concurrency: Optional[float]` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `max_retries: Optional[float]` The maximum number of retries - `max_wait_time_ms: Optional[float]` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `retry_delay: Optional[float]` The number of seconds to delay before making the message available for another attempt. - `type: Optional[Literal["worker"]]` - `"worker"` - `class MqHTTPConsumerResponse: …` - `consumer_id: Optional[str]` A Resource identifier. - `created_on: Optional[datetime]` - `dead_letter_queue: Optional[str]` Name of the dead letter queue, or empty string if not configured - `queue_name: Optional[str]` - `settings: Optional[MqHTTPConsumerResponseSettings]` - `batch_size: Optional[float]` The maximum number of messages to include in a batch. - `max_retries: Optional[float]` The maximum number of retries - `retry_delay: Optional[float]` The number of seconds to delay before making the message available for another attempt. - `visibility_timeout_ms: Optional[float]` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `type: Optional[Literal["http_pull"]]` - `"http_pull"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) consumer = client.queues.consumers.create( queue_id="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", script_name="my-consumer-worker", type="worker", ) print(consumer) ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" }, "success": true } ```