Fork me on GitHub

cuspy memo


XEP-0060(1.2 How It Works)

2008/01/14 Monday 23:11:04

続き。

== How It Works ==

この仕様は大きいです、しかし pubsub の背後にある基本的なアイディアはとてもシンプルです。(see Publish an Item to a Node)

  1. 公開情報の実体を publish-subscribe サービスのノードへ送ります
  2. pubsub サービスはその公開情報を知ることを許可されたエンティティへ送信します。

恐らく、最も pubsub に似たコンテンツ配信機能を持ったアプリケーションはブログやニュースサイト、その他のインターネットで頻繁に更新さる情報に有効でよく知られるようになった RSS と Atom(RFC 4287) フィードです。<hamlet@denmark.lit> さんがブログを配信する例を考えてみましょう。Hamlet さんが新しいブログのエントリを書く時、ブログソフトウェアは <pubsub.shakespeare.lit> でホストする pubsub ノードへ配信を行います。

例1. Publisher Publishes a New Weblog Entry

<iq type='set'
    from='hamlet@denmark.lit/blogbot'
    to='pubsub.shakespeare.lit'
    id='pub1'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='princely_musings'>
      <item>
        <entry xmlns='http://www.w3.org/2005/Atom'>

          <title>Soliloquy</title>
          <summary>
To be, or not to be: that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them?
          </summary>
          <link rel='alternate' type='text/html'
                href='http://denmark.lit/2003/12/13/atom03'/>
          <id>tag:denmark.lit,2003:entry-32397</id>

          <published>2003-12-13T18:30:02Z</published>
          <updated>2003-12-13T18:30:02Z</updated>
        </entry>
      </item>
    </publish>

  </pubsub>
</iq>

つまりこれが publish-subscribe の “pub” の部分です。

この時 pubsub サービスは全ての購読者に新しいブログエントリを通知します。

例2. Service Notifies Subscribers

<message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='princely_musings'>

      <item id='ae890ac52d0df67ed7cfdf51b644e901'>
        [ ... ENTRY ... ]
      </item>
    </items>
  </event>
</message>

<message from='pubsub.shakespeare.lit' to='bernardo@denmark.lit' id='bar'>

  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='princely_musings'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'>
        [ ... ENTRY ... ]
      </item>
    </items>

  </event>
</message>

<message from='pubsub.shakespeare.lit' to='horatio@denmark.lit' id='baz'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='princely_musings'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'>

        [ ... ENTRY ... ]
      </item>
    </items>
  </event>
</message>

<message from='pubsub.shakespeare.lit' to='bard@shakespeare.lit' id='fez'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>

    <items node='princely_musings'>
      <item id='ae890ac52d0df67ed7cfdf51b644e901'>
        [ ... ENTRY ... ]
      </item>
    </items>
  </event>
</message>

これは一時的なノードが本文のない通知だけを行う簡単なサンプルです。

例3. A Transient Notification

<message from='pubsub.shakespeare.lit' to='francisco@denmark.lit'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='elsinore/doorbell'/>
  </event>
</message>

もちろん、これに関連した実体で全ての pubsub 機能を有効する為にはその他のユースケースを完全にする必要があるかもしれません。たとえば、配信者はノードを作成するが必要になるかもしれません(see Create a Node)、そして購読者は通知の為にサインアップする必要があるかもしれません(see Subscribe to a Node)。これらのユースケースはドキュメントの残りの部分で全て記載されています。(どの機能が必須で、どの機能が推奨か任意であるといった情報は Feature Summary を参考にして下さい。)

No comments yet.

Leave a comment

You must be logged in to post a comment.