How to put a message to top of the mailbox queue for immediate processing?

87 views
Skip to first unread message

MV

unread,
Apr 8, 2014, 6:43:07 AM4/8/14
to akka...@googlegroups.com
Hello,

I have a use case where there are multiple ConsistenteHashingPool workers. Their mailboxes can contain many messages but if a 'CANCEL REQUEST (w/Request ID) comes into the system, then I need to put this at the top of the queue. Process this message and mark other messages in the actor's MAILBOX with this ID as invalid.

What is the best way for me to achieve this?

I can only use release version of AKKA = 2.3.1 or 2.2.3.
I saw that the 2.4-SNAPSHOT message has the ControlMessage and mailbox for that message, but since it is a snapshot version, my SCM will not approve use of that version.

Thanks in advance,
Meena


Martynas Mickevičius

unread,
Apr 8, 2014, 10:58:44 AM4/8/14
to akka...@googlegroups.com
You could use BoundedPriorityMailbox in your router. More info here.

Also, make sure that 'CANCEL REQUEST' message produces the same hash value for the hashing pool as the message you want to cancel. Otherwise 'CANCEL REQUEST' message could be routed to a worker which will not ever get the message to be canceled.

--
Martynas Mickevičius
Typesafe – Reactive Apps on the JVM

MV

unread,
Apr 8, 2014, 12:51:28 PM4/8/14
to akka...@googlegroups.com
Hi Martynas

Thanks for getting back to me. I guess my problem is also to figure out how to delete the messages in the mailbox for this specific request ID.
Basically, the mailbox will have multiple messages for the same requestID with different time slices. So when I get a cancel request for the specific ID, I want to also remove the existing messages in the mailbox for this ID.
I could not find a nice and easy way to accomplish this.

Is there anything in the AKKA framework for something like this?

Thanks
Meena

√iktor Ҡlang

unread,
Apr 8, 2014, 12:56:18 PM4/8/14
to Akka User List
Hi Meena,

You don't need to delete them, you just need to ignore them.
Deleting messages in the mailbox is going to me much costlier than ignoring them.


--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

MV

unread,
Apr 8, 2014, 2:08:34 PM4/8/14
to akka...@googlegroups.com
Sorry for the naive question - but how do I ignore them?
Let's say have these messages in the mailbox for Request 1:

Req1_time_slice_1
Req1_time_slice_2
Req1_time_slice_3
Req1_time_slice_4
Req1_time_slice_5
Req1_CANCEL_MESSAGE

Ideally with the PriorityMailBox - I will assume this situation:
  • Req1_time_slice_1 (OFF THE QUEUE) and being processed in onReceive()
  • Req1_CANCEL_MESSAGE BUBBLES to postion 2 because of PriorityMailBox
  • NOW - I need to ignore the following messages in the mailbox:
    • Req1_time_slice_2
    • Req1_time_slice_3
    • Req1_time_slice_4
    • Req1_time_slice_5

How is that achieved in Akka?

I apologize for the naive question as I am new to Akka and trying to wrap it in my head :-)
Meena

√iktor Ҡlang

unread,
Apr 8, 2014, 2:11:42 PM4/8/14
to Akka User List
On Tue, Apr 8, 2014 at 8:08 PM, MV <mee...@gmail.com> wrote:
Sorry for the naive question - but how do I ignore them?
Let's say have these messages in the mailbox for Request 1:

Req1_time_slice_1
Req1_time_slice_2
Req1_time_slice_3
Req1_time_slice_4
Req1_time_slice_5
Req1_CANCEL_MESSAGE

Ideally with the PriorityMailBox - I will assume this situation:
  • Req1_time_slice_1 (OFF THE QUEUE) and being processed in onReceive()
  • Req1_CANCEL_MESSAGE BUBBLES to postion 2 because of PriorityMailBox
  • NOW - I need to ignore the following messages in the mailbox:
    • Req1_time_slice_2
    • Req1_time_slice_3
    • Req1_time_slice_4
    • Req1_time_slice_5

How is that achieved in Akka?

When you get the cancel message, you store in your actor that if you receive a Req_1 message you just discard it.



--
Cheers,
Reply all
Reply to author
Forward
0 new messages