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 8982581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:36:51+00:00 2026-06-15T20:36:51+00:00

I’m doing my graduation project, and have run into a dilemma here. I need

  • 0

I’m doing my graduation project, and have run into a dilemma here.
I need to make an application that generates PDFs and emails them to people on a schedule defined by data in the database.
I’m working for a company with this project, and we already have a GlassFish application server that we use. It would be best if the entire solution is delivered in one package, as it is now.
Client with webstart
Web Application etc. is all in one package

My new service needs to run on a separate thread, generate reports and send them out on emails. From what I can read on the web, running your own threads in an application server as GlassFish is highly discouraged, so it sounds like I need to make my own separate application.

Can this really be? What are your comments, and what are the best practices for this?

  • 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-15T20:36:52+00:00Added an answer on June 15, 2026 at 8:36 pm

    @Schedule

    If you are using Ejb 3.1 (glassfish 3.x), you may use the @Schedule annotation to have the container invoke a method in a specified interval or at a given calendar time. Allowing you to avoid handling threads in your own code

    Read about ejb 3.1 timer

    @Stateless
    public class LabbBean {
    
        @EJB
        WorkerEjb workerEjb;
    
        @Schedule(second="*/5", minute="*",hour="*", persistent=false)
        public void myMethod() {
            for (all jobs found in db){
                workerEjb.workerMethod(job);    
            }
        }
    }
    
    @Stateless
    public class WorkerEjb {
        @Asynchronous
        public void workerMethod(job) {
            //Send emails
        }
    }
    

    If you wanted to do the work in separate threads, the @Schedule annotated method could call a worker-ejb with the worker-method annotated as @Asynchronous

    @Timeout

    I just realised you wanted the schedule to be initiated from the database. An option the would be to initiate a bunch of timers programmatically using a @Singleton ejb with @Startup annotation. The timeout annotated method would be called in separate threads if some timers run out at the same time.

    @Singleton
    @Startup
    public class LabbBean {
        @Resource
        protected TimerService timerService;
    
        @PostConstruct
        public void init() {
            //Init your timers from the data in the database here
            for (all your timers) {
                TimerConfig config = new TimerConfig();
                config.setInfo("timer1");
                config.setPersistent(false);
    
                ScheduleExpression schedule = new ScheduleExpression();
                schedule.dayOfMonth(10);
                schedule.minute(2);
                timerService.createCalendarTimer(schedule, config);
            }
        }
    
        //method called when timeout occurs
        @Timeout
        public void timeoutHandler(Timer timer) {
            String name = timer.getInfo().toString();
            System.out.println("Timer name=" + name);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.