f4454be078d0138fb74277769104432c5838f7ed
[ric-plt/lib/rmr.git] / docs / overview.rst
1  
2  
3 .. This work is licensed under a Creative Commons Attribution 4.0 International License. 
4 .. SPDX-License-Identifier: CC-BY-4.0 
5 .. CAUTION: this document is generated from source in doc/src/rtd. 
6 .. To make changes edit the source and recompile the document. 
7 .. Do NOT make changes directly to .rst or .md files. 
8  
9  
10  
11 RMR Overview 
12 ============================================================================================ 
13  
14  
15 RMR Library 
16 ============================================================================================ 
17  
18  
19 NAME 
20 -------------------------------------------------------------------------------------------- 
21  
22 RMR -- Ric Message Router Library 
23  
24 DESCRIPTION 
25 -------------------------------------------------------------------------------------------- 
26  
27 RMR is a library which provides a user application with the 
28 ability to send and receive messages to/from other RMR based 
29 applications without having to understand the underlying 
30 messaging transport environment (e.g., SI95) and without 
31 needing to know which other endpoint applications are 
32 currently available and accepting messages. To do this, RMR 
33 depends on a routing table generated by an external source. 
34 This table is used to determine the destination endpoint of 
35 each message sent by mapping the message type T (supplied by 
36 the user application) to an endpoint entry. Once determined, 
37 the message is sent directly to the endpoint. The user 
38 application is unaware of which endpoint actually receives 
39 the message, and in some cases whether that message was sent 
40 to multiple applications. 
41  
42 RMR functions do provide for the ability to respond to the 
43 specific source instance of a message allowing for either a 
44 request response, or call response relationship when needed. 
45  
46 The Route Table 
47 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
48  
49 The library must be given a route table which maps message 
50 types (integers) to endpoint groups such that each time a 
51 message of type T is sent, the message is delivered to one 
52 member of each group associated with T. For example, message 
53 type 2 might route to two different groups where group A has 
54 two members, worker1 and worker2, while group B has only one 
55 member, logger1. 
56  
57 The route table consists of a start record, one or more table 
58 entry records, and an end record. All table records contain 
59 fields separated with vertical bars (|), and allow for 
60 trailing comments with the standard shell comment symbol 
61 (hash, #) provided that the start of the comment is separated 
62 from the last token on the record by one or more spaces. 
63 Leading and trailing white space in each field is ignored. 
64 The route table supports two entry types: *rte* and *mse*. 
65  
66 A *rte* entry defines a message type, an optional sender 
67 application, and the endpoint(s) which accept the indicated 
68 message type. However, this format is deprecated and may be 
69 removed in a future version. An example record appears next. 
70  
71 :: 
72   
73      rte | 1 | app10:4560
74  
75  
76  
77 The second type of entry is *mse*. This entry defines a 
78 message type, an optional sender application, a subscription 
79 ID, and a collection of endpoints. An example record appears 
80 next. 
81  
82 :: 
83   
84      mse | 1000,forwarder:43086 | 10 | app2:43086
85  
86  
87  
88 It is the responsibility of the route table generator to know 
89 which endpoints belong to which groups, and which groups 
90 accept which message types. Once understood, the route table 
91 generator publishes a table that is ingested by RMR and used 
92 for mapping messages to end points. 
93  
94 The following is a simple route table which causes message 
95 types 0 through 9 to be routed to specific applications: 
96  
97 :: 
98   
99  newrt|start
100     mse|0|-1| %meid
101     mse|1|-1|app10:4560,app11:4560
102     mse|2|-1|app12:4560
103     mse|3|-1|app14:4560
104     mse|4|-1|app18:4560
105     mse|5|-1|app01:4560
106     mse|6|-1|app02:4560
107     mse|7|-1|app03:4560
108     mse|8|-1|app04:4560
109     mse|9|-1|app05:4560
110  newrt|end
111  
112  
113  
114 The special endpoint "%meid" indicates that the message type 
115 (0 in this case) is to be routed to the endpoint which has 
116 been listed as the "owner" for the meid appearing in the 
117 message. MEID ownership is communicated to RMR using the same 
118 Route Table Manager interface and by supplying a "table" such 
119 as the one below: 
120  
121 :: 
122   
123  meid_map | start
124     mme_ar | control1 | meid000 meid001 meid002 meid003 meid004 meid005
125     mme_ar | control2 | meid100 meid101 meid102 meid103
126  meid_map | end | 2
127  
128  
129 This table indicates that the application (endpoint) 
130 *control1* "owns" 6 MEIDs and *control2* owns 4. When message 
131 type 0 is sent, the MEID in the message will be used to 
132 select the endpoint via this table. 
133  
134 The MEID table will update the existing owner relationships, 
135 and add new ones; it is necessary to send only the changes 
136 with the add/replace (mme_ar) entries in the table. When 
137 necessary, MEIDs can be deleted by adding an mme_del record 
138 to the table. The following example illustrates how this 
139 might look: 
140  
141 :: 
142   
143  meid_map | start
144     mme_ar | control1 | meid000 meid001 meid002 meid003 meid004 meid005
145     mme_ar | control2 | meid100 meid101 meid102 meid103
146     mme_del| meid200 meid401
147  meid_map | end | 3
148  
149  
150  
151 Route Table Syntax 
152 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
153  
154 The following illustrates the syntax for both types of route 
155 table entries. 
156  
157  
158 :: 
159   
160  newrt | start
161  rte | <message-type>[,<sender-endpoint>] | <round-robin-grp>[;<round-robin-grp>]...
162  mse | <message-type>[,<sender-endpoint>] | <sub-id> | <round-robin-grp>[;<round-robin-grp>]...
163  newrt | end
164  
165  
166  
167 A round robin group is one or more endpoints from which one 
168 will be selected to receive the message. When multiple 
169 endpoints are given in a group, they must be separated with a 
170 comma. An endpoint is an IP address and port (e.g. 
171 192.158.4.30:8219), or DNS name and port, of the application 
172 that should receive the message type. If multiple round-robin 
173 groups are given, they must be separated by a semicolon. 
174  
175 MEID Map Syntax 
176 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
177  
178 The MEID map is similar to the route table. Entries are used 
179 to add or replace the ownership of one or more MEIDs (mme_ar) 
180 or to delete one or more MEIDs (mme_del). The following is 
181 the syntax for the MEID map. 
182  
183  
184 :: 
185   
186  meid_map | start
187  mme_ar | <owner-endpoint> | <meid> [<meid>...]
188  mme_del | <meid> [<meid>...]
189  meid_map | end | <count> [| <md5sum>
190  
191  
192  
193 The <count> on the end record indicates the number of mme_ar 
194 and mme_del records which were sent; if the count does not 
195 match the whole map is refused and dropped. The 
196 <owner-endpoint> is the endpoint which should receive the 
197 message when a message is routed based on the MEID it 
198 contains. A MEID may be "owned" by only one endpoint, and if 
199 supplied multiple times, the last observed relationship is 
200 used. Each of the lists of MEIDs are blank separated. 
201  
202 The optional <md5sum> on the *end* record should be the 
203 computed MD5 hash for all records which appear between the 
204 start and and records. This allows for a tighter verification 
205 that all data was received exactly as the route manager 
206 transmitted them. 
207  
208 Environment 
209 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
210  
211 To enable configuration of the library behaviour outside of 
212 direct user application control, RMR supports a number of 
213 environment variables which provide information to the 
214 library. The following is a list of the various environment 
215 variables, what they control and the defaults which RMR uses 
216 if undefined. 
217  
218  
219  
220 RMR_ASYNC_CONN 
221    
222   Allows the async connection mode to be turned off (by 
223   setting the value to 0). When set to 1, or missing from 
224   the environment, RMR will invoke the connection interface 
225   in the transport mechanism using the non-blocking (async) 
226   mode. This will likely result in many "soft failures" 
227   (retry) until the connection is established, but allows 
228   the application to continue unimpeded should the 
229   connection be slow to set up. 
230    
231  
232 RMR_BIND_IF 
233    
234   This provides the interface that RMR will bind listen 
235   ports to, allowing for a single interface to be used 
236   rather than listening across all interfaces. This should 
237   be the IP address assigned to the interface that RMR 
238   should listen on, and if not defined RMR will listen on 
239   all interfaces. 
240    
241  
242 RMR_CTL_PORT 
243    
244   This variable defines the port that RMR should open for 
245   communications with Route Manager, and other RMR control 
246   applications. If not defined, the port 4561 is assumed. 
247    
248   Previously, the RMR_RTG_SVC (route table generator service 
249   port) was used to define this port. However, a future 
250   version of Route Manager will require RMR to connect and 
251   request tables, thus that variable is now used to supply 
252   the Route Manager's well-known address and port. 
253    
254   To maintain backwards compatibility with the older Route 
255   Manager versions, the presence of this variable in the 
256   environment will shift RMR's behaviour with respect to the 
257   default value used when RMR_RTG_SVC is **not** defined. 
258    
259   When RMR_CTL_PORT is **defined:** RMR assumes that Route 
260   Manager requires RMR to connect and request table updates 
261   is made, and the default well-known address for Route 
262   manager is used (routemgr:4561). 
263    
264   When RMR_CTL_PORT is **undefined:** RMR assumes that Route 
265   Manager will connect and push table updates, thus the 
266   default listen port (4561) is used. 
267    
268   To avoid any possible misinterpretation and/or incorrect 
269   assumptions on the part of RMR, it is recommended that 
270   both the RMR_CTL_PORT and RMR_RTG_SVC be defined. In the 
271   case where both variables are defined, RMR will behave 
272   exactly as is communicated with the variable's values. 
273    
274  
275 RMR_RTG_SVC 
276    
277   The value of this variable depends on the Route Manager in 
278   use. 
279    
280   When the Route Manager is expecting to connect to an xAPP 
281   and push route tables, this variable must indicate the 
282   port which RMR should use to listen for these connections. 
283    
284   When the Route Manager is expecting RMR to connect and 
285   request a table update during initialisation, the variable 
286   should be the host of the Route Manager process. 
287    
288   The RMR_CTL_PORT variable (added with the support of 
289   sending table update requests to Route manager), controls 
290   the behaviour if this variable is not set. See the 
291   description of that variable for details. 
292    
293  
294 RMR_HR_LOG 
295    
296   By default RMR writes messages to standard error 
297   (incorrectly referred to as log messages) in human 
298   readable format. If this environment variable is set to 0, 
299   the format of standard error messages might be written in 
300   some format not easily read by humans. If missing, a value 
301   of 1 is assumed. 
302    
303  
304 RMR_LOG_VLEVEL 
305    
306   This is a numeric value which corresponds to the verbosity 
307   level used to limit messages written to standard error. 
308   The lower the number the less chatty RMR functions are 
309   during execution. The following is the current 
310   relationship between the value set on this variable and 
311   the messages written: 
312    
313  
314
315    
316   Off; no messages of any sort are written. 
317    
318  
319
320    
321   Only critical messages are written (default if this 
322   variable does not exist) 
323    
324  
325
326    
327   Errors and all messages written with a lower value. 
328    
329  
330
331    
332   Warnings and all messages written with a lower value. 
333    
334  
335
336    
337   Informational and all messages written with a lower 
338   value. 
339    
340  
341
342    
343   Debugging mode -- all messages written, however this 
344   requires RMR to have been compiled with debugging 
345   support enabled. 
346  
347  
348  
349 RMR_RTG_ISRAW 
350    
351   **Deprecated.** Should be set to 1 if the route table 
352   generator is sending "plain" messages (not using RMR to 
353   send messages), 0 if the RTG is using RMR to send. The 
354   default is 1 as we don't expect the RTG to use RMR. 
355    
356   This variable is only recognised when using the NNG 
357   transport library as it is not possible to support NNG 
358   "raw" communications with other transport libraries. It is 
359   also necessary to match the value of this variable with 
360   the capabilities of the Route Manager; at some point in 
361   the future RMR will assume that all Route Manager messages 
362   will arrive via an RMR connection and will ignore this 
363   variable. 
364  
365 RMR_SEED_RT 
366    
367   This is used to supply a static route table which can be 
368   used for debugging, testing, or if no route table 
369   generator process is being used to supply the route table. 
370   If not defined, no static table is used and RMR will not 
371   report *ready* until a table is received. The static route 
372   table may contain both the route table (between newrt 
373   start and end records), and the MEID map (between meid_map 
374   start and end records). 
375  
376 RMR_SRC_ID 
377    
378   This is either the name or IP address which is placed into 
379   outbound messages as the message source. This will used 
380   when an RMR based application uses the rmr_rts_msg() 
381   function to return a response to the sender. If not 
382   supplied RMR will use the hostname which in some container 
383   environments might not be routable. 
384    
385   The value of this variable is also used for Route Manager 
386   messages which are sent via an RMR connection. 
387  
388 RMR_VCTL_FILE 
389    
390   This supplies the name of a verbosity control file. The 
391   core RMR functions do not produce messages unless there is 
392   a critical failure. However, the route table collection 
393   thread, not a part of the main message processing 
394   component, can write additional messages to standard 
395   error. If this variable is set, RMR will extract the 
396   verbosity level for these messages (0 is silent) from the 
397   first line of the file. Changes to the file are detected 
398   and thus the level can be changed dynamically, however RMR 
399   will only suss out this variable during initialisation, so 
400   it is impossible to enable verbosity after startup. 
401  
402 RMR_WARNINGS 
403    
404   If set to 1, RMR will write some warnings which are 
405   non-performance impacting. If the variable is not defined, 
406   or set to 0, RMR will not write these additional warnings. 
407  
408  
409 SEE ALSO 
410 -------------------------------------------------------------------------------------------- 
411  
412 rmr_alloc_msg(3), rmr_tralloc_msg(3), rmr_call(3), 
413 rmr_free_msg(3), rmr_init(3), rmr_init_trace(3), 
414 rmr_get_meid(3), rmr_get_src(3), rmr_get_srcip(3), 
415 rmr_get_trace(3), rmr_get_trlen(3), rmr_get_xact(3), 
416 rmr_payload_size(3), rmr_rcv_msg(3), rmr_rcv_specific(3), 
417 rmr_rts_msg(3), rmr_ready(3), rmr_fib(3), rmr_has_str(3), 
418 rmr_tokenise(3), rmr_mk_ring(3), rmr_realloc_payload(3), 
419 rmr_ring_free(3), rmr_set_trace(3), rmr_torcv_msg(3), 
420 rmr_wh_open(3), rmr_wh_send_msg(3)