Created
March 13, 2017 09:21
-
-
Save Geal/73f88fc3cd94a4cfd836729920e57263 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Client.new(<some TCP or TLS stream>) | |
.connect() //will start the handshake of 7 or so messages, returns a future that resolves once the handshake is done | |
.and_then(|client| { | |
client.create_channel() // returns a future that resolves once the channel is created | |
.map(|channel| { | |
channel | |
.queue("queue_name") // returns a future that resolves once the queue is declared | |
.and_then(|queue| { | |
queue.publish(|queue| { | |
queue.send(message) | |
}) | |
}) | |
}) | |
}); | |
client.create_channel() // returns a future that resolves once the channel is created | |
.map(|channel| { | |
channel | |
.queue("queue_name") // returns a future that resolves once the queue is declared | |
.and_then(|queue| { | |
queue.consume(|message| { | |
//handle messages here | |
}) | |
}) | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment