Debian Codegraph @

README

raw
1 NAME
2 AtomBus - An AtomPub server for messaging.
3
4 VERSION
5 version 1.0405
6
7 SYNOPSIS
8 use Dancer;
9 use AtomBus;
10 dance;
11
12 DESCRIPTION
13 AtomBus is an AtomPub server that can be used for messaging. The idea is
14 that atom feeds can correspond to conceptual queues or buses. AtomBus is
15 built on top of the Dancer framework. It is also pubsubhubbub friendly.
16
17 These examples assume that you have configured your web server to point
18 HTTP requests starting with /atombus to your AtomBus server (see
19 "DEPLOYMENT"). To publish an entry, make a HTTP POST request:
20
21 $ curl -d '<entry> <title>allo</title> <content type="xhtml">
22 <div xmlns="http://www.w3.org/1999/xhtml" >an important message</div>
23 </content> </entry>' http://localhost/atombus/feeds/widgets
24
25 That adds a new entry to a feed titled widgets. If that feed didn't
26 exist before, it will be created for you. To retrieve the widgets feed,
27 make a HTTP GET request:
28
29 $ curl http://localhost/atombus/feeds/widgets
30
31 Clients can request only entries that came after the last entry they
32 processed. They can do this by providing the id of the last message as
33 the start_after parameter:
34
35 $ curl http://localhost/atombus/feeds/widgets?start_after=42
36
37 Alternatively, you can provide a start_at param. This will retrieve
38 entries starting with the given id:
39
40 $ curl http://localhost/atombus/feeds/widgets?start_at=42
41
42 HTTP ETags are also supported. The server responds with an ETag header
43 for each request. The client can provide that ETag as the If-None-Match
44 header. The following example will work the same as if the client
45 provided a start_after parameter. Except that it will return an empty
46 body and a 304 status if there are no new entries. This is the behavior
47 that pubsubhubbub recommends
48 <http://code.google.com/p/pubsubhubbub/wiki/PublisherEfficiency>.
49
50 $ curl -H 'If-None-Match: "42"' http://localhost/atombus/feeds/widgets
51
52 Note that the most messages you will get per request is determined by
53 the page_size setting. If you do not specify a page_size setting, it
54 defaults to 1000. This default may change in the future, so don't count
55 on it.
56
57 AtomBus is mostly a proper implementation of the AtomPub protocol and
58 will validate 100% against <http://validator.w3.org/feed>. One point
59 where it diverges from the AtomPub spec is that feed entries are
60 returned in fifo order. This is because a message consumer will most
61 likely want to consume messages in the order that they were published.
62 In the future, a config setting may be available to reverse the order.
63
64 CONFIGURATION
65 Configuration can be achieved via a config.yml file or via the set
66 keyword. To use the config.yml approach, you will need to install YAML.
67 See the Dancer documentation for more information. The only required
68 config setting is the dsn.
69
70 Example config.yml:
71
72 # Dancer specific config settings
73 logger: file
74 log: errors
75
76 atombus:
77 page_size: 100
78 db:
79 dsn: dbi:mysql:database=atombus
80 user: joe
81 pass: momma
82
83 You can alternatively configure the server via the 'set' keyword in the
84 source code. This approach does not require a config file.
85
86 use Dancer;
87 use AtomBus;
88
89 # Dancer specific config settings
90 set logger => 'file';
91 set log => 'debug';
92 set show_errors => 1;
93
94 set atombus => {
95 page_size => 100,
96 db => {
97 dsn => 'dbi:SQLite:dbname=/var/local/atombus/atombus.db',
98 }
99 };
100
101 dance;
102
103 DATABASE
104 AtomBus is backed by a database. The dsn in the config must point to a
105 database which you have write privileges to. The tables will be created
106 automagically for you if they don't already exist. Of course that
107 requires create table privileges. All databases supported by DBIx::Class
108 are supported, which are most major databases including postgresql,
109 sqlite, mysql and oracle.
110
111 DEPLOYMENT
112 Deployment is very flexible. It can be run on a web server via CGI or
113 FastCGI. It can also be run on any Plack web server. See
114 Dancer::Deployment for more details.
115
116 FastCGI
117 AtomBus can be run via FastCGI. This requires that you have the FCGI and
118 Plack modules installed. Here is an example FastCGI script. It assumes
119 your AtomBus server is in the file atombus.pl.
120
121 #!/usr/bin/env perl
122 use Dancer ':syntax';
123 use Plack::Handler::FCGI;
124
125 my $app = do "/path/to/atombus.pl";
126 my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
127 $server->run($app);
128
129 Here is an example lighttpd config. It assumes you named the above file
130 atombus.fcgi.
131
132 fastcgi.server += (
133 "/atombus" => ((
134 "socket" => "/tmp/fcgi.sock",
135 "check-local" => "disable",
136 "bin-path" => "/path/to/atombus.fcgi",
137 )),
138 )
139
140 Now AtomBus will be running via FastCGI under /atombus.
141
142 Plack
143 AtomBus can be run with any Plack web server. Just run:
144
145 plackup atombus.pl
146
147 You can change the Plack web server via the -s option to plackup.
148
149 MOTIVATION
150 I like messaging systems because they make it so easy to create scalable
151 applications. Existing message brokers are great for creating message
152 queues. But once a consumer reads a message off of a queue, it is not
153 available for other consumers. I needed a system to publish events such
154 that multiple heterogeneous services could subscribe to them. So I
155 really needed a message bus, not a message queue. I could for example
156 have used something called topics in ActiveMQ, but I have found ActiveMQ
157 to be broken in general. An instance I manage has to be restarted daily.
158 AtomBus on the other hand will be extremely stable, because it is so
159 simple. It is in essence just a simple interface to a database. As long
160 as your database and web server are up, AtomBus will be there for you.
161 And there are many ways to add redundancy to databases and web heads.
162 Another advantage of using AtomBus is that Atom is a well known
163 standard. Everyone already has a client for it, their browser. Aren't
164 standards great! By the way, if you just need message queues, try
165 POE::Component::MessageQueue. It rocks. If you need a message bus, give
166 AtomBus a shot.
167
168 AUTHOR
169 Naveed Massjouni <[email protected]>
170
171 COPYRIGHT AND LICENSE
172 This software is copyright (c) 2010 by Naveed Massjouni.
173
174 This is free software; you can redistribute it and/or modify it under
175 the same terms as the Perl 5 programming language system itself.
176