I need to publish a task by name (creating a message on a queue with task name passed in headers, passing some args).
I've done this in Celery (Python) like this:
celery_app.send_task("task_name", args=("arg1", "arg2",))
Here's my code in Go to do the same thing:
headers := make(amqp.Table)
headers["argsrepr"] = []string{"arg1", "arg2"}
headers["task"] = "task_name"
body := ""
jsonBody, _ := json.Marshal(body)
err = ch.Publish(
"", // exchange
"queue_name", // routing key
false, // mandatory
false, // immediate
amqp.Publishing {
DeliveryMode: amqp.Persistent,
ContentType: "application/json",
Body: jsonBody,
Headers: headers,
})
But I get this error:
Failed to publish a message: table field "argsrepr" value [%!t(string=arg1) %!t(string=arg2)] not supported
I'm using "github.com/streadway/amqp"
library to talk with my rabbitmq node. It seems that "send task by name" is not implemented in this library.