Getting bytes of string more elegantly

This commit is contained in:
Dan Buch 2012-11-15 08:10:39 -05:00
parent 374c5e03fa
commit b8a0654107

View File

@ -14,9 +14,8 @@ object HelloWorldProducer extends App {
channel.exchangeDeclare("hello-exchange", "direct", true)
channel.queueDeclare("hello-queue", false, false, false, null)
println("Publishing ", messageBody)
channel.basicPublish("hello-exchange", "hola", null,
messageBody.toCharArray().map(_.toByte))
printf("Publishing '%s'\n", messageBody)
channel.basicPublish("hello-exchange", "hola", null, messageBody.getBytes())
connection.close()
}