⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x712.htm

📁 Its a xmpp protocol book
💻 HTM
字号:
<HTML
><HEAD
><TITLE
>Component/Service Architecture</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Programming Jabber"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Inside Jabber"
HREF="c445.htm"><LINK
REL="PREVIOUS"
TITLE="Request/Response"
HREF="x624.htm"><LINK
REL="NEXT"
TITLE="Custom Clients"
HREF="x760.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Programming Jabber</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x624.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 2. Inside Jabber</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x760.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="JABTDG-CH-2-SECT-2.6"
>Component/Service Architecture</A
></H1
><P
>The original problem for Jabber to solve was to provide bridges to 
different IM systems; the upshot of the solution was a server design
that is ultimately as flexible as the imagination allows. Each
of the IM bridges, or <I
CLASS="EMPHASIS"
>transports</I
> as they are often
called, is a pluggable
component; the Jabber server architecture, examined in detail in
<A
HREF="c1223.htm"
>Chapter 4</A
>,
is a component-based architecture. The standard Jabber server distribution
comes with the components required to provide IM services, data storage and
server-to-server communication, for example. 
Each component is separately configurable and is made known to the server
through the inclusion of that configuration into the main configuration
structure. 

<A
NAME="JABTDG-CH-2-FOOTNOTE-4"
HREF="#FTN.JABTDG-CH-2-FOOTNOTE-4"
>[1]</A
>&#13;</P
><P
>Components, also known as <I
CLASS="EMPHASIS"
>modules</I
> or
<I
CLASS="EMPHASIS"
>services</I
>, can be, to a large
extent, platform agnostic. There are different methods by which
components can connect to and interact with the Jabber server. One method
of which uses low-level Jabber library functions (in C) to bind the 
component&mdash;built in the form of a shared library&mdash;to the server. The
other methods use either standard I/O (STDIO) in a process-spawning 
mechanism, or TCP sockets. </P
><P
>The former "library load" method and the STDIO method both require that
the component runs on the same host as the Jabber server itself; this 
isn't in fact as restrictive as it sounds; as you'll find out in 
<A
HREF="c1223.htm"
>Chapter 4</A
>
it is possible to run multiple 'instances' of a Jabber server across 
different hosts, each instance containing one or more components, in 
much the same way as an SAP R/3 system can exist as multiple instances, 
each instance running on a separate host and providing different services
(dialog, update, enqueue, message, background, gateway, spool) according
to configuration. </P
><P
>Would it surprise you to learn that the binding fluid that flows between
the Jabber server and components (and ultimately of course between Jabber 
clients and components) is XML? Of course not. In fact, it's the same
XML that flows between Jabber clients and servers.

<A
NAME="JABTDG-CH-2-FOOTNOTE-5"
HREF="#FTN.JABTDG-CH-2-FOOTNOTE-5"
>[2]</A
>
The
<TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
>, <TT
CLASS="LITERAL"
>&#60;iq/&#62;</TT
>
and <TT
CLASS="LITERAL"
>&#60;presence/&#62;</TT
> elements can all flow to and
from components&mdash;how a component handles or generates these elements reflects
the purpose of that component. As we saw in the imaginary conversation in
<A
HREF="c324.htm"
>Chapter 1</A
>,
components can also be addressed in the same way that other 
Jabber entities can be addressed:</P
><P
></P
><UL
><LI
><P
>As a whole, the JID is simply the name of the component, for example
<TT
CLASS="LITERAL"
>stocks.company-a.com</TT
>;</P
></LI
><LI
><P
>Using individual "users" as if they existed as separate entities within
that component, for example <TT
CLASS="LITERAL"
>MEGC@stocks.company-a.com</TT
>;</P
></LI
></UL
><P
>A version of this imaginary conversation will become reality in 
Part II
as we learn how to build our own components and attach them to the Jabber
server.</P
><P
>Although components are addressed in the same way that clients are addressed,
and the interaction is similar, there is one significant difference between
writing or using a <I
CLASS="EMPHASIS"
>client</I
> (which could just as well be
a stub connector for a service), and writing or using a 
<I
CLASS="EMPHASIS"
>component</I
>.</P
><P
>This difference is rooted in the Jabber server
architecture and becomes clear when we consider the nature of how the
components
provide their services. Messages sent to a client entity that is not connected
will be stored and forwarded to that entity the next time it connects and
becomes available. This is beause the client's connection is inherently 
hosted, or managed, by the standard component that provides IM services such
as availability handling and message queueing. This is the 
Jabber Session Manager (JSM) component. All clients are
handled this way and automatically partake of these features.
All entities that connect over a stream with the
<TT
CLASS="LITERAL"
>jabber:client</TT
> namespace are considered clients, and
their XML-based interaction is handled by the JSM.</P
><P
>Because other components connected to the Jabber server are themselves peer
components to the JSM component, no availability or message queueing is
available, as the JSM is only designed to handle client-connected entities.

<A
NAME="JABTDG-CH-2-FOOTNOTE-7"
HREF="#FTN.JABTDG-CH-2-FOOTNOTE-7"
>[3]</A
>

To put it another way:</P
><P
></P
><UL
><LI
><P
>Send a message to a client that's not connected and it will get 
stored until that client connects and becomes available again.</P
></LI
><LI
><P
>Send a message to a component that's not connected, and an error
will occur.</P
></LI
></UL
><P
>From a philosophical standpoint, this is fair enough, as you're trying to
address a (temporarily) nonexistent feature of the server. From a practical
standpoint, this is not usually a problem unless you're in the habit of 
bouncing your Jabber server to randomly connect or disconnect components. </P
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-2-FOOTNOTE-4"
HREF="x712.htm#JABTDG-CH-2-FOOTNOTE-4"
>[1]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>XML is indeed all-pervasive in Jabber; the configuration is also written
using XML.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-2-FOOTNOTE-5"
HREF="x712.htm#JABTDG-CH-2-FOOTNOTE-5"
>[2]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>There are extra message types that flow inside the server and between the
components,including <TT
CLASS="LITERAL"
>&#60;route/&#62;</TT
>, 
<TT
CLASS="LITERAL"
>&#60;xdb/&#62;</TT
>, and
<TT
CLASS="LITERAL"
>&#60;log/&#62;</TT
>. These message types are explained in 
<A
HREF="c1223.htm"
>Chapter 4</A
>.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-2-FOOTNOTE-7"
HREF="x712.htm#JABTDG-CH-2-FOOTNOTE-7"
>[3]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>The components that connect as separate entities (i.e., not those that are
written as shared libraries) do so over a stream that is described by
one of two namespaces, each beginning <TT
CLASS="LITERAL"
>jabber:component:</TT
>.
See <A
HREF="c1223.htm"
>Chapter 4</A
> and <A
HREF="c3612.htm"
>Chapter 5</A
>
for more details).</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x624.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x760.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Request/Response</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c445.htm"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Custom Clients</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -