JuliaComputing / AMQPClient.jl

A Julia AMQP (Advanced Message Queuing Protocol) / RabbitMQ Client.
Other
39 stars 21 forks source link

basic_publish should accept simple String / sub-string as message #63

Open scls19fr opened 1 year ago

scls19fr commented 1 year ago

Hello,

Trying to convert https://www.rabbitmq.com/tutorials/tutorial-one-python.html to Julia (*), I noticed that API of this AMQPClient.jl could probably be improved to accept String / sub-string (ie without creating explicitly a Message)

For example the following Python code

channel.basic_publish(exchange='',
                      routing_key='hello',
                      body=data)

can be converted to Julia

# create a persistent plain text message
data = convert(Vector{UInt8}, codeunits("hello world"))
msg = Message(data, content_type="text/plain", delivery_mode=PERSISTENT)
basic_publish(chan1, msg; exchange="", routing_key="hello")

why not having simply?

basic_publish(chan1, "Hello World!"; exchange="", routing_key="hello")

Kind regards

(*) https://github.com/rabbitmq/rabbitmq-tutorials/tree/main/julia provides now such tutorial