XEP-0254: PubSub Queueing

Abstract:This specification defines an extension to XMPP publish-subscribe for queueing information at a node.
Authors:Joe Hildebrand, Peter Saint-Andre
Copyright:© 1999 - 2009 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status:Deferred
Type:Standards Track
Version:0.1
Last Updated:2008-11-13

WARNING: Consideration of this document has been Deferred by the XMPP Standards Foundation. Implementation of the protocol described herein is not recommended.


Table of Contents


1. Introduction
2. How It Works
    2.1. Subscribing
    2.2. Assigning an Item
    2.3. Deleting an Item from the Queue
    2.4. Unlocking an Item
3. Determining Support
4. Implementation Notes
5. Security Considerations
6. IANA Considerations
7. XMPP Registrar Considerations
    7.1. Protocol Namespaces
    7.2. Protocol Versioning
    7.3. Service Discovery Features

Appendices
    A: Document Information
    B: Author Information
    C: Legal Notices
    D: Relation to XMPP
    E: Discussion Venue
    F: Requirements Conformance
    G: Notes
    H: Revision History


1. Introduction

The Publish-Subscribe [1] extension to XMPP provides a comprehensive technology for alerts, notifications, data syndication, rich presence, and other real-time messaging use cases. In terms of traditional publish-subscribe systems like Java Message Service (JMS), the core XMPP PubSub specification covers the Observer design pattern only; however, traditional publish-subscribe systems often include support for a second design pattern, usually called the "point-to-point" or "queueing" pattern. [2] This specification defines a few small extensions to XMPP PubSub that enable support for a queueing mode in XMPP. The queueing mode is an add-on feature that a service can support, and that a node owner can enable if supported by the service. The feature name is "urn:xmpp:pubsub:queueing:0".

2. How It Works

2.1 Subscribing

If a node has enabled support for the queueing mode, in response to a subscription request without configuration options it MUST return an IQ-error containing a subscription options form; this form MUST include the "queue_requests" field (which specifies the number of parallel requests a subscriber is willing to process).

Example 1. Service indicates that subscription configuration is required

<iq from='workflows.shakespeare.lit'
    id='sub1'
    to='workerbee237@shakespeare.lit/foo'
    type='error'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <subscribe
        jid='workerbee237@shakespeare.lit'
        node='a290fjsl29j19kjb'/>
    <options 
        jid='workerbee237@shakespeare.lit'
        node='a290fjsl29j19kjb'>
      <x xmlns='jabber:x:data' type='form'>
        <field var='FORM_TYPE' type='hidden'>
          <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
        </field>
        <field type='text-single' var='pubsub#queue_requests'>
          <required/>
        </field>
      </x>
    </options>
  </pubsub>
  <error type='modify'>
    <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <configuration-required xmlns='http://jabber.org/protocol/pubsub#errors'/>
  </error>
</iq>
    

The subscriber would then send a new subscription request, this time with options.

Example 2. Subscribing with options

<iq from='workerbee237@shakespeare.lit/foo'
    id='sub2'
    to='workflows.shakespeare.lit'
    type='set'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <subscribe
        jid='workerbee237@shakespeare.lit'
        node='a290fjsl29j19kjb'/>
    <options 
        jid='workerbee237@shakespeare.lit'
        node='a290fjsl29j19kjb'>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='FORM_TYPE' type='hidden'>
          <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
        </field>
        <field var='pubsub#queue_requests'>
          <value>5</value>
        </field>
      </x>
    </options>
  </pubsub>
</iq>
    

If the subscription request can be processed successfully, the service returns an IQ-result and includes the configuration options established during the negotiation.

Example 3. Service replies with success (including configuration options)

<iq from='workflows.shakespeare.lit'
    id='sub2'
    to='workerbee237@shakespeare.lit/foo'
    type='result'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <subscription
        jid='workerbee237@shakespeare.lit'
        node='a290fjsl29j19kjb'
        subid='ba49252aaa4f5d320c24d3766f0bdcade78c78d3'
        subscription='subscribed'/>
    <options>
      <x xmlns='jabber:x:data' type='result'>
        <field var='FORM_TYPE' type='hidden'>
          <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
        </field>
        <field var='pubsub#queue_requests'>
          <value>5</value>
        </field>
      </x>
    </options>
  </pubsub>
</iq>
    

2.2 Assigning an Item

At any time, a publisher can push an item to the queue node.

Example 4. Publisher publishes an item

<iq from='engine.shakespeare.lit'
    id='pub1'
    to='workflow.shakespeare.lit'
    type='set'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'>
        <example xmlns='urn:xmpp:example'>payload</example>
      </item>
    </publish>
  </pubsub>
</iq>
    

The item is published to one of the subscribers.

Example 5. One subscriber receives a notification

<message from='workflow.shakespeare.lit' 
         id='foo'
         to='workerbee237@shakespeare.lit'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'>
        <example xmlns='urn:xmpp:example'>payload</example>
      </item>
    </items>
  </event>
</message>
    

2.3 Deleting an Item from the Queue

When the subscriber that received the item has successfully processed it (whatever that means in the context of the queue), the subscriber deletes the item from the queue.

Example 6. Entity deletes an item from a node

<iq from='workerbee237@shakespeare.lit/foo'
    id='delete1'
    to='workflows.shakespeare.lit'
    type='get'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <retract node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </retract>
  </pubsub>
</iq>
    

In the context of a queue node, the service MUST treat a delete request from a subscriber that received the item as if the sender were a publisher; i.e., it MUST delete the item from the queue and notify only this subscriber that the item has been deleted.

Example 7. Subscriber receives delete notification

<message from='workflow.shakespeare.lit' 
         id='bar'
         to='workerbee237@shakespeare.lit'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='a290fjsl29j19kjb'>
      <retract id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </items>
  </event>
</message>
    

Note: The subscriber SHOULD NOT commit any pending transactions until it receives the delete notification.

If the item does not exist, the service MUST return an <item-not-found/> error as described in XEP-0060.

If the entity that attempts to delete the item is not the subscriber that received the item, the service MUST return a <forbidden/> error as described in XEP-0060.

If the item is locked by another subscriber, the service MUST return a <conflict/> error (this flow is not defined in XEP-0060.

Example 8. Item is locked by another subscriber

<iq from='workflows.shakespeare.lit'
    id='delete1'
    to='workerbee237@shakespeare.lit/foo'
    type='get'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <retract node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </retract>
  </pubsub>
  <error type='auth'>
    <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

If the subscriber that received the item attempts to delete the item but the item is no longer locked by the subscriber (e.g., because of a race condition or a lost notification), the service MUST return an <unexpected-request/> error (this flow is not defined in XEP-0060.

Example 9. Item is no longer locked by subscriber

<iq from='workflows.shakespeare.lit'
    id='delete1'
    to='workerbee237@shakespeare.lit/foo'
    type='get'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <retract node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </retract>
  </pubsub>
  <error type='wait'>
    <unexpected-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

2.4 Unlocking an Item

The subscriber might determine that it cannot process the item (whatever that means in the context of the queue); if so, the subscriber unlocks the item.

Example 10. Entity unlocks an item

<iq from='workerbee237@shakespeare.lit/foo'
    id='unlock1'
    to='workflows.shakespeare.lit'
    type='get'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <unlock xmlns='urn:xmpp:pubsub:queueing:0'
            node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </unlock>
  </pubsub>
</iq>
    

The service then MUST unlock the item and notify only this subscriber that the item has been unlocked.

Example 11. Subscriber receives unlock notification

<message from='workflow.shakespeare.lit' 
         id='baz'
         to='workerbee237@shakespeare.lit'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='a290fjsl29j19kjb'>
      <unlock xmlns='urn:xmpp:queueing:0'
              id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </items>
  </event>
</message>
    

When an item is unlocked, the service would then send a publish notification to another subscriber according to application-specific logic for determining the "next" subscriber.

If the item does not exist, the service MUST return an <item-not-found/> error.

Example 12. Item does not exist

<iq from='workflows.shakespeare.lit'
    id='delete1'
    to='workerbee237@shakespeare.lit/foo'
    type='error'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <unlock xmlns='urn:xmpp:pubsub:queueing:0'
            node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </unlock>
  </pubsub>
  <error type='cancel'>
    <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

If the entity that attempts to unlock the item is not the subscriber that received the item, the service MUST return a <forbidden/> error.

Example 13. Requesting entity did not receive item

<iq from='workflows.shakespeare.lit'
    id='delete1'
    to='workerbee237@shakespeare.lit/foo'
    type='error'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <unlock xmlns='urn:xmpp:pubsub:queueing:0'
            node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </unlock>
  </pubsub>
  <error type='auth'>
    <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

If the item is locked by another subscriber, the service MUST return a <conflict/> error.

Example 14. Item is locked by another subscriber

<iq from='workflows.shakespeare.lit'
    id='delete1'
    to='workerbee237@shakespeare.lit/foo'
    type='error'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <unlock xmlns='urn:xmpp:pubsub:queueing:0'
            node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </unlock>
  </pubsub>
  <error type='cancel'>
    <conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

If the subscriber that received the item attempts to unlock the item but the item is no longer locked by the subscriber (e.g., because of a race condition or a lost notification), the service MUST return an <unexpected-request/> error.

Example 15. Item is no longer locked by subscriber

<iq from='workflows.shakespeare.lit'
    id='delete1'
    to='workerbee237@shakespeare.lit/foo'
    type='error'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <unlock xmlns='urn:xmpp:pubsub:queueing:0'
            node='a290fjsl29j19kjb'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
    </unlock>
  </pubsub>
  <error type='wait'>
    <unexpected-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

3. Determining Support

If a pubsub service supports the queueing mode, it MUST advertise support for the "urn:xmpp:pubsub:queueing:0" namespace in response to Service Discovery [3] information requests.

4. Implementation Notes

If the service receives unavailable presence from a subscriber, it SHOULD unlock all outstanding queue items associated with the subscriber and unsubscribe the subscriber to prevent delivery of further publish notifications.

If a subscriber cannot process queue items because of an unrecoverable error (e.g., disk full), the subscriber SHOULD unsubscribe and then unlock all of its outstanding queue items.

If the service does not receive a delete or unlock request from a subscriber that received a queue item in a configurable amount of time, it SHOULD timeout the request, send an unlock notification to the subscriber, and send a publish notification to the "next" subscriber.

5. Security Considerations

To follow.

6. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [4].

7. XMPP Registrar Considerations

7.1 Protocol Namespaces

This specification defines the following XML namespace:

Upon advancement of this specification from a status of Experimental to a status of Draft, the XMPP Registrar [5] shall add the foregoing namespaces to the registry located at <http://xmpp.org/registrar/namespaces.html>, as described in Section 4 of XMPP Registrar Function [6].

7.2 Protocol Versioning

If the protocol defined in this specification undergoes a revision that is not fully backwards-compatible with an older version, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of XEP-0053.

7.3 Service Discovery Features

The XMPP Registrar [7] maintains a registry of service discovery features (see <http://xmpp.org/registrar/disco-features.html>), which includes a number of features that can be returned by pubsub services. The following registry submission supplements the existing list.

<var>
  <name>urn:xmpp:pubsub:queueing:0</name>
  <desc>The node or service supports the queueing mode.</desc>
  <doc>XEP-xxxx</doc>
</var>
    

Appendices


Appendix A: Document Information

Series: XEP
Number: 0254
Publisher: XMPP Standards Foundation
Status: Deferred
Type: Standards Track
Version: 0.1
Last Updated: 2008-11-13
Approving Body: XMPP Council
Dependencies: XMPP Core, XEP-0060
Supersedes: None
Superseded By: None
Short Name: NOT_YET_ASSIGNED
Source Control: HTML  RSS


Appendix B: Author Information

Joe Hildebrand

Email: jhildebr@cisco.com
JabberID: hildjj@jabber.org

Peter Saint-Andre

Email: stpeter@jabber.org
JabberID: stpeter@jabber.org
URI: https://stpeter.im/


Appendix C: Legal Notices

Copyright

This XMPP Extension Protocol is copyright © 1999 - 2009 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <http://xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XMPP Standards Foundation, c/o Peter Saint-Andre, 1899 Wynkoop Street, Suite 600, Denver, CO 80202 USA).

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.


Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.


Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Appendix G: Notes

1. XEP-0060: Publish-Subscribe <http://xmpp.org/extensions/xep-0060.html>.

2. See for instance <http://en.wikipedia.org/wiki/Java_Message_Service>.

3. XEP-0030: Service Discovery <http://xmpp.org/extensions/xep-0030.html>.

4. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

5. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.

6. XEP-0053: XMPP Registrar Function <http://xmpp.org/extensions/xep-0053.html>.

7. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.


Appendix H: Revision History

Version 0.1 (2008-11-13)

Initial published version.

(psa)

Version 0.0.3 (2008-10-07)

Added more detailed error flows; added additional implementation notes.

(jjh/psa)

Version 0.0.2 (2008-10-07)

(jjh/psa)

Version 0.0.1 (2008-08-14)

First draft.

(psa/jjh)

END