liteq: Lightweight Portable Message Queue Using 'SQLite'

Description Concurrency Examples Examples

Description

Message queues for R. Built on top of 'SQLite' databases.

Concurrency

liteq works with multiple producer and/or consumer processes accessing the same queue, via the locking mechanism of 'SQLite'. If a queue is locked by 'SQLite', the process that tries to access it, must wait until it is unlocked. The maximum amount of waiting time is by default 10 seconds, and it can be changed via the R_LITEQ_BUSY_TIMEOUT environment variable, in milliseconds. If you have many concurrent processes using the same liteq database, and see database locked errors, then you can try to increase the timeout value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# We don't run this, because it writes to the cache directory
db <- tempfile()
q <- ensure_queue("jobs", db = db)
q
list_queues(db)

# Publish two messages
publish(q, title = "First message", message = "Hello world!")
publish(q, title = "Second message", message = "Hello again!")
is_empty(q)
message_count(q)
list_messages(q)

# Consume one
msg <- try_consume(q)
msg

ack(msg)
list_messages(q)
msg2 <- try_consume(q)
nack(msg2)
list_messages(q)

# No more messages
is_empty(q)
try_consume(q)

Examples

1
## See the manual page

Example output



liteq documentation built on May 2, 2019, 4:18 a.m.