README 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. mqueue Module
  2. Elena-Ramona Modroiu
  3. asipto.com
  4. Edited by
  5. Elena-Ramona Modroiu
  6. <[email protected]>
  7. Edited by
  8. Alex Balashov
  9. Evariste Systems
  10. <[email protected]>
  11. Copyright © 2010 Elena-Ramona Modroiu (asipto.com)
  12. __________________________________________________________________
  13. Table of Contents
  14. 1. Admin Guide
  15. 1. Overview
  16. 2. Dependencies
  17. 2.1. Kamailio Modules
  18. 2.2. External Libraries or Applications
  19. 3. Parameters
  20. 3.1. mqueue (string)
  21. 4. Functions
  22. 4.1. mq_add(queue, key, value)
  23. 4.2. mq_fetch(queue)
  24. 4.3. mq_pv_free(queue)
  25. 4.4. mq_size(queue)
  26. 5. Exported Pseudo-variables
  27. List of Examples
  28. 1.1. Set mqueue parameter
  29. 1.2. mq_add usage
  30. 1.3. mq_fetch usage
  31. 1.4. mq_pv_free usage
  32. 1.5. mq_size usage
  33. Chapter 1. Admin Guide
  34. Table of Contents
  35. 1. Overview
  36. 2. Dependencies
  37. 2.1. Kamailio Modules
  38. 2.2. External Libraries or Applications
  39. 3. Parameters
  40. 3.1. mqueue (string)
  41. 4. Functions
  42. 4.1. mq_add(queue, key, value)
  43. 4.2. mq_fetch(queue)
  44. 4.3. mq_pv_free(queue)
  45. 4.4. mq_size(queue)
  46. 5. Exported Pseudo-variables
  47. 1. Overview
  48. The mqueue module offers a generic message queue system in shared
  49. memory for inter-process communication using the config file. One
  50. example of usage is to send time consuming operations to one or several
  51. timer processes that consumes items in the queue, without affecting SIP
  52. message handling in the socket-listening process.
  53. There can be many defined queues. Access to queued values is done via
  54. pseudo variables.
  55. 2. Dependencies
  56. 2.1. Kamailio Modules
  57. 2.2. External Libraries or Applications
  58. 2.1. Kamailio Modules
  59. The following modules must be loaded before this module:
  60. * None.
  61. 2.2. External Libraries or Applications
  62. The following libraries or applications must be installed before
  63. running Kamailio with this module loaded:
  64. * None.
  65. 3. Parameters
  66. 3.1. mqueue (string)
  67. 3.1. mqueue (string)
  68. Definition of a memory queue
  69. Default value is "none".
  70. Value must be a list of parameters: attr=value;... The attribute 'name'
  71. is mandatory, defining the name of the queue. Optional attribute 'size'
  72. specifies the maximum number of items in queue, if it is execeeded the
  73. oldest one is removed.
  74. The parameter can be set many times, each holding the definition of one
  75. queue.
  76. Example 1.1. Set mqueue parameter
  77. ...
  78. modparam("mqueue", "mqueue", "name=myq;size=20;")
  79. modparam("mqueue", "mqueue", "name=qaz")
  80. ...
  81. 4. Functions
  82. 4.1. mq_add(queue, key, value)
  83. 4.2. mq_fetch(queue)
  84. 4.3. mq_pv_free(queue)
  85. 4.4. mq_size(queue)
  86. 4.1. mq_add(queue, key, value)
  87. Add a new item (key, value) in the queue. If max size of queue is
  88. exceeded, the oldest one is removed.
  89. Example 1.2. mq_add usage
  90. ...
  91. mq_add("myq", "$rU", "call from $fU");
  92. ...
  93. 4.2. mq_fetch(queue)
  94. Take oldest item from queue and fill $mqk(queue) and $mqv(queue) pseudo
  95. variables.
  96. Return: true on success (1); false on failure (-1) or no item fetched
  97. (-2).
  98. Example 1.3. mq_fetch usage
  99. ...
  100. while(mq_fetch("myq"))
  101. {
  102. xlog("$mqk(myq) - $mqv(myq)\n");
  103. }
  104. ...
  105. 4.3. mq_pv_free(queue)
  106. Free the item fetched in pseudo-variables. It is optional, a new fetch
  107. frees the previous values.
  108. Example 1.4. mq_pv_free usage
  109. ...
  110. mq_pv_free("myq");
  111. ...
  112. 4.4. mq_size(queue)
  113. Returns the current number of elements in the mqueue.
  114. If the mqueue is empty, the function returns -1. If the mqueue is not
  115. found, the function returns -2.
  116. Example 1.5. mq_size usage
  117. ...
  118. $var(q_size) = mq_size("queue");
  119. xlog("L_INFO", "Size of queue is: $var(q_size)\n");
  120. ...
  121. 5. Exported Pseudo-variables
  122. * $mqv(mqueue) - the most recent item key fetched from the specified
  123. mqueue
  124. * $mqv(mqueue) - the most recent item value fetched from the
  125. specified mqueue
  126. * $mq_size(mqueue) - the size of the specified mqueue
  127. Exported pseudo-variables are documented at
  128. http://www.kamailio.org/wiki/.