Quantcast

Recommendations for a periodic background service

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Recommendations for a periodic background service

Juan Asensio Sánchez
Hi

Not specific to Grails,

I Need to implement in my application a system that continuously
checks some data with SNMP from the hosts configured in the
application. I have read about Quartz, Quartz2, Executor, JMS and
ActiveMQ plugins, but I don't know how to handle the situation. I need
a service that periodically (the frequency must be able to be changed
at runtime) fetch the list of hosts from database, and then put them
in a queue; another multi-threaded process (the number of threads must
be also configurable) will then fetch the SNMP data from each host, so
I can have 5 process obtaining data from the hosts, and when one of
them finishes, pop a host from the queue and process it, and so on.

Next time the list of hosts is fetched, I must be able to check if the
queue contains already that host (perhaps if the queue has not been
yet finished in the time between executions)...

I am stuck with this now... Any suggestion is welcome.

Thanks.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Recommendations for a periodic background service

rlovtangen
This can be achieved with Grails.

I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
The service could use GPars to fetch SNMP data from multiple hosts in parallel.
Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.

To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.


This is what I have in BuildConfig.groovy for snmp4j:

        mavenRepo "https://server.oosnmp.net/dist/release/"
        ...
        compile 'org.snmp4j:snmp4j:1.11.2'
        compile 'org.snmp4j:snmp4j-agent:1.4.2'

* or the quartz2 plugin, if quartz plugin is not updated for Grails 2.0

Ronny

On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:

> Hi
>
> Not specific to Grails,
>
> I Need to implement in my application a system that continuously
> checks some data with SNMP from the hosts configured in the
> application. I have read about Quartz, Quartz2, Executor, JMS and
> ActiveMQ plugins, but I don't know how to handle the situation. I need
> a service that periodically (the frequency must be able to be changed
> at runtime) fetch the list of hosts from database, and then put them
> in a queue; another multi-threaded process (the number of threads must
> be also configurable) will then fetch the SNMP data from each host, so
> I can have 5 process obtaining data from the hosts, and when one of
> them finishes, pop a host from the queue and process it, and so on.
>
> Next time the list of hosts is fetched, I must be able to check if the
> queue contains already that host (perhaps if the queue has not been
> yet finished in the time between executions)...
>
> I am stuck with this now... Any suggestion is welcome.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Recommendations for a periodic background service

Juan Asensio Sánchez
Hi Ronny

Thank you very much for your answer. The SNMP part is already resolved
(although I need a SNMP client, it is not simple anyway). In your
answer, how can I apply the "queue"? The quartz process would add all
the hosts in a queue, and the service must continuously check if there
is any host in the queue, processing up to 5 at the same time, popping
more hosts when finished (should be the service another quartz job, an
executor, ...)?

Regards.


2012/6/21 Ronny Løvtangen <[hidden email]>:

> This can be achieved with Grails.
>
> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>
> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>
>
> This is what I have in BuildConfig.groovy for snmp4j:
>
>        mavenRepo "https://server.oosnmp.net/dist/release/"
>        ...
>        compile 'org.snmp4j:snmp4j:1.11.2'
>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>
> * or the quartz2 plugin, if quartz plugin is not updated for Grails 2.0
>
> Ronny
>
> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>
>> Hi
>>
>> Not specific to Grails,
>>
>> I Need to implement in my application a system that continuously
>> checks some data with SNMP from the hosts configured in the
>> application. I have read about Quartz, Quartz2, Executor, JMS and
>> ActiveMQ plugins, but I don't know how to handle the situation. I need
>> a service that periodically (the frequency must be able to be changed
>> at runtime) fetch the list of hosts from database, and then put them
>> in a queue; another multi-threaded process (the number of threads must
>> be also configurable) will then fetch the SNMP data from each host, so
>> I can have 5 process obtaining data from the hosts, and when one of
>> them finishes, pop a host from the queue and process it, and so on.
>>
>> Next time the list of hosts is fetched, I must be able to check if the
>> queue contains already that host (perhaps if the queue has not been
>> yet finished in the time between executions)...
>>
>> I am stuck with this now... Any suggestion is welcome.
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Recommendations for a periodic background service

jonspalmer
I'd also checkout the Jesque plugin which supports scheduled jobs as well as a very lightweight queuing support.

-----Original Message-----
From: Juan Asensio Sánchez [mailto:[hidden email]]
Sent: Wednesday, June 20, 2012 6:33 PM
To: [hidden email]
Subject: Re: [grails-user] Recommendations for a periodic background service

Hi Ronny

Thank you very much for your answer. The SNMP part is already resolved (although I need a SNMP client, it is not simple anyway). In your answer, how can I apply the "queue"? The quartz process would add all the hosts in a queue, and the service must continuously check if there is any host in the queue, processing up to 5 at the same time, popping more hosts when finished (should be the service another quartz job, an executor, ...)?

Regards.


2012/6/21 Ronny Løvtangen <[hidden email]>:

> This can be achieved with Grails.
>
> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>
> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>
>
> This is what I have in BuildConfig.groovy for snmp4j:
>
>        mavenRepo "https://server.oosnmp.net/dist/release/"
>        ...
>        compile 'org.snmp4j:snmp4j:1.11.2'
>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>
> * or the quartz2 plugin, if quartz plugin is not updated for Grails
> 2.0
>
> Ronny
>
> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>
>> Hi
>>
>> Not specific to Grails,
>>
>> I Need to implement in my application a system that continuously
>> checks some data with SNMP from the hosts configured in the
>> application. I have read about Quartz, Quartz2, Executor, JMS and
>> ActiveMQ plugins, but I don't know how to handle the situation. I
>> need a service that periodically (the frequency must be able to be
>> changed at runtime) fetch the list of hosts from database, and then
>> put them in a queue; another multi-threaded process (the number of
>> threads must be also configurable) will then fetch the SNMP data from
>> each host, so I can have 5 process obtaining data from the hosts, and
>> when one of them finishes, pop a host from the queue and process it, and so on.
>>
>> Next time the list of hosts is fetched, I must be able to check if
>> the queue contains already that host (perhaps if the queue has not
>> been yet finished in the time between executions)...
>>
>> I am stuck with this now... Any suggestion is welcome.
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Recommendations for a periodic background service

rlovtangen
In reply to this post by Juan Asensio Sánchez
Hi Juan,

I haven't really thought through the implementation details, but I'm sure GPars has some programming model that fits this use case well. Maybe having 5 Actors (http://gpars.codehaus.org/Actor) that you can send messages to containing the host to retrieve.
The quarts job would then only be responsible for sending messages to the Actors, and the Actors will process the messages, 5 at a time. Haven't really used Actors myself, but sounds like they are a good fit for this job? Or maybe someone with more experience with GPars has some better ideas.

Ronny

On Jun 21, 2012, at 12:33 AM, Juan Asensio Sánchez wrote:

> Hi Ronny
>
> Thank you very much for your answer. The SNMP part is already resolved
> (although I need a SNMP client, it is not simple anyway). In your
> answer, how can I apply the "queue"? The quartz process would add all
> the hosts in a queue, and the service must continuously check if there
> is any host in the queue, processing up to 5 at the same time, popping
> more hosts when finished (should be the service another quartz job, an
> executor, ...)?
>
> Regards.
>
>
> 2012/6/21 Ronny Løvtangen <[hidden email]>:
>> This can be achieved with Grails.
>>
>> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
>> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
>> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>>
>> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>>
>>
>> This is what I have in BuildConfig.groovy for snmp4j:
>>
>>        mavenRepo "https://server.oosnmp.net/dist/release/"
>>        ...
>>        compile 'org.snmp4j:snmp4j:1.11.2'
>>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>>
>> * or the quartz2 plugin, if quartz plugin is not updated for Grails 2.0
>>
>> Ronny
>>
>> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>>
>>> Hi
>>>
>>> Not specific to Grails,
>>>
>>> I Need to implement in my application a system that continuously
>>> checks some data with SNMP from the hosts configured in the
>>> application. I have read about Quartz, Quartz2, Executor, JMS and
>>> ActiveMQ plugins, but I don't know how to handle the situation. I need
>>> a service that periodically (the frequency must be able to be changed
>>> at runtime) fetch the list of hosts from database, and then put them
>>> in a queue; another multi-threaded process (the number of threads must
>>> be also configurable) will then fetch the SNMP data from each host, so
>>> I can have 5 process obtaining data from the hosts, and when one of
>>> them finishes, pop a host from the queue and process it, and so on.
>>>
>>> Next time the list of hosts is fetched, I must be able to check if the
>>> queue contains already that host (perhaps if the queue has not been
>>> yet finished in the time between executions)...
>>>
>>> I am stuck with this now... Any suggestion is welcome.
>>>
>>> Thanks.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Recommendations for a periodic background service

Juan Asensio Sánchez
In reply to this post by jonspalmer
Hi Jon and Ronny

It looks like the Jesque plugin is the more approximate concept about
what I need. But I have some doubts:

- The process that periodically checks for objects in database must be
anyway a Quartz Job, isn't it?
- It is not possible to enqueue a Job in the first position of the
queue (I need this to allow users from web interface to manually force
the SNMP data collect inmediatelly for a host)?
- I can not check if a host (or host.id) is already in the queue, so i
can not avoid the host to be many times in the queue, growing the
queue infintely.
- I don't like the idea about have another service (the Redis service)
running in the server

About GPars, I have not found much documentation or examples, but is
is also a good approximate approach, but I can't understand well the
system. I would have in a service a pooled "gpars thing", resizable,
that continuously looks the queue and process its data; any simple
example? Also, could I reorder the elements in the queue?

Thanks again.



2012/6/21 Jon Palmer <[hidden email]>:

> I'd also checkout the Jesque plugin which supports scheduled jobs as well as a very lightweight queuing support.
>
> -----Original Message-----
> From: Juan Asensio Sánchez [mailto:[hidden email]]
> Sent: Wednesday, June 20, 2012 6:33 PM
> To: [hidden email]
> Subject: Re: [grails-user] Recommendations for a periodic background service
>
> Hi Ronny
>
> Thank you very much for your answer. The SNMP part is already resolved (although I need a SNMP client, it is not simple anyway). In your answer, how can I apply the "queue"? The quartz process would add all the hosts in a queue, and the service must continuously check if there is any host in the queue, processing up to 5 at the same time, popping more hosts when finished (should be the service another quartz job, an executor, ...)?
>
> Regards.
>
>
> 2012/6/21 Ronny Løvtangen <[hidden email]>:
>> This can be achieved with Grails.
>>
>> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
>> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
>> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>>
>> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>>
>>
>> This is what I have in BuildConfig.groovy for snmp4j:
>>
>>        mavenRepo "https://server.oosnmp.net/dist/release/"
>>        ...
>>        compile 'org.snmp4j:snmp4j:1.11.2'
>>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>>
>> * or the quartz2 plugin, if quartz plugin is not updated for Grails
>> 2.0
>>
>> Ronny
>>
>> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>>
>>> Hi
>>>
>>> Not specific to Grails,
>>>
>>> I Need to implement in my application a system that continuously
>>> checks some data with SNMP from the hosts configured in the
>>> application. I have read about Quartz, Quartz2, Executor, JMS and
>>> ActiveMQ plugins, but I don't know how to handle the situation. I
>>> need a service that periodically (the frequency must be able to be
>>> changed at runtime) fetch the list of hosts from database, and then
>>> put them in a queue; another multi-threaded process (the number of
>>> threads must be also configurable) will then fetch the SNMP data from
>>> each host, so I can have 5 process obtaining data from the hosts, and
>>> when one of them finishes, pop a host from the queue and process it, and so on.
>>>
>>> Next time the list of hosts is fetched, I must be able to check if
>>> the queue contains already that host (perhaps if the queue has not
>>> been yet finished in the time between executions)...
>>>
>>> I am stuck with this now... Any suggestion is welcome.
>>>
>>> Thanks.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
>
>
> This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Recommendations for a periodic background service

jonspalmer
Juan,

 - Jesque can have scheduled jobs much like (well inspired by) Quartz. You just declare the Cron schedule in the Job class and Jesque takes care of scheduling it for you.
 - Jesque supports different named queues. You can have different workers tasked to work on different queues or one pool of workers tasked to work on a set of queues in a defined order. If you created a different queue for the user initiated requests then you could ensure they get processed ahead of the scheduled jobs.
 - Checking if a job is in the queue already is harder. I'd ask does it really matter if multiple users schedule 'the same' job or a job that is going to execute soon on a schedule?
 - Redis on your server? Yup you have to be ok with that. My experience has been that it's easy to install, has a very small footprint (especially if its just managing state of the queues) and is rock solidly stable.

Jon

-----Original Message-----
From: Juan Asensio Sánchez [mailto:[hidden email]]
Sent: Thursday, June 21, 2012 4:21 AM
To: [hidden email]
Cc: Jon Palmer; [hidden email]
Subject: Re: [grails-user] Recommendations for a periodic background service

Hi Jon and Ronny

It looks like the Jesque plugin is the more approximate concept about what I need. But I have some doubts:

- The process that periodically checks for objects in database must be anyway a Quartz Job, isn't it?
- It is not possible to enqueue a Job in the first position of the queue (I need this to allow users from web interface to manually force the SNMP data collect inmediatelly for a host)?
- I can not check if a host (or host.id) is already in the queue, so i can not avoid the host to be many times in the queue, growing the queue infintely.
- I don't like the idea about have another service (the Redis service) running in the server

About GPars, I have not found much documentation or examples, but is is also a good approximate approach, but I can't understand well the system. I would have in a service a pooled "gpars thing", resizable, that continuously looks the queue and process its data; any simple example? Also, could I reorder the elements in the queue?

Thanks again.



2012/6/21 Jon Palmer <[hidden email]>:

> I'd also checkout the Jesque plugin which supports scheduled jobs as well as a very lightweight queuing support.
>
> -----Original Message-----
> From: Juan Asensio Sánchez [mailto:[hidden email]]
> Sent: Wednesday, June 20, 2012 6:33 PM
> To: [hidden email]
> Subject: Re: [grails-user] Recommendations for a periodic background
> service
>
> Hi Ronny
>
> Thank you very much for your answer. The SNMP part is already resolved (although I need a SNMP client, it is not simple anyway). In your answer, how can I apply the "queue"? The quartz process would add all the hosts in a queue, and the service must continuously check if there is any host in the queue, processing up to 5 at the same time, popping more hosts when finished (should be the service another quartz job, an executor, ...)?
>
> Regards.
>
>
> 2012/6/21 Ronny Løvtangen <[hidden email]>:
>> This can be achieved with Grails.
>>
>> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
>> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
>> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>>
>> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>>
>>
>> This is what I have in BuildConfig.groovy for snmp4j:
>>
>>        mavenRepo "https://server.oosnmp.net/dist/release/"
>>        ...
>>        compile 'org.snmp4j:snmp4j:1.11.2'
>>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>>
>> * or the quartz2 plugin, if quartz plugin is not updated for Grails
>> 2.0
>>
>> Ronny
>>
>> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>>
>>> Hi
>>>
>>> Not specific to Grails,
>>>
>>> I Need to implement in my application a system that continuously
>>> checks some data with SNMP from the hosts configured in the
>>> application. I have read about Quartz, Quartz2, Executor, JMS and
>>> ActiveMQ plugins, but I don't know how to handle the situation. I
>>> need a service that periodically (the frequency must be able to be
>>> changed at runtime) fetch the list of hosts from database, and then
>>> put them in a queue; another multi-threaded process (the number of
>>> threads must be also configurable) will then fetch the SNMP data
>>> from each host, so I can have 5 process obtaining data from the
>>> hosts, and when one of them finishes, pop a host from the queue and process it, and so on.
>>>
>>> Next time the list of hosts is fetched, I must be able to check if
>>> the queue contains already that host (perhaps if the queue has not
>>> been yet finished in the time between executions)...
>>>
>>> I am stuck with this now... Any suggestion is welcome.
>>>
>>> Thanks.
>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
>
>
> This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Recommendations for a periodic background service

Juan Asensio Sánchez
Thanks, I will try and post my solution if any.

Regards.


2012/6/21 Jon Palmer <[hidden email]>:

> Juan,
>
>  - Jesque can have scheduled jobs much like (well inspired by) Quartz. You just declare the Cron schedule in the Job class and Jesque takes care of scheduling it for you.
>  - Jesque supports different named queues. You can have different workers tasked to work on different queues or one pool of workers tasked to work on a set of queues in a defined order. If you created a different queue for the user initiated requests then you could ensure they get processed ahead of the scheduled jobs.
>  - Checking if a job is in the queue already is harder. I'd ask does it really matter if multiple users schedule 'the same' job or a job that is going to execute soon on a schedule?
>  - Redis on your server? Yup you have to be ok with that. My experience has been that it's easy to install, has a very small footprint (especially if its just managing state of the queues) and is rock solidly stable.
>
> Jon
>
> -----Original Message-----
> From: Juan Asensio Sánchez [mailto:[hidden email]]
> Sent: Thursday, June 21, 2012 4:21 AM
> To: [hidden email]
> Cc: Jon Palmer; [hidden email]
> Subject: Re: [grails-user] Recommendations for a periodic background service
>
> Hi Jon and Ronny
>
> It looks like the Jesque plugin is the more approximate concept about what I need. But I have some doubts:
>
> - The process that periodically checks for objects in database must be anyway a Quartz Job, isn't it?
> - It is not possible to enqueue a Job in the first position of the queue (I need this to allow users from web interface to manually force the SNMP data collect inmediatelly for a host)?
> - I can not check if a host (or host.id) is already in the queue, so i can not avoid the host to be many times in the queue, growing the queue infintely.
> - I don't like the idea about have another service (the Redis service) running in the server
>
> About GPars, I have not found much documentation or examples, but is is also a good approximate approach, but I can't understand well the system. I would have in a service a pooled "gpars thing", resizable, that continuously looks the queue and process its data; any simple example? Also, could I reorder the elements in the queue?
>
> Thanks again.
>
>
>
> 2012/6/21 Jon Palmer <[hidden email]>:
>> I'd also checkout the Jesque plugin which supports scheduled jobs as well as a very lightweight queuing support.
>>
>> -----Original Message-----
>> From: Juan Asensio Sánchez [mailto:[hidden email]]
>> Sent: Wednesday, June 20, 2012 6:33 PM
>> To: [hidden email]
>> Subject: Re: [grails-user] Recommendations for a periodic background
>> service
>>
>> Hi Ronny
>>
>> Thank you very much for your answer. The SNMP part is already resolved (although I need a SNMP client, it is not simple anyway). In your answer, how can I apply the "queue"? The quartz process would add all the hosts in a queue, and the service must continuously check if there is any host in the queue, processing up to 5 at the same time, popping more hosts when finished (should be the service another quartz job, an executor, ...)?
>>
>> Regards.
>>
>>
>> 2012/6/21 Ronny Løvtangen <[hidden email]>:
>>> This can be achieved with Grails.
>>>
>>> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
>>> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
>>> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>>>
>>> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>>>
>>>
>>> This is what I have in BuildConfig.groovy for snmp4j:
>>>
>>>        mavenRepo "https://server.oosnmp.net/dist/release/"
>>>        ...
>>>        compile 'org.snmp4j:snmp4j:1.11.2'
>>>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>>>
>>> * or the quartz2 plugin, if quartz plugin is not updated for Grails
>>> 2.0
>>>
>>> Ronny
>>>
>>> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>>>
>>>> Hi
>>>>
>>>> Not specific to Grails,
>>>>
>>>> I Need to implement in my application a system that continuously
>>>> checks some data with SNMP from the hosts configured in the
>>>> application. I have read about Quartz, Quartz2, Executor, JMS and
>>>> ActiveMQ plugins, but I don't know how to handle the situation. I
>>>> need a service that periodically (the frequency must be able to be
>>>> changed at runtime) fetch the list of hosts from database, and then
>>>> put them in a queue; another multi-threaded process (the number of
>>>> threads must be also configurable) will then fetch the SNMP data
>>>> from each host, so I can have 5 process obtaining data from the
>>>> hosts, and when one of them finishes, pop a host from the queue and process it, and so on.
>>>>
>>>> Next time the list of hosts is fetched, I must be able to check if
>>>> the queue contains already that host (perhaps if the queue has not
>>>> been yet finished in the time between executions)...
>>>>
>>>> I am stuck with this now... Any suggestion is welcome.
>>>>
>>>> Thanks.
>>>>
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>>
>> This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Recommendations for a periodic background service

Dean Del Ponte-2
+1 for Quartz.  I use it extensively in production without issue.

- Dean Del Ponte

On Fri, Jun 29, 2012 at 3:26 AM, Juan Asensio Sánchez <[hidden email]> wrote:
Thanks, I will try and post my solution if any.

Regards.


2012/6/21 Jon Palmer <[hidden email]>:
> Juan,
>
>  - Jesque can have scheduled jobs much like (well inspired by) Quartz. You just declare the Cron schedule in the Job class and Jesque takes care of scheduling it for you.
>  - Jesque supports different named queues. You can have different workers tasked to work on different queues or one pool of workers tasked to work on a set of queues in a defined order. If you created a different queue for the user initiated requests then you could ensure they get processed ahead of the scheduled jobs.
>  - Checking if a job is in the queue already is harder. I'd ask does it really matter if multiple users schedule 'the same' job or a job that is going to execute soon on a schedule?
>  - Redis on your server? Yup you have to be ok with that. My experience has been that it's easy to install, has a very small footprint (especially if its just managing state of the queues) and is rock solidly stable.
>
> Jon
>
> -----Original Message-----
> From: Juan Asensio Sánchez [mailto:[hidden email]]
> Sent: Thursday, June 21, 2012 4:21 AM
> To: [hidden email]
> Cc: Jon Palmer; [hidden email]
> Subject: Re: [grails-user] Recommendations for a periodic background service
>
> Hi Jon and Ronny
>
> It looks like the Jesque plugin is the more approximate concept about what I need. But I have some doubts:
>
> - The process that periodically checks for objects in database must be anyway a Quartz Job, isn't it?
> - It is not possible to enqueue a Job in the first position of the queue (I need this to allow users from web interface to manually force the SNMP data collect inmediatelly for a host)?
> - I can not check if a host (or host.id) is already in the queue, so i can not avoid the host to be many times in the queue, growing the queue infintely.
> - I don't like the idea about have another service (the Redis service) running in the server
>
> About GPars, I have not found much documentation or examples, but is is also a good approximate approach, but I can't understand well the system. I would have in a service a pooled "gpars thing", resizable, that continuously looks the queue and process its data; any simple example? Also, could I reorder the elements in the queue?
>
> Thanks again.
>
>
>
> 2012/6/21 Jon Palmer <[hidden email]>:
>> I'd also checkout the Jesque plugin which supports scheduled jobs as well as a very lightweight queuing support.
>>
>> -----Original Message-----
>> From: Juan Asensio Sánchez [mailto:[hidden email]]
>> Sent: Wednesday, June 20, 2012 6:33 PM
>> To: [hidden email]
>> Subject: Re: [grails-user] Recommendations for a periodic background
>> service
>>
>> Hi Ronny
>>
>> Thank you very much for your answer. The SNMP part is already resolved (although I need a SNMP client, it is not simple anyway). In your answer, how can I apply the "queue"? The quartz process would add all the hosts in a queue, and the service must continuously check if there is any host in the queue, processing up to 5 at the same time, popping more hosts when finished (should be the service another quartz job, an executor, ...)?
>>
>> Regards.
>>
>>
>> 2012/6/21 Ronny Løvtangen <[hidden email]>:
>>> This can be achieved with Grails.
>>>
>>> I would use the quarts-plugin* (http://grails.org/plugin/quartz) for scheduling, and create a service that does the actual work.
>>> The service could use GPars to fetch SNMP data from multiple hosts in parallel.
>>> Number of threads could be specified in a config property, which you can create a page for updating (As easy as setting grailsApplication.config.your.key = newValue). Or in the database.
>>>
>>> To actually fetch SNMP data, you can use snmp4j. The S in SNMP stands for Simple, but simple is not the same as easy ;) I struggled a while to get SNMP working, as I needed to act as an agent. It's probably easier to act as a client.
>>>
>>>
>>> This is what I have in BuildConfig.groovy for snmp4j:
>>>
>>>        mavenRepo "https://server.oosnmp.net/dist/release/"
>>>        ...
>>>        compile 'org.snmp4j:snmp4j:1.11.2'
>>>        compile 'org.snmp4j:snmp4j-agent:1.4.2'
>>>
>>> * or the quartz2 plugin, if quartz plugin is not updated for Grails
>>> 2.0
>>>
>>> Ronny
>>>
>>> On Jun 20, 2012, at 11:47 PM, Juan Asensio Sánchez wrote:
>>>
>>>> Hi
>>>>
>>>> Not specific to Grails,
>>>>
>>>> I Need to implement in my application a system that continuously
>>>> checks some data with SNMP from the hosts configured in the
>>>> application. I have read about Quartz, Quartz2, Executor, JMS and
>>>> ActiveMQ plugins, but I don't know how to handle the situation. I
>>>> need a service that periodically (the frequency must be able to be
>>>> changed at runtime) fetch the list of hosts from database, and then
>>>> put them in a queue; another multi-threaded process (the number of
>>>> threads must be also configurable) will then fetch the SNMP data
>>>> from each host, so I can have 5 process obtaining data from the
>>>> hosts, and when one of them finishes, pop a host from the queue and process it, and so on.
>>>>
>>>> Next time the list of hosts is fetched, I must be able to check if
>>>> the queue contains already that host (perhaps if the queue has not
>>>> been yet finished in the time between executions)...
>>>>
>>>> I am stuck with this now... Any suggestion is welcome.
>>>>
>>>> Thanks.
>>>>
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>>
>> This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...