Debian Codegraph @

src/modules/rabbitmq/README

raw
1 RABBITMQ Module
2
3 Carsten Bock
4
5 ng-voice GmbH
6
7 Edited by
8
9 Stefan-Cristian Mititelu
10
11 <[email protected]>
12
13 Copyright © 2016 ONEm Communications Ltd.
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Dependencies
22
23 2.1. Kamailio modules
24 2.2. External libraries or applications
25
26 3. Parameters
27
28 3.1. url (string)
29 3.2. timeout_sec (int)
30 3.3. timeout_usec (int)
31 3.4. direct_reply_to (int)
32
33 4. Functions
34
35 4.1. rabbitmq_publish(exchange, routing_key, content_type,
36 messagebody)
37
38 4.2. rabbitmq_publish_consume(exchange, routing_key,
39 content_type, messagebody, reply)
40
41 List of Examples
42
43 1.1. Set the “url” parameter
44 1.2. Set the “timeout_sec” parameter
45 1.3. Set the “timeout_usec” parameter
46 1.4. Set the “direct_reply_to” parameter
47 1.5. rabbitmq_publish usage
48 1.6. rabbitmq_publish_consume usage
49
50 Chapter 1. Admin Guide
51
52 Table of Contents
53
54 1. Overview
55 2. Dependencies
56
57 2.1. Kamailio modules
58 2.2. External libraries or applications
59
60 3. Parameters
61
62 3.1. url (string)
63 3.2. timeout_sec (int)
64 3.3. timeout_usec (int)
65 3.4. direct_reply_to (int)
66
67 4. Functions
68
69 4.1. rabbitmq_publish(exchange, routing_key, content_type,
70 messagebody)
71
72 4.2. rabbitmq_publish_consume(exchange, routing_key, content_type,
73 messagebody, reply)
74
75 1. Overview
76
77 This module offers amqp communication using librabbitmq. This module
78 was created using rabbitmq-c C client
79 (https://github.com/alanxz/rabbitmq-c). A new amqp connection is set up
80 on a per-children basis, when Kamailio starts. If connection is lost,
81 the process tries to re-establish it when a new amqp action is
82 required.
83
84 Currently librabbitmq offers no async API, but sync API, with a
85 timeout. See below link for updates on this issue:
86 * https://github.com/alanxz/rabbitmq-c/issues/370.
87
88 2. Dependencies
89
90 2.1. Kamailio modules
91 2.2. External libraries or applications
92
93 2.1. Kamailio modules
94
95 The following modules must be loaded before this module:
96 * none.
97
98 2.2. External libraries or applications
99
100 The following libraries or applications must be installed before
101 running Kamailio with this module:
102 * librabbitmq-dev - (https://github.com/alanxz/rabbitmq-c).
103
104 3. Parameters
105
106 3.1. url (string)
107 3.2. timeout_sec (int)
108 3.3. timeout_usec (int)
109 3.4. direct_reply_to (int)
110
111 3.1. url (string)
112
113 The amqp connection url.
114
115 Default value is “amqp://guest:guest@localhost:5672/%2F”.
116
117 Example 1.1. Set the “url” parameter
118 ...
119 modparam("rabbitmq", "url", "amqp://kamailio:kamailio@localhost:5672/%2Fkamailio
120 ")
121 ...
122
123 3.2. timeout_sec (int)
124
125 The timeout in seconds. The timeout_sec + timeout_usec combination
126 gives the time to wait for an amqp reply, when
127 rabbitmq_publish_consume() is used.
128
129 Default value is “1”.
130
131 Example 1.2. Set the “timeout_sec” parameter
132 ...
133 modparam("rabbitmq", "timeout_sec", 1)
134 ...
135
136 3.3. timeout_usec (int)
137
138 The timeout in micro seconds. The timeout_sec + timeout_usec
139 combination gives the time to wait for an amqp reply, when
140 rabbitmq_publish_consume() is used.
141
142 Default value is “0”.
143
144 Example 1.3. Set the “timeout_usec” parameter
145 ...
146 modparam("rabbitmq", "timeout_usec", 0)
147 ...
148
149 3.4. direct_reply_to (int)
150
151 Setting this parameter to 1, enables rabbitmq direct reply-to feature.
152 More info about this, can be found at
153 https://www.rabbitmq.com/direct-reply-to.html.
154
155 Default value is “0”.
156
157 Example 1.4. Set the “direct_reply_to” parameter
158 ...
159 modparam("rabbitmq", "direct_reply_to", 1)
160 ...
161
162 4. Functions
163
164 4.1. rabbitmq_publish(exchange, routing_key, content_type, messagebody)
165
166 4.2. rabbitmq_publish_consume(exchange, routing_key, content_type,
167 messagebody, reply)
168
169 4.1. rabbitmq_publish(exchange, routing_key, content_type, messagebody)
170
171 The function publishes messagebody without waiting for a reply.
172
173 Meaning of the parameters is as follows:
174 * exchange - the amqp exchange.
175 * routing_key - the amqp routing_key.
176 * content_type - the content_type of the messagebody.
177 * messagebody - the messagebody to be published.
178
179 This function can be used from any route.
180
181 Example 1.5. rabbitmq_publish usage
182 rabbitmq_publish("exchange", "routing_key", "application/json", "$avp(json_reque
183 st)");
184
185 4.2. rabbitmq_publish_consume(exchange, routing_key, content_type,
186 messagebody, reply)
187
188 The function publishes messagebody and waits timeoute_sec +
189 timeout_usec for a reply. If the reply comes, one can read it in the
190 reply avp.
191
192 Meaning of the parameters is as follows:
193 * exchange - the amqp exchange.
194 * routing_key - the amqp routing_key.
195 * content_type - the content_type of the messagebody.
196 * messagebody - the messagebody to be published.
197 * reply - the consumed reply.
198
199 This function can be used from REQUEST_ROUTE.
200
201 Example 1.6. rabbitmq_publish_consume usage
202 rabbitmq_publish_consume("exchange", "routing_key", "application/json", "$avp(js
203 on_request)", "$avp(json_reply)");