Skip to content

Commit

Permalink
Adds priority property to message and sorts local store by priority.
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardGatt committed Nov 7, 2023
1 parent 4a4d885 commit 3bd4851
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class Queue : GistListener {
}

private fun handleMessages(messages: List<Message>) {
for (message in messages) {
// Sorting messages by priority and placing nulls last.
val sortedMessages = messages.sortedWith(compareBy(nullsLast()) { it.priority })

Check warning on line 147 in messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt

View check run for this annotation

Codecov / codecov/patch

messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt#L147

Added line #L147 was not covered by tests
for (message in sortedMessages) {
processMessage(message)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data class GistProperties(
data class Message(
val messageId: String = "",
val instanceId: String = UUID.randomUUID().toString(),
val priority: Int? = null,
val queueId: String? = null,
val properties: Map<String, Any?>? = null
)
Expand Down

0 comments on commit 3bd4851

Please sign in to comment.