@@ -33,43 +33,41 @@ A message received from a queue can also have the following attributes:
33
33
| remaining | Int32 | Number of messages remaining in the queue. |
34
34
35
35
36
- ```` julia
36
+ ``` julia
37
37
# create a message with 10 bytes of random value as data
38
38
msg = Message (rand (UInt8, 10 ))
39
39
40
40
# create a persistent plain text message
41
- data = convert (Vector{UInt8}, " hello world" )
41
+ data = convert (Vector{UInt8}, codeunits ( " hello world" ) )
42
42
msg = Message (data, content_type= " text/plain" , delivery_mode= PERSISTENT)
43
- ````
43
+ ```
44
44
45
45
Messages are published to an exchange, optionally specifying a routing key.
46
46
47
- ```` julia
47
+ ``` julia
48
48
EXCG_DIRECT = " MyDirectExcg"
49
49
ROUTE1 = " routingkey1"
50
50
51
51
basic_publish (chan1, msg; exchange= EXCG_DIRECT, routing_key= ROUTE1)
52
- ````
52
+ ```
53
53
54
54
To poll a queue for messages:
55
55
56
- ```` julia
57
- maybe_msg = basic_get (chan1, QUEUE1, false )
56
+ ``` julia
57
+ msg = basic_get (chan1, QUEUE1, false )
58
58
59
59
# check if we got a message
60
- if ! isnull (maybe_msg)
61
- msg = get (maybe_msg)
62
-
60
+ if msg != = nothing
63
61
# process msg...
64
62
65
63
# acknowledge receipt
66
64
basic_ack (chan1, msg. delivery_tag)
67
65
end
68
- ````
66
+ ```
69
67
70
68
To subscribe for messages (register an asynchronous callback):
71
69
72
- ```` julia
70
+ ``` julia
73
71
# define a callback function to process messages
74
72
function consumer (msg)
75
73
# process msg...
@@ -89,4 +87,4 @@ println("consumer registered with tag $consumer_tag")
89
87
90
88
# unsubscribe the consumer from the queue
91
89
basic_cancel (chan1, consumer_tag)
92
- ````
90
+ ```
0 commit comments