Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:30:07+00:00 2026-06-09T01:30:07+00:00

I want to implement the following: Web application in Grails going to MongoDB database

  • 0

I want to implement the following:

  1. Web application in Grails going to MongoDB database
  2. Long-running batch processes populating and updating that database in the background

I would like for both of them to reuse the same Grails services and same GORM domain classes (using mongodb plugin for Grails).

For the Web application everything should work fine, including the dynamic GORM finder methods.

But I cannot figure out how to implement the batch processes.

a. If I implement them as Grails service methods, their long-running nature will be a problem. Even wrapping them in some async executors will unnecessarily complicate everything, as I’d like them each to be a separate Java process so they can be monitored and stopped easily and separately.

b. If I implement them as src/groovy scripts and try to launch from command line, I cannot inject the Grails services properly (ApplicationHolder method throws NPE) or get the GORM finder methods to work. The standalone GORM guides all have Hibernate in mind and overall it seems not the right route to pursue.

c. I considered the ‘batch-launcher’ Grails plugin but it failed to install and seems a bit abandoned.

d. I considered the ‘run-script’ Grails command to run the scripts from src/groovy and it seems it might actually work in development, but seems not the right thing to do in production.

I cannot be the only person with such a problem – so how is it generally solved?

How do people run standalone scripts sharing the code base and DB with their Grails applications?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:30:09+00:00Added an answer on June 9, 2026 at 1:30 am

    Since you want the jobs processing to be in a separate JVM from your front-end application, the easiest way to do that is to have two instances of Grails running, one for the front-end that serves web requests, and the other to deal with job processing.

    Thankfully, the rich ecosystem of plugins for Grails makes this sort of thing quite easy, though perhaps not the most efficient, since running an entire Grails application just for processing is a bit overkill.

    The way I tend to go about it is to write my application as one app, with services that take care of the job processing. These services are tied to the RabbitMQ plugin, so the general flow is that the web requests (or quartz scheduled jobs) put jobs into a work queue, and then the worker services take care of processing them.

    The advantage with this is that, since it’s one application, I have full access to all of the domain objects, etc., and I can leverage the dissconnected nature of a message queue to scale out my front- and back-ends seperately without needing more than one application. Instead, I can just install the same application multiple times and configure the number of threads dedicated to processing jobs and/or the queues that the job processors are looking at.

    So, with this setup, for development, I will usually just set the number of job processing threads to whatever makes sense for the development work I’m doing, and then just a simple grails run-app, and I have a fully functional system (assuming I have a RabbitMQ server running to use as well).

    Then, when I go to deploy into production, I deploy 2 instances of the application, one for the front-end work and the other for the back-end work. I just configure the front-end instance to have 1 or 0 threads for processing jobs, and the back-end instance I give many more threads. This lets me update either portion as needed or spin up more instances if I need to scale one part or the other.

    I’m sure there are other ways to do this, but I’ve found this to be both really easy to develop (since it’s all one application), and also really easy to deploy, scale, and maintain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement test feedback in my web application in the following manner
In an application having UITabBarController , I want to implement following scenario: When user
I need some idea to implement the following requirement in the web application .
I want to enable the following scenario: my web application (WAR file) is deployed
I want to implement the following constraints in mysql: create table TypeMapping( ... constraint
I want to implement an application which will work as a parser. User will
I want to implement Facebook Connect in my android application. I have seen a
I am new to springs. i want to implement JtaTransactionManager in my application instead
I'm new to Iphone development, i want to implement a simple application that some
With the following tag in web.config I localized the application to english <globalization culture=en-US

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.