-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmsgqueue.pas
More file actions
36 lines (28 loc) · 713 Bytes
/
msgqueue.pas
File metadata and controls
36 lines (28 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
Simple message queuing broker
Same as request-reply broker but using shared queue proxy
@author cpicanco <cpicanco@ufpa.br>
}
program msgqueue;
{$mode objfpc}{$H+}
uses zmq;
var
context, frontend, backend: Pointer;
rc: Integer;
begin
context := zmq_ctx_new;
// Socket facing clients
frontend := zmq_socket(context, ZMQ_ROUTER);
rc := zmq_bind(frontend, 'tcp://*:5559');
Assert(rc = 0);
// Socket facing services
backend := zmq_socket(context, ZMQ_DEALER);
rc := zmq_bind(backend, 'tcp://*:5560');
Assert(rc = 0);
// Start the proxy
zmq_proxy(frontend, backend, nil);
// We never get here…
zmq_close(frontend);
zmq_close(backend);
zmq_ctx_destroy(context);
end.