EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  Run a batch program EGL at a given time

    Posted Mon January 12, 2015 10:47 AM

    Hi,

    I nedd to run automatically and EGL backup batch program when all users are offline.

    The program is now called with a command button but users forget to save the data of the day's work.

    I can't dreate and use a windows service because the parameters to te called program are variable fro one day to another so I must pass parameters from the main project.

    How to start this batch program in the EGL environnment?

    Paoloc

    paoloc


  • 2.  Re: Run a batch program EGL at a given time

    Posted Mon January 12, 2015 11:07 AM

    Paoloc,

    Just to make sure I understand what you are asking.

    Are you asking how to run/start a batch program from something like the Windows command line (or cmd/bat file)?  

    Are you expecting to pass parameters to the program from the Windows command line or into the main program? 

    Mark

    markevans


  • 3.  Re: Run a batch program EGL at a given time

    Posted Tue January 13, 2015 08:10 AM

    Mark!

    Unfortunately my English is very poor and therefore I can not explain well the problems.

    I was wrong to talk of windws. windows is only the runtime environment, but it could be linux or unix.

    My problem is to run a  EGL called program on the same server (Tomcat) where the main project is running.

    The main program pass parameters to the called program that run a backup procedure at a given time every day at the same hour after the server is started and when the first user logOn into the the main project.

    The main program checks whether the useof a certain typer who is logging on is the first of the day.

    The same application for different users should back up different input path and related DB2 tables to different output path and DB2 tables using the same EGL called program.

    The called program receives parameters for user type and the path of the input and output and runs until the time (obtained from DB2 tables) on the day when it was called.

    paoloc

     

    paoloc


  • 4.  Re: Run a batch program EGL at a given time

    Posted Tue January 13, 2015 03:16 PM

    Paoloc,

    I appreciate you being able to speak/write English at all.  I certainly am not fluent in any other language.

    Let me try to repeat what I think I am reading and you can correct it.

    I think you are saying you want to have a web application (your main project) call out to a program that runs under the application server as well?

    Is this done per user?   or per server?  I could not follow this? 

    If it is per user, then you expect it to run AFTER the user logs in?  If so, how can you say it should run at a given time since you don't know when that user is going to login?   Or do you mean you just want it to run sometime after the work hours of the user.

    Would it would better to write some kind of record to a serial file or a DB2 table when the user logons.  Then have a pure batch job that runs via a scheduler or some other way outside the application server.   This program could then read this file(s) or DB2 table and do a backup based on the the information in the data in the table/file. 

    Mark

     

    markevans


  • 5.  Re: Run a batch program EGL at a given time

    Posted Wed January 14, 2015 10:55 AM

    Mark! 

    Thank you for speaking to me of the "scheduler". It was a concept unknown to me in java and tomcat (I come from the i5 world  where these things are resolved much more simply). After a brief investigation on google, I think I will use Quartz. What do you think?

    There is one other thing I do not understand how to implement: I do not understand though, with Quartz, I have to call the batch program or EGL-generated Java class. I have to use a javaWrapper (which I never understood very well) to call the batch program?

    To answer your questions:

    1) Yes the main project call out to a program that runs under the application server (Tomcat)

    2) This is done per user

    3) Run after the user (certain users) logs in

    4) it should run at a given time (for example, a value set to a DB2 table) since I don't know when that user is going to login

    5) The main project alredy now write on DB2 when users logon (and logout or abandon the session irregularly).

    6) I do not think it's a good idea to use pure batch jobs outside the main project (poor control)

     

    paoloc

    paoloc


  • 6.  Re: Run a batch program EGL at a given time

    Posted Wed January 14, 2015 04:16 PM

    Hi,

     I don't have any experience on a specific schedulers. Maybe someone else on the forum has some.

    I guess I still don't understand why you think this needs to be a called program.  It seems to me you are trying to run a backup for each user that logged on.  And you want this to be done a certain time of day when they are not working.  If so, then it would make sense to me that the scheduler invoke a batch/java class. This can easily be an EGL program (main - which means no parameters passed to it (no. "()" in the program definition).  This can then be deployed as a pure java application that can be started like "java myeglpgm" by the scheduler.

    The "myeglpgm" could read the DB2 tables and determine what work it needs to do in order to perform the backups for each of the users.

    I would still suggest this be managed as a separate EGL project, but it does not have to be.

     

    markevans


  • 7.  Re: Run a batch program EGL at a given time

    Posted Thu January 15, 2015 07:18 AM

    Hi Paoloc and Mark,

    I've been following this topic with interest as I think this is a good opportunity for an EGL topic on implementing the Quartz scheduler (or WAS's built in scheduler should anyone be deploying WAS).  We have a pure java custom solution which uses Quartz for nightly batch processing and was created by a 3rd party software integrator.  They use Quartz even though they knew it was being deployed on WAS - I'm not sure why they didn't use WAS's scheduler but I suppose they were more comfortable using the open source resources.

    It'll be interesting to see if there will be others who might get involved in the discussion now that Quartz has been mentioned at which time a new thread "EGL implementing Quartz" may be in order.  I'll try to use my Quartz experience (in pure java) and see if I can make the EGL ExternalType java wrappers, but like Paoloc, I too don't have much experience doing so.  I'm hopeful that someone has already done this and can post their work.

    As I understand your issue to be that you need to perform a (backup?) task before the user logs back into the application.  You also mentioned something about the timing of this had to occur "at a given time every day at the same hour after the server is started."  In that I understand that your Tomcat server (or application) is restarted everyday at the same time.  It also sounds to me that this task only needs to occur for those users having performed work in the previous day (or since the server was last restarted and this backup task was performed).

    I think I'm in agreement with Mark in that you could write the user information and/or parameters to a db2 table.  Then when the server reboots and the application starts, an EGL batch job is kicked off which reads the db2 table to identify which users and parameter data needs to be processed.  In the meantime your application is in a lock state and users are prevented from starting a new session (i.e. logging into the application).  Although, technically speaking, if the batch job is to be performed every time the server/application is started, then a scheduler is not necessary.  Instead, the batch job could be added in the application's Web Deployment Descriptor's Servlets and JSP's section.  But doing so may require the use of a java wrapper to call the EGL batch program unless it - when generated into java - implements the javax.servlet.http.HttpServlet class.

    It would be helpful to learn what your parameters are to understand better what type of processing that is being done.

    An alternate consideration given your familiarity with IBM i may to have a DB2 Stored Procedure called from WrkJobScdE on the IBM i.  That is, if the work is purely database related.

    I will be waiting on the sidelines following this discussion until I have something more of value to offer.

    Daron

    canutri


  • 8.  Re: Run a batch program EGL at a given time

    Posted Thu January 15, 2015 08:36 AM

    We use the IBM i job scheduler (wrkjobscde) to start small java programs, which have no other function than to call an egl service on Websphere (also on IBM i).

    This allows us to remain fairly platform-independent and still use our business logic in the web services. The downside is startup speed, as a jvm needs to be started each time a java application is started.

     

    I would write a small program that does a service call to a tomcat service function every X minutes, and keeps doing this until it stops. This service function can check which users need to be backed up and then call the existing (command button) function to back up the data.

    Then all that is required is to find a platform-dependent way to start the java program automatically. (job scheduler on IBM I, Scheduled tasks on windows, ...)

     

    The Quartz option seems interesting as well and probably is more flexible. If you want to stay with only EGL it would require writing the wrappers.

     

    Bram

    Bram_Callewaert


  • 9.  Re: Run a batch program EGL at a given time

    Posted Fri January 16, 2015 09:40 AM

    Hi Mark, hi Bram,

    Thanks for the suggestions.

    I want to stay with EGL and I must write mi called program as a wrapper.

    paoloc

    paoloc