| 1 |
|
| 2 |
<HTML> |
| 3 |
<HEAD> |
| 4 |
<TITLE>The XPA Message Bus (xpamb)</TITLE> |
| 5 |
</HEAD> |
| 6 |
<BODY> |
| 7 |
|
| 8 |
|
| 9 |
<H2><A NAME="xpamb">xpamb: the XPA Message Bus</A></H2> |
| 10 |
|
| 11 |
|
| 12 |
<H2>Summary</H2> |
| 13 |
<P> |
| 14 |
The xpamb program can act as a "classical" message bus interface |
| 15 |
between clients and servers. A client can send a data request to |
| 16 |
the message bus, which then interfaces with multiple servers and |
| 17 |
returns the data back to the client. |
| 18 |
|
| 19 |
|
| 20 |
<H2>Description</H2> |
| 21 |
<P> |
| 22 |
A "classical" message bus (such as ToolTalk) consists of servers and |
| 23 |
clients, along with a mediating program that transfers data between |
| 24 |
different processes. XPA takes a slightly different approach in that |
| 25 |
communication between clients and servers is direct. This generally |
| 26 |
is the correct technique when there is only one connection (or even a |
| 27 |
small number of connections), but can become inefficient for the |
| 28 |
serving program if a large amount of data is being transferred to many |
| 29 |
clients. For example, if a real-time data acquisition program is |
| 30 |
broadcasting a FITS image to several clients, it would need to |
| 31 |
transmit that image to each client individually. This might interfere |
| 32 |
with its own processing cycles. The preferable mechanism would be to |
| 33 |
pass the image off to an intermediate program that can then broadcast |
| 34 |
the data to the several clients. |
| 35 |
<P> |
| 36 |
The <B>xpamb</B> program can alleviate such problems by functioning |
| 37 |
as a message bus in cases where such an intermediary process is |
| 38 |
wanted. It pre-defines a single access point named |
| 39 |
<B>XPAMB:xpamb</B> to which data can be sent for re-broadcast. You |
| 40 |
also can tell <B>xpamb</B> to save the data, and associate with that |
| 41 |
data a new access point, so that it can be retrieved later on. |
| 42 |
|
| 43 |
<P> |
| 44 |
All interaction with <B>xpamb</B> is performed through |
| 45 |
<B>xpaset</B> and <B>xpaget</B> (or the corresponding API |
| 46 |
routines, <B>XPASet()</B> and <B>XPAGet()</B>) to the |
| 47 |
<B>XPAMB:xpamb</B> access point. That is, <B>xpamb</B> is just |
| 48 |
another XPA-enabled program that responds to requests from |
| 49 |
clients. The paramlist is used to specify the targets to which |
| 50 |
the data will be for re-broadcast, as well as the re-broadcast paramlist: |
| 51 |
<PRE> |
| 52 |
data | xpaset xpamb [switches] broadcast-target broadcast-paramlist |
| 53 |
</PRE> |
| 54 |
Optional switches are used to store data, and manipulate stored data, |
| 55 |
and are described below. |
| 56 |
|
| 57 |
<P> |
| 58 |
In its simplest form, you can, for example, send a FITS image to xpamb for |
| 59 |
broadcasting to all ds9 image simply by executing: |
| 60 |
<PRE> |
| 61 |
cat foo.fits | xpaset xpamb "DS9:*" fits foo.fits |
| 62 |
</PRE> |
| 63 |
Since <B>DS9</B> is the class name for the ds9 image display |
| 64 |
program, this will result in the FITS image being re-sent to all fits |
| 65 |
access points for all active image display programs. |
| 66 |
|
| 67 |
<P> |
| 68 |
You can send stored data and new data to the same set of access points at |
| 69 |
the same time. The stored data always is send first, followed by the new |
| 70 |
data: |
| 71 |
<PRE> |
| 72 |
cat foo2.fits | xpaset xpamb -send foo "DS9:*" fits foo.fits |
| 73 |
</PRE> |
| 74 |
will first send the foo.fits file, and then the foo2.fits file to all |
| 75 |
access points of class <B>DS9</B>. Notice that in this example, |
| 76 |
the foo2.fits file is not stored, but it could be stored by using the |
| 77 |
<B>-store [name]</B> switch on the command line. |
| 78 |
|
| 79 |
<P> |
| 80 |
The <B>xpaget</B> command can be used to retrieve a data from XPA |
| 81 |
access points or from a stored data buffer, or retrieve information |
| 82 |
about a stored data buffer. If no arguments are given: |
| 83 |
<PRE> |
| 84 |
xpaget xpamb |
| 85 |
</PRE> |
| 86 |
then information about all currently stored data buffers is returned. This |
| 87 |
information includes the data and time at which the data was stored, the |
| 88 |
size in bytes of the data, and the supplied info string. |
| 89 |
|
| 90 |
<P> |
| 91 |
If arguments are specified, they will be in the form: |
| 92 |
<PRE> |
| 93 |
xpaget xpamb [-info] [-data] [name [paramlist]] |
| 94 |
</PRE> |
| 95 |
If the optional <B>-info</B> and/or <B>-data</B> switches are specified, then |
| 96 |
information and/or data will be returned for the named data buffer |
| 97 |
following the switches. You can use either or both of these switches |
| 98 |
in a single command. For example, if the -info switch is used: |
| 99 |
<PRE> |
| 100 |
xpaget xpamb -info foo |
| 101 |
</PRE> |
| 102 |
then the info about that stored data buffer will be returned. |
| 103 |
If the -data is used with a specific name: |
| 104 |
<PRE> |
| 105 |
xpaget xpamb -data foo |
| 106 |
</PRE> |
| 107 |
then the stored data itself will be returned. If both are used: |
| 108 |
<PRE> |
| 109 |
xpaget xpamb -info -data foo |
| 110 |
</PRE> |
| 111 |
then the info will be returned, followed by the data. Note that it is an |
| 112 |
error to specify one of these switches without a data buffer name and that |
| 113 |
the paramlist will be ignored. |
| 114 |
|
| 115 |
<P> |
| 116 |
If neither the <B>-info</B> or <B>-data</B> switch is specified, then |
| 117 |
the name refers to an XPA access point (with an optional paramlist |
| 118 |
following). |
| 119 |
For example: |
| 120 |
<PRE> |
| 121 |
xpaget xpamb ds9 file |
| 122 |
</PRE> |
| 123 |
is equivalent to: |
| 124 |
<PRE> |
| 125 |
xpaget ds9 file |
| 126 |
</PRE> |
| 127 |
|
| 128 |
|
| 129 |
<H2>Options</H2> |
| 130 |
<P> |
| 131 |
For xpaset, several optional switches are used to save data and |
| 132 |
manipulate the stored data: |
| 133 |
<DL> |
| 134 |
|
| 135 |
<P> |
| 136 |
<DT><B>-data [name]</B> |
| 137 |
<DD> Add the supplied data buffer to a pool of stored data buffers, |
| 138 |
using the specified name as a unique identifier for later retrieval. |
| 139 |
An error occurs if the name already exists (use either <B>replace</B> |
| 140 |
or <B>del</B> to rectify this). The <B>-add</B> switch is supported |
| 141 |
for backwards compatibility with xpa 2.0. |
| 142 |
|
| 143 |
<P> |
| 144 |
<DT><B>-replace [name]</B> |
| 145 |
<DD> Replace previously existing stored data having the same unique name |
| 146 |
with new data. This essentially is a combination of the <B>del</B> |
| 147 |
and <B>data</B> commands. |
| 148 |
|
| 149 |
<P> |
| 150 |
<DT><B>-info ["'info string'"]</B> |
| 151 |
<DD> When adding a data buffer, you can specify an informational |
| 152 |
string to be stored with that data. This string will be returned |
| 153 |
by xpaget: |
| 154 |
<PRE> |
| 155 |
xpaget xpamb foo -info |
| 156 |
</PRE> |
| 157 |
(along with other information such as the date/time of storage and the size of |
| 158 |
the data buffer) if the -info switch is specified. If the info string contains |
| 159 |
spaces, you must enclose it in <B>two</B> sets of quotes: |
| 160 |
<PRE> |
| 161 |
cat foo | xpaset xpamb -store foo -info "'this is info on foo'" |
| 162 |
</PRE> |
| 163 |
The first set of quotes is removed by the shell while the second is used to |
| 164 |
delineate the info string. |
| 165 |
|
| 166 |
<P> |
| 167 |
<DT><B>-send [name]</B> |
| 168 |
<DD> Broadcast the stored data buffer to the named template. |
| 169 |
|
| 170 |
<P> |
| 171 |
<DT><B>-del [name]</B> |
| 172 |
<DD> Delete the named data buffer and free all allocated space. |
| 173 |
</DL> |
| 174 |
|
| 175 |
<P> |
| 176 |
Switches can be used in any combination that makes sense. For example: |
| 177 |
<PRE> |
| 178 |
cat foo.fits | xpaset xpamb -store foo -info "FITS" "DS9:*" fits foo.fits |
| 179 |
</PRE> |
| 180 |
will broadcast the foo.fits image to all access points of class |
| 181 |
<B>DS9</B>. In addition, the foo.fits file will be stored under the |
| 182 |
name of <B>foo</B> for later manipulation such as: |
| 183 |
<PRE> |
| 184 |
xpaset -p xpamb -send foo "DS9:*" fits foo.fits |
| 185 |
</PRE> |
| 186 |
will re-broadcast the foo.fits image to all access points of class "DS9". |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
<P> |
| 193 |
<A HREF="./help.html">Go to XPA Help Index</A> |
| 194 |
|
| 195 |
<H5>Last updated: September 10, 2003</H5> |
| 196 |
</BODY> |
| 197 |
</HTML> |