Mercurial > projects > ldc
comparison tango/example/cluster/reply.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
1 private import tango.core.Thread; | |
2 | |
3 private import tango.util.log.Configurator; | |
4 | |
5 private import tango.net.cluster.tina.Cluster; | |
6 | |
7 private import tango.net.cluster.NetworkQueue; | |
8 | |
9 /******************************************************************************* | |
10 | |
11 *******************************************************************************/ | |
12 | |
13 void main() | |
14 { | |
15 // open the cluster and a queue channel. Note that the queue has | |
16 // been configured with a reply listener ... | |
17 auto cluster = (new Cluster).join; | |
18 auto queue = new NetworkQueue (cluster, "message.channel", | |
19 (IEvent event){event.log.info ("Received reply");} | |
20 ); | |
21 | |
22 void recipient (IEvent event) | |
23 { | |
24 auto msg = event.get; | |
25 | |
26 event.log.info ("Replying to message on channel "~msg.reply); | |
27 event.reply (event.replyChannel(msg), queue.EmptyMessage); | |
28 } | |
29 | |
30 // setup a listener to recieve and reply | |
31 queue.createConsumer (&recipient); | |
32 | |
33 // toss a message out to the cluster | |
34 queue.put (queue.EmptyMessage); | |
35 | |
36 // wait for completion ... | |
37 Thread.sleep (1); | |
38 } |