> Is there a well-defined way in Jetlang to limit the number of messages
> that can be sent on a particular channel?
>
> I have an actor which is subscribed to a MemoryChannel. There is a
> possibility that it can receive more requests/sec than it can process
> so eventually this could lead to an OutOfMemory exception.
Create a Subscribable that implements your policy for what to do when your limit is reached.
The default ChannelSubscription is pretty dumb in that it just delivers everything to the subscriber on its fiber.
-pete
--
(peter.royal|osi)@pobox.com - http://fotap.org/~osi
There are a couple solutions depending on your desired behavior.
1. Batching - Most of the time when I've run into this problem I've
solved it by using a batch subscriber or a keyed batch. This allows
the consumer to keep up with the producer. I typically don't want to
slow down the producer for any reason.
2. Producer Throttle - If you must slow down the producer, the
simplest solution is to limit by message rate. This will cause the
producer to block. In many cases this isn't optimal b/c the producer
doesn't know the capacity of the consumer. This solution is simple but
it doesn't give optimal throughput. The code you submitted won't work
for throttling since the same thread puts and polls from the queue.
Another thread is needed to pull from the queue. A better solution
would calculate the messages per second then wait if the rate is
exceeded. I would implement this as a simple Publisher decorator.
3. Fiber queue cap - For optimal throughput, the best solution is to
cap the internal fiber queue. With this solution, the producer is
blocked when the consumers queue reaches capacity. The producer will
immediately be signaled when space frees up. This requires a few
changes to the internals of jetlang.
Will any of the solutions work for you?
Mike
> --
> You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
> To post to this group, send email to jetla...@googlegroups.com.
> To unsubscribe from this group, send email to jetlang-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
>
>
http://code.google.com/p/jetlang/source/detail?r=523
One caveat is that the cap can cause a deadlock if the consuming
thread posts events back to its own full queue. This is a rare case
and can be fixed by using another fiber to post back events.
Let me know if this solves your problem.
Mike
Mike
I've started a new sub-project of jetlang that adds remoting to jetlang.
http://code.google.com/p/jetlang/source/browse/#svn%2Fserver
It might be of interest if you need a client server setup.
I don't know when I'll have a chance to add the queue capping to the
pool fiber since I'm actively working on the remoting implementation.
Mike
--
You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jetlang-dev/-/D6AQj4-WQdMJ.
To post to this group, send email to jetla...@googlegroups.com.
To unsubscribe from this group, send email to jetlang-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
To unsubscribe from this group, send email to jetlang-dev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/jetlang-dev/-/uCiYEZ6VqaoJ.
To post to this group, send email to jetla...@googlegroups.com.
To unsubscribe from this group, send email to jetlang-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
--
You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jetlang-dev/-/1PTAjj8mf3sJ.
To unsubscribe from this group, send email to jetlang-dev+unsubscribe@googlegroups.com.