应用接口
当你在 Supabase 中创建队列时,你可以选择在 pgmq_public 模式下创建辅助数据库函数。这个模式提供了管理队列消息给客户端的操作,但没有提供创建或删除队列的函数。
🌐 When you create a Queue in Supabase, you can choose to create helper database functions in the pgmq_public schema. This schema exposes operations to manage Queue Messages to consumers client-side, but does not expose functions for creating or dropping Queues.
pgmq_public 中的数据库函数可以通过 Supabase Data API 暴露出来,这样客户端的使用者就可以调用它们。查看 快速入门 获取示例。
🌐 Database functions in pgmq_public can be exposed via Supabase Data API so consumers client-side can call them. Visit the Quickstart for an example.
pgmq_public.pop(queue_name)#
获取下一个可用消息并从指定队列中删除它。
🌐 Retrieves the next available message and deletes it from the specified Queue.
queue_name(text):队列名称
pgmq_public.send(queue_name, message, sleep_seconds)#
向指定队列添加一条消息,并可选择延迟几秒钟才让所有消费者看到。
🌐 Adds a Message to the specified Queue, optionally delaying its visibility to all consumers by a number of seconds.
queue_name(text):队列名称message(jsonb):要发送的消息内容sleep_seconds(integer,可选):将消息显示延迟指定秒数。默认值为 0
pgmq_public.send_batch(queue_name, messages, sleep_seconds)#
将一批消息添加到指定的队列中,并可以选择延迟几秒钟才让所有消费者可用。
🌐 Adds a batch of Messages to the specified Queue, optionally delaying their availability to all consumers by a number of seconds.
queue_name(text):队列名称messages(jsonb[]):要发送的消息载荷数组sleep_seconds(integer,可选):将消息的可见性延迟指定的秒数。默认为 0
pgmq_public.archive(queue_name, message_id)#
通过将消息从队列表移动到队列的存档表来归档消息。
🌐 Archives a Message by moving it from the Queue table to the Queue's archive table.
queue_name(text):队列名称message_id(bigint):要归档的消息ID
pgmq_public.delete(queue_name, message_id)#
从指定队列中永久删除一条消息。
🌐 Permanently deletes a Message from the specified Queue.
queue_name(text):队列名称message_id(bigint):要删除的消息的ID
pgmq_public.read(queue_name, sleep_seconds, n)#
从指定的队列中读取最多“n”条消息,可选择设置“sleep_seconds”(可见性超时)。
🌐 Reads up to "n" Messages from the specified Queue with an optional "sleep_seconds" (visibility timeout).
queue_name(text):队列名称sleep_seconds(integer):可见性超时时间(秒)n(integer):要读取的最大消息数量