Gary Shea wrote:
> Hi Berin --
>
> I'm using the Event queueing stuff in a number of places and loving it.
>
> I'd like to use it to build a LogQueue, where the sink places entries
> a log on disk, and the source pulls them from the disk log. The main
> issue is the sink, which I would rather didn't delete the log entry
> until processing the entry is completed.
>
> This is not exactly a SEDA scenario, but it seems to fitsin with your
> transactional source ideas...
>
> Thoughts?
As far as the queueing goes, if you have a set of events that you want
to prepare and commit as a group, use the preparedEnqueue() function.
As far as working with a "LogQueue", I think the best approach is to
make a new type of event. SOmething along the lines of a LogEvent
with a "commit" or "release" method would work. There are a number
of ways you can put it together, but here is just one:
class LogEntry
{
public Object event;
void done();
}
As your LogQueue reads the entries from the disk log, it adds them
to the LogEntry that is the object dequeued() from the LogQueue.
Whatever processes your LogEntry calls the done() method, which
provides a signal back to the LogQueue that the entry is safe to
delete.
The downside to the approach is that you have to explicitly say
that the entry is done being processed. Also, the stages that
process the events need to know thaty they are dealing with a
LogEntry.
Another approach is to use Proxying, which adds some functionality
to the event without forcing the subsequent stages to test for a
LogEntry. You can override the finallizer to provide notification
to the LogQueue (completely invisible, but doesn't work when you
pool entry instances), or override a final method that is always
called on the event (still invisible, works when entries are pooled,
but requires specific knowledge of the event types).
Anyway, that should get you started.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]