Created
November 30, 2011 07:41
-
-
Save dth/1408357 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val myAddresses = Array(new Address("mq1", 5672), new Address("mq2", 5672)) | |
val connectionParameters = ConnectionParameters(myAddresses, "guest", "guest", "/") | |
val connection = AMQP.newConnection(connectionParameters) | |
val exchangeParameters = ExchangeParameters("foo", Direct, PassiveDeclaration) | |
val smallPrefetchChannelParameters = Some(ChannelParameters(prefetchSize = 0)) | |
AMQP.newConsumer( | |
connection = connection, | |
consumerParameters = ConsumerParameters( | |
routingKey = "bar", | |
deliveryHandler = Actor.actorOf(new JobConsumer(1)), | |
exchangeParameters = Some(exchangeParameters), | |
channelParameters = smallPrefetchChannelParameters)) | |
... | |
class JobConsumer(id: Int) extends Actor { | |
self.id = "jobconsumer-" + id | |
def receive = { | |
case Delivery(payload, _, _, _, _, _) => | |
println(self.id + " received message: " + new String(payload)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment