Ask about EVENT
Thursday, 23 February 2012 · 4 messages · last reply 1 Mar 2012
T
truc.cam23 Feb 2012 10:18 #
Dear BaseX team,
I'd like to ask you why my class not run properly. I'm using EVENT to notify changes from xquery. It must print numbers from 1 to 10, 50 times for each number. Why does it skip some numbers in a random manner? How can I do to correct it?
Please see my attachment.
Thanks in advance.
DP
Dimitar Popov23 Feb 2012 11:52 #
Hi,
The problem is that the event listener in ClientSession does not buffer the input from the server correctly, i.e. asynchronously.
Anyway, if you implement a simple producer-consumer pattern[1] in your code, you should get correct results. But, of course, this should be implemented by the ClientSession and not by you.
Dimitar
[1] http://en.wikipedia.org/wiki/Producer-consumer_problem
Quoted text · +0100 · 12 lines
Am Donnerstag, den 23.02.2012, 10:18 +0100 schrieb truc.cam at emotive.de: > Dear BaseX team, > I'd like to ask you why my class not run properly. I'm using EVENT to > notify changes from xquery. It must print numbers from 1 to 10, 50 > times for each number. Why does it skip some numbers in a random > manner? How can I do to correct it? > Please see my attachment. > Thanks in advance. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
AW
Andreas Weiler24 Feb 2012 11:52 #
Hi,
thanks for reporting, i will take care of this issue.
Andreas
Quoted text · Dimitar Popov · 32 lines
Am 23.02.2012 um 11:52 schrieb Dimitar Popov: > Hi, > > The problem is that the event listener in ClientSession does not buffer > the input from the server correctly, i.e. asynchronously. > > Anyway, if you implement a simple producer-consumer pattern[1] in your > code, you should get correct results. But, of course, this should be > implemented by the ClientSession and not by you. > > Dimitar > > [1] http://en.wikipedia.org/wiki/Producer-consumer_problem > > Am Donnerstag, den 23.02.2012, 10:18 +0100 schrieb truc.cam at emotive.de: >> Dear BaseX team, >> I'd like to ask you why my class not run properly. I'm using EVENT to >> notify changes from xquery. It must print numbers from 1 to 10, 50 >> times for each number. Why does it skip some numbers in a random >> manner? How can I do to correct it? >> Please see my attachment. >> Thanks in advance. >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
AW
Hi,
the problem is that you call the session2.close() method before all items are printed out in the for loop in the notify method of the notifier. This closes the session2 before all items from the event are received.
Just implement a mechanism, which is waiting for all items of the event before closing the session.
-- Andreas
Quoted text · Dimitar Popov · 32 lines
Am 23.02.2012 um 11:52 schrieb Dimitar Popov: > Hi, > > The problem is that the event listener in ClientSession does not buffer > the input from the server correctly, i.e. asynchronously. > > Anyway, if you implement a simple producer-consumer pattern[1] in your > code, you should get correct results. But, of course, this should be > implemented by the ClientSession and not by you. > > Dimitar > > [1] http://en.wikipedia.org/wiki/Producer-consumer_problem > > Am Donnerstag, den 23.02.2012, 10:18 +0100 schrieb truc.cam at emotive.de: >> Dear BaseX team, >> I'd like to ask you why my class not run properly. I'm using EVENT to >> notify changes from xquery. It must print numbers from 1 to 10, 50 >> times for each number. Why does it skip some numbers in a random >> manner? How can I do to correct it? >> Please see my attachment. >> Thanks in advance. >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 7.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery