Job scheduler as a message queue

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Job scheduler as a message queue

Boris Hamanov
Say, a user registers on my site, through a form; I am running a service
that does the registration.

Now suppose 10 users use the form simultaneously and submit their
registration at approximately the same time. My service is called 10 times.
I want to guarantee that one and ONLY ONE instance of my
registration service runs at any given time.

I need that because in my specific scenario each subsequent registration
depends on the previous ones.

Can I make my service asynchronous and use the job scheduler to achieve my
goal?


Thanks in advance ;)
Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Sakthivel Vellingiri
Boris -

Job Scheduler be used for timed invocation of services and perhaps not
suitable for this usecase;

I'm guessing, you need a queue data-structure to hold the registration
requests and a dedicated worker thread clearing off the queue;

- Regards

On 4/19/12, Boris Hamanov <[hidden email]> wrote:

> Say, a user registers on my site, through a form; I am running a service
> that does the registration.
>
> Now suppose 10 users use the form simultaneously and submit their
> registration at approximately the same time. My service is called 10 times.
> I want to guarantee that one and ONLY ONE instance of my
> registration service runs at any given time.
>
> I need that because in my specific scenario each subsequent registration
> depends on the previous ones.
>
> Can I make my service asynchronous and use the job scheduler to achieve my
> goal?
>
>
> Thanks in advance ;)
>

--
Sent from my mobile device
Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Boris Hamanov
Hi Integrin

It looks to me that Job Scheduler could be suitable as it works like a queue
already. No need to reinvent the hot water :) I could safe myself some work
and a lot of testing there.

Anyone more knowledgable about how the Job Scheduler works?
What happens it you put the same service several times inside? Any way to
specify that only one thread should be devoted to one service name?

-----Original Message-----
From: Integrin
Date: 19 април 2012 г. 20:41 ч.
To: [hidden email]
Subject: Re: Job scheduler as a message queue

Boris -

Job Scheduler be used for timed invocation of services and perhaps not
suitable for this usecase;

I'm guessing, you need a queue data-structure to hold the registration
requests and a dedicated worker thread clearing off the queue;

- Regards

On 4/19/12, Boris Hamanov <[hidden email]> wrote:

> Say, a user registers on my site, through a form; I am running a service
> that does the registration.
>
> Now suppose 10 users use the form simultaneously and submit their
> registration at approximately the same time. My service is called 10
> times.
> I want to guarantee that one and ONLY ONE instance of my
> registration service runs at any given time.
>
> I need that because in my specific scenario each subsequent registration
> depends on the previous ones.
>
> Can I make my service asynchronous and use the job scheduler to achieve my
> goal?
>
>
> Thanks in advance ;)
>

--
Sent from my mobile device

Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Sakthivel Vellingiri
Boris -

Quote from
http://ofbiz.apache.org/docs/services.html

The scheduler is a multithreaded component with a single thread used
for job managing/scheduling and separate threads used for invocation
of each service. When a job is scheduled to run, the scheduler will
call the service dispatcher associated with the job to invoke the
service in its own thread. This will prevent long or time consuming
jobs from slowing down other jobs in the queue.

I hear your intent to limit JobScheduler to use a single thread for a
service; I have to admit i did not need to use JobScheduler that way;
and will wait for framework experts to comment;

- Regards
Sakthi


On 4/19/12, Boris Hamanov <[hidden email]> wrote:

> Hi Integrin
>
> It looks to me that Job Scheduler could be suitable as it works like a queue
> already. No need to reinvent the hot water :) I could safe myself some work
> and a lot of testing there.
>
> Anyone more knowledgable about how the Job Scheduler works?
> What happens it you put the same service several times inside? Any way to
> specify that only one thread should be devoted to one service name?
>
> -----Original Message-----
> From: Integrin
> Date: 19 април 2012 г. 20:41 ч.
> To: [hidden email]
> Subject: Re: Job scheduler as a message queue
>
> Boris -
>
> Job Scheduler be used for timed invocation of services and perhaps not
> suitable for this usecase;
>
> I'm guessing, you need a queue data-structure to hold the registration
> requests and a dedicated worker thread clearing off the queue;
>
> - Regards
>
> On 4/19/12, Boris Hamanov <[hidden email]> wrote:
>> Say, a user registers on my site, through a form; I am running a service
>> that does the registration.
>>
>> Now suppose 10 users use the form simultaneously and submit their
>> registration at approximately the same time. My service is called 10
>> times.
>> I want to guarantee that one and ONLY ONE instance of my
>> registration service runs at any given time.
>>
>> I need that because in my specific scenario each subsequent registration
>> depends on the previous ones.
>>
>> Can I make my service asynchronous and use the job scheduler to achieve my
>> goal?
>>
>>
>> Thanks in advance ;)
>>
>
> --
> Sent from my mobile device
>
>

--
Sent from my mobile device
Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Jacques Le Roux
Administrator
In reply to this post by Boris Hamanov
Simply use the semaphore attribute of the service, with value wait
See also semaphore-wait-seconds & semaphore-sleep

Jacques

From: "Boris Hamanov" <[hidden email]>

> Say, a user registers on my site, through a form; I am running a service
> that does the registration.
>
> Now suppose 10 users use the form simultaneously and submit their
> registration at approximately the same time. My service is called 10 times.
> I want to guarantee that one and ONLY ONE instance of my
> registration service runs at any given time.
>
> I need that because in my specific scenario each subsequent registration
> depends on the previous ones.
>
> Can I make my service asynchronous and use the job scheduler to achieve my
> goal?
>
>
> Thanks in advance ;)
>
Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Boris Hamanov
Thank you Jacques!

I looked at semaphore-wait-seconds & semaphore-sleep there is no
documentation in the schema, how the whole thing works?

-----Original Message-----
From: Jacques Le Roux
Date: 20 април 2012 г. 00:20 ч.
To: [hidden email]
Subject: Re: Job scheduler as a message queue

Simply use the semaphore attribute of the service, with value wait
See also semaphore-wait-seconds & semaphore-sleep

Jacques

From: "Boris Hamanov" <[hidden email]>

> Say, a user registers on my site, through a form; I am running a service
> that does the registration.
>
> Now suppose 10 users use the form simultaneously and submit their
> registration at approximately the same time. My service is called 10
> times.
> I want to guarantee that one and ONLY ONE instance of my
> registration service runs at any given time.
>
> I need that because in my specific scenario each subsequent registration
> depends on the previous ones.
>
> Can I make my service asynchronous and use the job scheduler to achieve my
> goal?
>
>
> Thanks in advance ;)
>

Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Jacques Le Roux
Administrator
https://cwiki.apache.org/confluence/display/OFBTECH/Service+Engine+Guide#ServiceEngineGuide-SERVICEELEMENT

Jacques

From: "Boris Hamanov" <[hidden email]>

> Thank you Jacques!
>
> I looked at semaphore-wait-seconds & semaphore-sleep there is no documentation in the schema, how the whole thing works?
>
> -----Original Message-----
> From: Jacques Le Roux
> Date: 20 април 2012 г. 00:20 ч.
> To: [hidden email]
> Subject: Re: Job scheduler as a message queue
>
> Simply use the semaphore attribute of the service, with value wait
> See also semaphore-wait-seconds & semaphore-sleep
>
> Jacques
>
> From: "Boris Hamanov" <[hidden email]>
>> Say, a user registers on my site, through a form; I am running a service
>> that does the registration.
>>
>> Now suppose 10 users use the form simultaneously and submit their
>> registration at approximately the same time. My service is called 10 times.
>> I want to guarantee that one and ONLY ONE instance of my
>> registration service runs at any given time.
>>
>> I need that because in my specific scenario each subsequent registration
>> depends on the previous ones.
>>
>> Can I make my service asynchronous and use the job scheduler to achieve my
>> goal?
>>
>>
>> Thanks in advance ;)
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Job scheduler as a message queue

Boris Hamanov
Very useful documention there! Thanks Jacques, you really made my day!

-----Original Message-----
From: Jacques Le Roux
Date: 25 април 2012 г. 00:25 ч.
To: [hidden email]
Subject: Re: Job scheduler as a message queue

https://cwiki.apache.org/confluence/display/OFBTECH/Service+Engine+Guide#ServiceEngineGuide-SERVICEELEMENT

Jacques

From: "Boris Hamanov" <[hidden email]>

> Thank you Jacques!
>
> I looked at semaphore-wait-seconds & semaphore-sleep there is no
> documentation in the schema, how the whole thing works?
>
> -----Original Message-----
> From: Jacques Le Roux
> Date: 20 април 2012 г. 00:20 ч.
> To: [hidden email]
> Subject: Re: Job scheduler as a message queue
>
> Simply use the semaphore attribute of the service, with value wait
> See also semaphore-wait-seconds & semaphore-sleep
>
> Jacques
>
> From: "Boris Hamanov" <[hidden email]>
>> Say, a user registers on my site, through a form; I am running a service
>> that does the registration.
>>
>> Now suppose 10 users use the form simultaneously and submit their
>> registration at approximately the same time. My service is called 10
>> times.
>> I want to guarantee that one and ONLY ONE instance of my
>> registration service runs at any given time.
>>
>> I need that because in my specific scenario each subsequent registration
>> depends on the previous ones.
>>
>> Can I make my service asynchronous and use the job scheduler to achieve
>> my
>> goal?
>>
>>
>> Thanks in advance ;)
>>
>