Network Working Group S. Ferguson Internet-Draft Caucho Intended status: Standards Track February 9, 2012 Expires: August 12, 2012 The JSON Actor Message Protocol draft-ferg-jsmp-v2 Abstract The JSON Actor Message Protocol defines a bidirectional messaging protocol using JSON as a payload serialization format. Messages are typed and addressed. Both unidirectional messages and bidirectional queries are supported. JAMP can be sent on messaging framing protocols like WebSockets, HTTP (REST), or STOMP. Status of this Memo By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. This Internet-Draft will expire on August 12, 2012. Ferguson Expires August 12, 2012 [Page 1] Internet-Draft The JSON Actor Message Protocol February 2012 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. Requirements . . . . . . . . . . . . . . . . . . . . . . . . . 4 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 5 4. General Requirements . . . . . . . . . . . . . . . . . . . . . 6 4.1. Requirements . . . . . . . . . . . . . . . . . . . . . . . 6 4.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 6 4.3. Terminology . . . . . . . . . . . . . . . . . . . . . . . 6 4.4. Basic Rules . . . . . . . . . . . . . . . . . . . . . . . 7 5. Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 5.1. send . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 5.2. query . . . . . . . . . . . . . . . . . . . . . . . . . . 8 5.3. reply . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5.4. error-query . . . . . . . . . . . . . . . . . . . . . . . 9 5.5. error . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6. Security Considerations . . . . . . . . . . . . . . . . . . . 11 7. Normative References . . . . . . . . . . . . . . . . . . . . . 12 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 13 Intellectual Property and Copyright Statements . . . . . . . . . . 14 Ferguson Expires August 12, 2012 [Page 2] Internet-Draft The JSON Actor Message Protocol February 2012 1. Introduction The goal of JAMP is to provide structure for a JSON-based messaging over a WebSockets connection. JAMP supports: o named actions with parameters, enabling RPC-style messaging. o addressable actors on the client and servers, enabling encapsulation of services. o both unidirectional send and bidirectional query-reply pairs for both major messaging styles. o payloads encoded using JSON. Ferguson Expires August 12, 2012 [Page 3] Internet-Draft The JSON Actor Message Protocol February 2012 2. Requirements 1. JAMP must support unidirectional messages. 2. JAMP must support query-response pairs. 3. JAMP responses may be unordered to the querirs or messages. 4. JAMP must support named actions and parameters. 5. JAMP must support services, using addresses for routing. Ferguson Expires August 12, 2012 [Page 4] Internet-Draft The JSON Actor Message Protocol February 2012 3. Protocol Overview _This section is non-normative._ A unidirectional message looks as follows: ["send", "jamp+ws://target.example.com/to-actor", "jamp+ws://source.example.com/from-actor", "my_action", ["arg1", "arg2"]] Bidirectional queries consist of a "query" packet and a corresponding "reply" packet. The query and reply are correlated with a correlation-id, which is a 64-bit integer. The query/reply pair can be used to implement remote procedure calls (RPC) A service MUST response to a "query" with either a "reply" or a "error_reply" because the client will be waiting for the response. A query looks as follows: ["query", 12345, "jamp+http://target.example.com/service-actor", "jamp+http://source.example.com/query-actor", "my_action", ["my-arg1", "my-arg2"]] The corresponding reply looks as follows: ["reply", 12345, "jamp+http://source.example.com/query-actor", "jamp+http://target.example.com/service-actor", "my-result"] Addresses are strings in this specification, interpreted by the implementation. If the implementation does any routing, it is recommended to use URLs as addresses. Ferguson Expires August 12, 2012 [Page 5] Internet-Draft The JSON Actor Message Protocol February 2012 4. General Requirements 4.1. Requirements The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. An implementation is not compliant if it fails to satisfy one or more of the MUST or REQUIRED level requirements for the protocols it implements. An implementation that satisfies all the MUST or REQUIRED level and all the SHOULD level requirements for its protocols is said to be "unconditionally compliant"; one that satisfies all the MUST level requirements but not all the SHOULD level requirements for its protocols is said to be "conditionally compliant." 4.2. Syntax Notation This specification uses the Augmented Backus-Naur Form (ABNF) notation of [RFC5234]. The following core rules are included by reference, as defined in [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF (CR LF), DIGIT (decimal 0-9), OCTET (any 8-bit sequence of data), SP (space), VCHAR (any visible [USASCII] character), and WSP (whitespace). 4.3. Terminology This specification the following JAMP address: An opaque string representing JAMP actor. payload: A JSON value. type: A string representing a message type. Ferguson Expires August 12, 2012 [Page 6] Internet-Draft The JSON Actor Message Protocol February 2012 4.4. Basic Rules The following basic rules follow the definitions in HTTP [RFC2616]. type = 1* ( ALPHA / DIGIT / "_" / "." ) query_id = 1* DIGIT string = JSON string object = JSON object to-address = string from-address = string action-name = string parameters = parameter-list? parameter-list = object / object ',' parameterlist reply-object = object error-object = object Ferguson Expires August 12, 2012 [Page 7] Internet-Draft The JSON Actor Message Protocol February 2012 5. Messages The following 5 packets are the only message allowed for JAMP: message, query, reply, error_reply, error. The stream consists of a sequence of messages. message = send / query / reply / error-reply / error 5.1. send send is a unidirectional message. send grammar send ::= '[' "send" ',' to-address ',' from-address ',' action-name ',' '[' parameters ']' ']' A unidirectional message looks as follows: ["send", "jamp+ws://target.example.com/to-actor", "jamp+ws://source.example.com/from-actor", "my_action", ["arg1", "arg2"]] 5.2. query query is a bidirectional request for a response. A receiver MUST response with either a "reply" or a "error-query" Ferguson Expires August 12, 2012 [Page 8] Internet-Draft The JSON Actor Message Protocol February 2012 query grammar query ::= '[' "query" ',' query_id ',' to-address ',' from-address ',' action-name ',' '[' parameters ']' ']' Example: A query looks as follows: ["query", 12345, "jamp+http://target.example.com/service-actor", "jamp+ws://source.example.com/query-actor", "my_action", ["arg1", "arg2"]] 5.3. reply "reply" is a bidirectional response to a query. reply grammar reply ::= '[' "reply" ',' query_id ',' to-address ',' from-address ',' reply-object ']' Example: A reply looks as follows: ["reply", 12345, "jamp+http://source.example.com/client", "jamp+http://source.example.com/service", "my-result"] 5.4. error-query error-query is an error response to a query. Ferguson Expires August 12, 2012 [Page 9] Internet-Draft The JSON Actor Message Protocol February 2012 query-error grammar error_query ::= '[' "error_query" ',' query_id ',' to-address ',' from-address ',' error_object ']' A error query message looks as follows: ["error_query", 12345, "jamp+http://source.example.com/client", "jamp+http://source.example.com/service", {"type" : "internal-server-error", "message" : "the server was unable to process the request"}] 5.5. error 'error' is a general error in response to a message. It can be used to inform a client of service availability. error grammar error ::= '[' "error" ',' to-address ',' from-address ',' error-object ']' An error message looks as follows: ["error", "jamp+ws://source.example.com/my-actor", "jamp+ws://target.example.com/my-service", {"type": "service-not-found", "message": "'my-service' is an unknown service"}] Ferguson Expires August 12, 2012 [Page 10] Internet-Draft The JSON Actor Message Protocol February 2012 6. Security Considerations This section is meant to inform application developers and users of security issues related to JAMP. This list is unlikely to be complete. Ferguson Expires August 12, 2012 [Page 11] Internet-Draft The JSON Actor Message Protocol February 2012 7. Normative References [RFC2616] Fielding, R., Gettys, J., Mogul, J., Mainter, L., Leach, P., and T. Berners-Lee, "Hypertext Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003. [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, January 2008. Ferguson Expires August 12, 2012 [Page 12] Internet-Draft The JSON Actor Message Protocol February 2012 Author's Address Scott Ferguson Caucho Technology Ferguson Expires August 12, 2012 [Page 13] Internet-Draft The JSON Actor Message Protocol February 2012 Full Copyright Statement Copyright (C) The IETF Trust (2012). This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights. This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Intellectual Property The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79. Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr. The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org. Ferguson Expires August 12, 2012 [Page 14]