Kinda starting to implement the hello world producer

This commit is contained in:
Dan Buch 2012-11-15 07:44:27 -05:00
parent a1c85158f0
commit 217fe20307

View File

@ -1,5 +1,21 @@
object Producer extends App { import com.rabbitmq.client._
println("OH HAI")
}
// vim: set ts=2 sw=2 et: object Producer extends App {
if (args.length < 1) {
println("You must provide a message argument")
} else {
var messageBody = args(0)
var factory = new ConnectionFactory()
factory.setUri("amqp://guest:guest@localhost:5672")
var connection = factory.newConnection()
var channel = connection.createChannel()
channel.exchangeDeclare("hello-exchange", "direct", true)
channel.queueDeclare("hello-queue", true, false, false, null)
println("Publishing ", messageBody)
channel.basicPublish("hello-exchange", "hola", null,
messageBody.toCharArray().map(_.toByte))
}
}