readMessageById

This is to just read the message from queue, by given id
parent b45423de
Pipeline #6886 passed with stages
in 5 minutes and 32 seconds
......@@ -27,6 +27,7 @@ module Database.PGMQ.Simple
, purgeQueue
, readMessage
, readMessageFromArchive
, readMessageById
, readMessages
, readMessageWithPoll
, readMessagesWithPoll
......@@ -199,6 +200,15 @@ readMessageFromArchive conn queue msgId = do
[sql| SELECT msg_id, read_ct, enqueued_at, archived_at, vt, message FROM ? WHERE msg_id = ?|]
(PSQL.QualifiedIdentifier (Just "pgmq") $ T.pack archiveTable, msgId) >>= return . headMay
-- | Read a message from queue with given ID (for querying purposes, doesn't pop message from queue)
readMessageById :: (SerializableMessage a)
=> PSQL.Connection -> Queue -> MessageId -> IO (Maybe (Message a))
readMessageById conn queue msgId = do
let queueTable = "q_" <> queue
PSQL.query conn
[sql| SELECT msg_id, read_ct, enqueued_at, NULL, vt, message FROM ? WHERE msg_id = ?|]
(PSQL.QualifiedIdentifier (Just "pgmq") $ T.pack queueTable, msgId) >>= return . headMay
{-| Reads given number of messages from given queue
https://tembo.io/pgmq/api/sql/functions/#read -}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment