Created
July 5, 2011 20:45
-
-
Save bwmcadams/1065879 to your computer and use it in GitHub Desktop.
FindAndRemove Snippet
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
def dequeue: MessageInvocation = withErrorHandling { | |
/** | |
* Retrieves first item in natural order (oldest first, assuming no modification/move) | |
* Waits 3 seconds for now for a message, else pops back out. | |
* TODO - How do we handle fetch, but sleep if nothing is in there cleanly? | |
* TODO - Should we have a specific query in place? Which way do we sort? | |
* TODO - Error handling version! | |
*/ | |
val msgInvocation = new DefaultPromise[MessageInvocation](3000) | |
db.findAndRemove(collName)(Document.empty) { msg: MongoDurableMessage => | |
EventHandler.debug(this, | |
"\nDEQUEUING message in mongo-based mailbox [%s]".format(msg)) | |
msgInvocation.completeWithResult(msg.messageInvocation()) | |
EventHandler.debug(this, | |
"\nDEQUEUING messageInvocation in mongo-based mailbox [%s]".format(msgInvocation)) | |
} | |
msgInvocation.get | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment