132
|
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 }
|