No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0354.xml 16KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Customizable Message Routing</title>
  10. <abstract>This specification specifies customizable behavior of RFC 6121 section to allow various message routing algorithms (e.g., for load balancing).</abstract>
  12. <number>0354</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XMPP IM</spec>
  20. <spec>XEP-0030</spec>
  21. </dependencies>
  22. <supersedes/>
  23. <supersededby/>
  24. <shortname>NOT_YET_ASSIGNED</shortname>
  25. &flow;
  26. <revision>
  27. <version>0.2</version>
  28. <date>2017-09-11</date>
  29. <initials>XEP Editor (jwi)</initials>
  30. <remark>Defer due to lack of activity.</remark>
  31. </revision>
  32. <revision>
  33. <version>0.1</version>
  34. <date>2014-10-15</date>
  35. <initials>XEP Editor (aw)</initials>
  36. <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  37. </revision>
  38. <revision>
  39. <version>0.0.1</version>
  40. <date>2014-09-22</date>
  41. <initials>fs</initials>
  42. <remark><p>First draft.</p></remark>
  43. </revision>
  44. </header>
  45. <section1 topic='Introduction' anchor='intro'>
  46. <p>
  47. The "Server Rules for Processing XML Stanzas" section in &rfc6121; defines only a "one receives" or "all receive" algorithm for message routing if the receiving entity of a message stanza has multiple connected resources and the message is addressed to a bare JID. Also RFC 6121 does not define a method to check or change the currently used message routing algorithm. Furthermore, none of the described routing algorithms is a good match when it comes down to achieve load-balancing between the connected resources, which is sometimes desirable.
  48. </p>
  49. <p>
  50. This extensions solves those issues by allowing clients to configure their desired message routing algorithm. By exploiting the freedom provided by RFC 6121 which allows servers to implement their own algorithm for determining the "most available" resource.
  51. </p>
  52. <p>
  53. &xep0254; defines a XEP to queue PubSub items, which could be used as alternative approach, instead of the herein defined message routing algorithms ('urn:xmpp:cmr:roundrobin' and 'urn:xmpp:cmr:weighted'). But this solution requires more and complexer code on the server and client side, while the guarantees provided by XEP-0254 are not always required.
  54. </p>
  55. </section1>
  56. <section1 topic='Requirements' anchor='reqs'>
  57. <p>
  58. The authors have designed the customizable message routing protocol with the following requirements in mind:
  59. </p>
  60. <ul>
  61. <li><p>The protocol MUST NOT violate the server rules for processing XML Stanzas as defined in RFC 6121 § 8</p></li>
  62. <li><p>The protocol should be easy to use by clients and easy to adopt by server implementations</p></li>
  63. <li><p>The protocol must by extensible by further message routing algorithms</p></li>
  64. </ul>
  65. </section1>
  66. <section1 topic='Glossary' anchor='glossary'>
  67. <p>The following terms are used throughout this document</p>
  68. <dl>
  69. <di><dt>Customizable Message Routing (CMR)</dt><dd>The name of this XEP and the protocol defined by it.</dd></di>
  70. <di><dt>Message Routing Algorithm</dt><dd>An algorithm that defines how a server processes message stanzas send to a server-local bare JID of type 'message' or 'chat', with at least one available or connected resource of the receiver (RFC 6121 §</dd></di>
  71. </dl>
  72. </section1>
  73. <section1 topic='Use Cases' anchor='usecases'>
  74. <section2 topic='Non-balancing Message Routing Algorithms'>
  75. <p>
  76. Non-balancing message algorithms consists of the traditional algorithms that are widely used by XMPP implementations as defined in RFC 6121 § and &rfc3921;. They usually try to send a message either to the all resources or try to determine the best resource based on some heuristic. They where designed with human-to-human interaction in mind.
  77. </p>
  78. <p>
  79. Examples for non-balancing algorithms include:
  80. </p>
  81. <ul>
  82. <li><p>Deliver to all ('urn:xmpp:cmr:all')</p></li>
  83. <li><p>Deliver to most active resource ('urn:xmpp:cmr:mostactive')</p></li>
  84. </ul>
  85. </section2>
  86. <section2 topic='Balancing Message Routing Algorithms'>
  87. <p>
  88. Balanced message routing algorithms try to distribute messages between the available resources of the receiver. They are ideal for use with the Internet of Things (IoT) and especially machine to machine (M2M) technologies.
  89. </p>
  90. <p>
  91. Consider a large deployment of sensor nodes send their data to a cluster for further processing. Every cluster node establishes a connection using the same bare JID but a different resource for receiving the sensor data. Furthermore, after a cluster connection is authenticated, it queries the XMPP service for the CMR status, and enables a balancing message routing algorithm.
  92. </p>
  93. <p>
  94. The sensor nodes can now send their data as payload of a message stanza to the cluster. The server will evenly distributed the data between the cluster nodes by using a round-robin scheme.
  95. </p>
  96. <p>
  97. Since CMR balances message stanzas of type 'normal' or 'chat', PubSub notifications will also be evenly distributed between the connected resources of an connection where CMR is active.
  98. </p>
  99. <p>
  100. Examples for balancing algorithms include:
  101. </p>
  102. <ul>
  103. <li><p>Load balance using round robin ('urn:xmpp:cmr:roundrobin')</p></li>
  104. <li><p>Weighted load balancing ('urn:xmpp:cmr:weighted')</p></li>
  105. </ul>
  106. </section2>
  107. <section2 topic='Non-Use Cases'>
  108. <p>
  109. CMR is not suitable for scenarios where the routing behavior should also consider resources with negative priority. This would violate RFC 6121 § A suitable specification for such use cases may already exists. For example a proper solution that involves forking of messages even to resources with negatives priorities is explained in Section 6 of &xep0280;.
  110. </p>
  111. </section2>
  112. </section1>
  113. <section1 topic='Protocol' anchor='protocol'>
  114. <section2 topic='Discovering Support'>
  115. <p>
  116. An entity advertises support for this protocol by including the
  117. 'urn:xmpp:cmr:0' feature in its service discovery information features as
  118. specified in &xep0030; or section 6.3 of &xep0115;.
  119. </p>
  120. <example caption='Service discovery information request'><![CDATA[
  121. <iq xmlns='jabber:client'
  122. from='romeo@montague.example/garden'
  123. id='info1'
  124. to='montague.example'
  125. type='get'>
  126. <query xmlns=''/>
  127. </iq>
  128. ]]></example>
  129. <example caption='Service discovery information response'><![CDATA[
  130. <iq xmlns='jabber:client'
  131. from='montague.example'
  132. id='info1'
  133. to='romeo@montague.example/garden'
  134. type='result'>
  135. <query xmlns=''>
  136. ...
  137. <feature var='urn:xmpp:cmr:0'/>
  138. ...
  139. </query>
  140. </iq>
  141. ]]></example>
  142. </section2>
  143. <section2 topic='Quering the current active and available message routing algorithms'>
  144. <p>
  145. Clients are able to query the server for the currently active and available message routing algorithms.
  146. </p>
  147. <example caption='Client requests the current CMR state'><![CDATA[
  148. <iq xmlns='jabber:client'
  149. from='romeo@montague.example/garden'
  150. id='state1'
  151. type='get'>
  152. <query xmlns='urn:xmpp:cmr:0'/>
  153. </iq>
  154. ]]></example>
  155. <p>
  156. The result IQ, must include exactly one &lt;active/&gt; element and at least one &lt;available/&gt; element. Both elements must posses a &apos;algorithm&apos; attribute, which contains the name of the available or active algorithm.
  157. </p>
  158. <example caption='Server returns information about the CMR state'><![CDATA[
  159. <iq xmlns='jabber:client'
  160. from='romeo@montague.example'
  161. id='state1'
  162. to='romeo@montague.example/garden'
  163. type='result'>
  164. <query xmlns='xmlns='urn:xmpp:cmr:0'>
  165. <active algorithm='urn:xmpp:cmr:all' />
  166. <available algorithm='urn:xmpp:cmr:all'/>
  167. <available algorithm='urn:xmpp:cmr:mostactive'/>
  168. <available algorithm='urn:xmpp:cmr:roundrobin'/>
  169. <available algorithm='urn:xmpp:cmr:weighted'/>
  170. </iq>
  171. ]]></example>
  172. </section2>
  173. <section2 topic='Changing the active message routing algorithm'>
  174. <p>
  175. To change the active message routing algorithm, the client sends an &IQ; of type &apos;set&apos; containing a &apos;cmr&apos; child element which contains the desired algorithm as value of the &apos;algorithm&apos; attribute.
  176. </p>
  177. <example caption='Client requests to change the active message routing algorithm'><![CDATA[
  178. <iq xmlns='jabber:client'
  179. from='romeo@montague.example/garden'
  180. id='change1'
  181. type='set'>
  182. <cmr xmlns='urn:xmpp:cmr:0'
  183. algorithm='urn:xmpp:cmr:roundrobin' />
  184. </iq>
  185. ]]></example>
  186. <p>
  187. The server will respond with an result &IQ; if the routing algorithm was successfully changed.
  188. </p>
  189. <example caption='Server acknowledges the change of the active message routing algorithm'><![CDATA[
  190. <iq xmlns='jabber:client'
  191. from='romeo@montague.example'
  192. id='change1'
  193. to='romeo@montague.example/garden'
  194. type='result'/>
  195. ]]></example>
  196. <p>
  197. If the server is unable to change the message routing algorithm, then an error &IQ; is returned to the client.
  198. </p>
  199. <example caption='Server informs client that the routing algorithm was not changed'><![CDATA[
  200. <iq xmlns='jabber:client'
  201. from='romeo@montague.example'
  202. id='change1'
  203. to='romeo@montague.example/garden'
  204. type='error'>
  205. <error type='cancel'>
  206. <not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  207. </error>
  208. </iq>]]></example>
  209. </section2>
  210. <section2 topic='Message Routing Hints'>
  211. <p>
  212. If allowed and supported by the server, clients are able to annotate message
  213. stanza with a routing hint, that SHOULD affect the used message routing
  214. algorithm for the annotated stanza.
  215. </p>
  216. <section3 topic='Determing support'>
  217. <example caption='Client sends service discovery information request'><![CDATA[
  218. <iq xmlns='jabber:client'
  219. from='romeo@montague.example/garden'
  220. id='info2'
  221. to='bar.example'
  222. type='get'>
  223. <query xmlns=''/>
  224. </iq>
  225. ]]></example>
  226. <example caption='Server replies with service discovery information response'><![CDATA[
  227. <iq xmlns='jabber:client'
  228. from='bar.example'
  229. id='info2'
  230. to='romeo@montague.example/garden'
  231. type='result'>
  232. <query xmlns=''>
  233. ...
  234. <feature var='urn:xmpp:cmr:hints:0'/>
  235. ...
  236. </query>
  237. </iq>
  238. ]]></example>
  239. </section3>
  240. <section3 topic='Determing available message routing algorithms of a (remote) server'>
  241. <example caption='Client requests available message routing algorithms'><![CDATA[
  242. <iq xmlns='jabber:client'
  243. from='romeo@montague.example/garden'
  244. to='bar.example'
  245. id='state1'
  246. type='get'>
  247. <query xmlns='urn:xmpp:cmr:0'/>
  248. </iq>
  249. ]]></example>
  250. <example caption='Server replies with available message routing algorithms'><![CDATA[
  251. <iq xmlns='jabber:client'
  252. from='bar.example'
  253. id='state1'
  254. to='romeo@montague.example/garden'
  255. type='result'>
  256. <query xmlns='xmlns='urn:xmpp:cmr:0'>
  257. <available algorithm='urn:xmpp:cmr:all'/>
  258. <available algorithm='urn:xmpp:cmr:mostactive'/>
  259. <available algorithm='urn:xmpp:cmr:roundrobin'/>
  260. <available algorithm='urn:xmpp:cmr:weighted'/>
  261. <available algorithm='urn:xmpp:cmr:forkalways'/>
  262. </iq>
  263. ]]></example>
  264. </section3>
  265. <section3 topic='Sending a message with routing hint'>
  266. <example caption='Client sends a message with a routing hint'><![CDATA[
  267. <message xmlns='jabber:client'
  268. from='romeo@montague.example/garden'
  269. to='foo@bar.example'>
  270. <body>Hello everyone</body>
  271. <cmr xmlns='urn:xmpp:cmr:0'
  272. algorithm='run:xmpp:cmr:forkalways'/>
  273. </message>
  274. ]]></example>
  275. </section3>
  276. </section2>
  277. </section1>
  278. <section1 topic='Business Rules' anchor='rules'>
  279. <section2 topic='General Rules'>
  280. <p>
  281. Clients are allowed to change the CMR state at any time. CMR MUST only affect the routing of message stanzas of type 'normal' or 'chat', which are addressed to a bare JID and where the receiving entity has more then one available resource with a non-negative presence priority. That is, it affects the routing decision as described in RFC 6121 § for messages of type 'normal' and 'chat'.
  282. </p>
  283. <p>
  284. The CMR state, ie. the used routing algorithm, is identical for every session of an XMPP client. Therefore implementations MUST NOT allow different CMR states between the resources of the same bare JID.
  285. </p>
  286. <p>
  287. If an entity advertises support for CMR as described in 3. it MUST support at least one message routing algorithm.
  288. </p>
  289. </section2>
  290. <section2 topic='Routing Algorithm Specification'>
  291. <section3 topic='Deliver to all'>
  292. <p>
  293. <strong>Algorithm Namespace:</strong> 'urn:xmpp:cmr:all'
  294. </p>
  295. <p>Deliver to all non-negative resources with share the same maximum priority. And if message type is 'chat', only to those that have opted in to receive chat messages.</p>
  296. </section3>
  297. <section3 topic='Deliver to most active resource'>
  298. <p>
  299. <strong>Algorithm Namespace:</strong> 'urn:xmpp:cmr:mostactive'
  300. </p>
  301. <p>Deliver the message to the "most available" resource or resources, depending on the server's implementation.</p>
  302. </section3>
  303. <section3 topic='Load balance using round robin'>
  304. <p>
  305. <strong>Algorithm Namespace:</strong> 'urn:xmpp:cmr:roundrobin'
  306. </p>
  307. <p>Deliver the message to the next resource selected by a round-robin algorithm.</p>
  308. </section3>
  309. <section3 topic='Weighted load balancing'>
  310. <p>
  311. <strong>Algorithm Namespace:</strong> 'urn:xmpp:cmr:weighted'
  312. </p>
  313. <p>Deliver the message to a resource selected by a weighted round-robin algorithm. The weight of a resource is determined by its priority.</p>
  314. </section3>
  315. </section2>
  316. </section1>
  317. <section1 topic='Implementation Notes' anchor='impl'>
  318. <p>Servers implementing CMR MUST at least implement one message routing algorithm, and offer at least one of of 'urn:xmpp:cmr:all' and 'urn:xmpp:cmr:mostactive'. Technically this is a constraint derived from Section of RFC 6121.</p>
  319. </section1>
  320. <section1 topic='Security Considerations' anchor='security'>
  321. <p>This specification introduces no known security considerations.</p>
  322. </section1>
  323. <section1 topic='IANA Considerations' anchor='iana'>
  324. <p>This document requires no interaction with &IANA;.</p>
  325. </section1>
  326. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  327. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  328. <p>This specification defines the following XML namespace:</p>
  329. <ul>
  330. <li>urn:xmpp:cmr:0</li>
  331. </ul>
  332. <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  333. </section2>
  334. <section2 topic='Protocol Versioning' anchor='registrar-versioning'>
  335. &NSVER;
  336. </section2>
  337. </section1>
  338. <section1 topic='XML Schema' anchor='schema'>
  339. <code><![CDATA[
  340. <?xml version='1.0' encoding='UTF-8'?>
  341. <xs:schema
  342. xmlns:xs=''
  343. targetNamespace='urn:xmpp:cmr:0'
  344. xmlns='urn:xmpp:cmr:0'
  345. elementFormDefault='qualified'>
  346. <xs:annotation>
  347. <xs:documentation>
  348. The protocol documented by this schema is defined in
  349. XEP-XXXX:
  350. </xs:documentation>
  351. </xs:annotation>
  352. <xs:element name='query'>
  353. <xs:complexType>
  354. <xs:sequence>
  355. <xs:element ref='active'
  356. minOccurs='1'
  357. maxOccurs='1'/>
  358. <xs:element ref='available'
  359. minOccurs='1'
  360. maxOccurs='unbounded'/>
  361. </xs:sequence>
  362. </xs:complexType>
  363. </xs:element>
  364. <xs:element name='active' type='cmrtype'/>
  365. <xs:element name='available' type='cmrtype'/>
  366. <xs:element name='cmr' type='cmrtype'/>
  367. <xs:complexType name='cmrtype'>
  368. <xs:complexType>
  369. <xs:attribute name='algorithm' type='xs:string' use='required'/>
  370. </xs:complexContent>
  371. </xs:complexType>
  372. </xs:schema>
  373. ]]></code>
  374. </section1>
  375. </xep>