summaryrefslogtreecommitdiff
path: root/test.lua
blob: 30ed5eab6a7a14107e0e6d69cd6a68c04483c9f1 (plain) (blame)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/lua

mq = require "mq"

q, err = mq.create("/nownext", "wo", "rw-rw----")
if q == nil then
   print(err)
   return 1
end
print("q created successfully")


result, err = mq.send(q, "hello world1")
if result == nil then
   print(err)
   return 1
end
print("message sent successfully")


result, err = mq.close(q)
if result == nil then
   print(err)
   return 1
end
print("q closed successfully")




q, err = mq.open("/nownext", "rw")
if q == nil then
   print(err)
   return 1
end
print("q opened successfully")


result, err = mq.send(q, "hello world2", 1)
if result == nil then
   print(err)
   return 1
end
print("message sent successfully")

msg, prio = mq.receive(q)
if msg == nil then
   print(prio)
   return 1
end
print("message '" .. msg .. "' received with prio " .. prio)


result, err = mq.close(q)
if result == nil then
   print(err)
   return 1
end
print("q closed successfully")


q, err = mq.open("/nownext", "ro")
if q == nil then
   print(err)
   return 1
end
print("q opened successfully")

msg, prio = mq.receive(q)
if msg == nil then
   print(prio)
   return 1
end
print("message '" .. msg .. "' received with prio " .. prio)


result, err = mq.unlink("/nownext")
if result == nil then
   print(err)
   return 1
end
print("q deleted successfully")


return 0