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
Expand all | Collapse all

Automatically activated EGL Service

  • 1.  Automatically activated EGL Service

    Posted Wed April 08, 2015 08:02 AM

    Hi,

    is it possible to create an EGL Service which starts automatically with the Websphere Application Server and runs every 10 minutes.

    Kind regards.

    Marcel-D


  • 2.  Re: Automatically activated EGL Service

    Posted Wed April 08, 2015 11:47 AM

    I would create a simple program to call the egl service every 10 minutes, and start websphere with a script which also calls the program.

    Bram_Callewaert


  • 3.  Re: Automatically activated EGL Service

    Posted Thu April 09, 2015 02:31 AM

    Hi Bram,

    do you know how to start websphere with a script which calls the prgram?

    Marcel-D


  • 4.  Re: Automatically activated EGL Service

    Posted Thu April 09, 2015 02:54 AM

    We work with an as400, and the server is started with the following command:

    CALL PGM(QWAS7A/QWASSTRSVR) PARM('-profilePath' '/qibm/userdata/websphere/appserver/v7/express/profiles/WebAS400' '-server' 'WebAS400')

    This could be integrated in a CL program, which also submits a job to run every 10 minutes.

    Example below:

    PGM   DCL &SKEDTIME     *CHAR 4   DCL &TIME         *DEC  4   DCL &BEGTIME      *DEC  4  VALUE(0530)   DCL &ENDTIME      *DEC  4  VALUE(2200)   DCL &INCREMENT    *DEC  4  VALUE(0005)   DCL &REM          *DEC  4   DCL &TIM100       *DEC  4   DCL &CHAR         *CHAR 4 /*MONMSG CPF0000 EXEC(GOTO ERROR)*/   CHGVAR &TIME &BEGTIMENEXTSKED:   CHGVAR &SKEDTIME &TIME   SBMJOB     CMD(RUNJVA CLASS('/JVASCD/VERWERKLASERTIJDEN.JAR')) +                JOB(LASERT) +                SCDTIME(&SKEDTIME)   IF (&TIME *LT &ENDTIME) DO      CHGVAR &TIME (&TIME + &INCREMENT)      CHGVAR &TIM100 (&TIME / 100)      CHGVAR &TIM100 (&TIM100 * 100)      CHGVAR &REM (&TIME - &TIM100)      IF (&REM *GT 59) DO         CHGVAR &CHAR (&REM)         SNDPGMMSG  MSG('REM IS ' *CAT &CHAR)         CHGVAR &TIME (&TIME - 60)         CHGVAR &TIME (&TIME + 100)         CHGVAR &CHAR (&TIME)         SNDPGMMSG  MSG('TIME IS ' *CAT &CHAR)      ENDDO      GOTO NEXTSKED      GOTO NEXTSKED   ENDDO   RETURNERROR:   /* DO WHATEVER */

    Kind regards,

     

    Bram

    Bram_Callewaert


  • 5.  Re: Automatically activated EGL Service

    Posted Thu April 09, 2015 04:52 AM

    Thank you Bram!

    Marcel-D


  • 6.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 04:51 AM

    We have a servlet definition inside the web.xml for every servlet we use.
    This servlet starts a small java class which executes EGL code!
    This works very good, and is done with just a few lines java code.

    Greetings, Jeroen

    amITs

    Jerrycan


  • 7.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 05:15 AM

    Hi Jeroen,

    do you have an example for me ?

     

    Kind Regards

    Marcel-D


  • 8.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 08:04 AM

    Add the servlet in your web.xml. 

        <servlet>        <display-name>UnlockServlet</display-name>        <servlet-name>UnlockServlet</servlet-name>        <servlet-class>nl.amits.javacustom.servlets.UnlockServlet</servlet-class>        <load-on-startup>1</load-on-startup>        </servlet>

    (you can do this also in design mode ofcourse)
     

    The java code:

    package nl.amits.javacustom.servlets;import com.ibm.javart.JavartException;import com.ibm.javart.calls.PowerServer;import com.ibm.javart.calls.PowerServerImpl;import java.util.Timer;import java.util.TimerTask;import javax.servlet.http.HttpServlet;import nl.amits.adis.javawrap.UnlockProgramWrapper;public class UnlockServlet extends HttpServlet {    private static final long serialVersionUID = -7218615493958066258L;    public UnlockServlet() {        Timer timer = new Timer();        Task task = new Task();        //  task every 4 minutes        timer.schedule(task,                       0,                       240000);    }}class Task extends TimerTask {    public void run() {        PowerServer server = new PowerServerImpl();        try {            UnlockProgramWrapper wrapper = new UnlockProgramWrapper(server);            wrapper.call();            server.commit();             server.close();        } catch (JavartException je) {            // handle error.            je.printStackTrace();        } finally {            try {                if (server != null) {                    server.close();                }            } catch (JavartException je) {            }        }    }}

     

    And the EGL code:

    package nl.amits.adis.javawrap;program UnlockProgram type BasicProgram() { }    function main()        connected string;        try            sqlLib.connect("<jdbc url>",                     "database userid",                    "database password");        onException(a anyException)            connected = "Connect test failed, " :: a.message;        end        syslib.writeStdout(connected);    endend

    Because the servlet is started independed, you have to connect the database this way.

     

    Greetings, Jeroen.

     

     

     

     

    Jerrycan


  • 9.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 08:39 AM

    Hi Jeroen,

    thank you very much,

    but can't find the UnlockProgramWrapper.

     

    Greetings.

    Marcel-D

    Attachments



  • 10.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 08:48 AM

    Ah this one is generated via the build descriptor

     

    A part of it:

    <LinkageOptions name="javaWrapOption">        <callLink >                <remoteCall pgmName="UnlockProgram" javaWrapper="YES"/>        </callLink></LinkageOptions>

    This build descriptor generates the UnlockProgramWrapper.

    Jerrycan


  • 11.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 08:52 AM

    Hi,

    You also need to set the enableJavaWrapperGen in the build descriptors.  Without this, it will not look at the linkage options.

    You can see more about his in the EGL helps:

    http://www-01.ibm.com/support/knowledgecenter/SSMQ79_9.1.1/com.ibm.egl.gg.doc/topics/gegl_java_javawrapper.html

     

    markevans


  • 12.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 08:56 AM

    You are right Mark, i cleaned a little to much from the code i copied.

    Also we use a different builddescriptor for our JavaWrappers so on the package this specific java builddescriptor is used.
     

    Jerrycan


  • 13.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 08:57 AM

    Hi Jeroen,

    That's a great example!  I was working - very slowly - on a non-production example using Quartz since I've used it with a custom java application created for us by a 3rd party.  Also, WAS has a scheduler which I think would be interesting to learn about.  I'm not sure I'll continue having your example - Thank you.

    Will the PowerServer class be needed too as that is being instantiated in the Task.run method?

    Daron

    canutri


  • 14.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 09:02 AM

    DAron,

     

    the PowerServer is provided by the EGL Java runtime.

    It is part of the whole EGL Java Wrapper solution.  

    The EGL Java Wrapper's purpose is to allow a non-EGL Java class to call into an EGL program (either as Java or any other remoteCall we support) (including starting the EGL debugger).

    Here is a little more generic information about them.

    http://www-01.ibm.com/support/knowledgecenter/SSMQ79_9.1.1/com.ibm.egl.gg.doc/topics/gegl_java_javawrapperclasses.html

     

     

    markevans


  • 15.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 09:18 AM

    Hi Mark,

    Wow, I did not know about this (or didn't understand it when I took the EGL distance learning classes).

    Admittedly, I've only skimmed the documentation you provided and need to review it in more detail, but one quick question...  If the EGL application is using a jndi reference, would the SqlLib.connect() still be required?

    canutri


  • 16.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 09:23 AM

    This was most likely not covered in the DL as it was the way to get into EGL from native Java prior to services .   But it still has some applicability and power as needed.

    I believe it runs as a "non" J2EE program which is why it still needs the sqllib.connect. 

    You could try to generate the program with J2EE=yes and see if it will still use and be able to successfully access the JNDI reference.   I just cannot remember.

    Mark

    markevans


  • 17.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 09:44 AM

    We can remember it. Because we asked it via a PMR. This was the solution from IBM.

    Jerrycan


  • 18.  Re: Automatically activated EGL Service

    Posted Fri April 10, 2015 11:36 AM

    Thank you Mark and Jeroen.
    If jndi is not capable, then one must take into consideration that connection pooling is not being used and the impact thereof on the server; especially when timing the to execute the class is frequent.

    canutri