Create a new job from a Java Program

Skip to first unread message

Sandhya Srinivasan

Sep 29, 2020, 5:10:07 AM9/29/20
to schedulix

We have a requirement when we have to create a schedulix job by running a java program. The job server will be running already. we have a .sdms file with the commands to create the job. The main issue is how to invoke this .sdms file from java. 

Currently we have script file which has sdmsh < <scriptFile.sdms> to create the job. But we want to replace this with java program. I am using Process Builder for now. But is there any alternate ways to achieve this?

Thanks and Regards,

Ronald Jeninga

Sep 29, 2020, 12:13:05 PM9/29/20
to schedulix
Hi Sandhya,

in fact it's pretty simple let a Java program communicate with the server.
I can't give you a piece of source code now (I'm OOO), but I can give you some hints.

First of all, if you look at the SDMSApp/ you'll find how to connect to the server using the Shell/SDMSServerConnection class.
As soon as you have a connection, you can use the SDMSServerConnection.execute() function to execute statements.
Of course you'll have to do some error handling. Just look at the tools and the SDMSApp/ and you'll find that's pretty simple as well.

I hope this helps.

Best regards,


Sandhya Srinivasan

Sep 30, 2020, 5:53:14 AM9/30/20
to schedulix
Yes, I was going through the classes in the jar. But what will be the maven dependency to add if in case I wish to add BICSuite.jar to my project dependencies?

Ronald Jeninga

Sep 30, 2020, 12:47:48 PM9/30/20
to schedulix
Hi Sandya,

I must admit I've never worked with maven, but basically the BICsuite.jar file should be considered like e.g. a or so.
It has to be present (i.e. part of the CLASSPATH), but it's not a part of the software to be built.
If it's not there the build will fail (class not found).

If you want to build the schedulix software as part of your overall build process, you'll have to tell maven to call "make".
But to be honest, I don't see a value in that.
You don't rebuild Postgres either just because you'd like to communicate with the DBMS from within your program.

The interface itself is very stable.
Apart from that we find it extremely important to preserve backward compatibility.
Just because we had a fancy idea and implemented a new feature, we can't force the entire community to recompile.

Best regards,


Ronald Jeninga

Oct 7, 2020, 9:38:52 AM10/7/20
to schedulix
Hi Sandya,

since I'm back in my office again, I thought it would be a nice idea to present you a MWE (minimal working example):

import de.independit.scheduler.server.output.SDMSOutput;
import de.independit.scheduler.server.output.SDMSLineRenderer;

public class SimpleAccess

    private static SDMSServerConnection sc = null;
    private static SDMSLineRenderer lr = null;

    public static void main(String argv[])
        sc = new SDMSServerConnection(
            "localhost",    /* host */
            2506,           /* port */
            "SYSTEM",       /* user */
            "G0H0ME",       /* password */
            0,              /* connection timeout disabled */
            false           /* no TLS */
        lr = new SDMSLineRenderer();

        try {
            /* connect first. Since we don't want to do something special (e.g. use TLS)
               we can supply a null instead of an de.independit.scheduler.SDMSApp.Options object
            SDMSOutput o = sc.connect(null /* no special options */);
            if (o.error != null) {
                System.err.println("Connect Error: " + o.error.code + ", " + o.error.message);

            /* Now we execute some statement.
               If you need to execute multiple statements, you'll have to call execute() multiple times.
               But note that a "Multicommand" is regarded a single statement, even if it's several megabytes long.
            o = sc.execute("LIST SESSIONS;");
            try {
                /* here we print the result on stdout. Just for the example */
                lr.render(System.out, o);
            } catch (Exception e) {    /* a so-called FatalException, which is a subclass of Exception, can occur here */
                System.err.println("Something went wrong: " + e.toString());

            /* here we close the connection again */
        } catch (IOException ioe) {
            System.err.println("Something went wrong : " + ioe.toString());

That's all.

In order to compile (and execute) it, I did:

[ronald@ocelot tmp]$ CLASSPATH=$CLASSPATH:$BICSUITEHOME/lib/BICsuite.jar
[ronald@ocelot tmp]$ export CLASSPATH
[ronald@ocelot tmp]$ javac
[ronald@ocelot tmp]$ java SimpleAccess

List of Sessions

THIS SESSIONID PORT START                         TYPE      USER                             UID  IP        TXID     IDLE STATE  TIMEOUT INFORMATION                               STATEMENT      WAIT
---- --------- ---- ----------------------------- --------- -------------------------------- ---- --------- -------- ---- ------ ------- ----------------------------------------- -------------- ----
          1001 2506 Wed Oct 07 13:10:12 CEST 2020 JOBSERVER GLOBAL.EXAMPLES.HOST_1.SERVER    1047 45363868    1 IDLE       300 jobserver[]                    
          1003 2506 Wed Oct 07 13:10:12 CEST 2020 JOBSERVER GLOBAL.EXAMPLES.HOST_2.SERVER    1057 45363874    1 IDLE       300 jobserver[]                    
          1007 2506 Wed Oct 07 13:26:10 CEST 2020 JOBSERVER GLOBAL.EXAMPLES.LOCALHOST.SERVER 1037 45363871    1 IDLE       300 jobserver[]                    
 *        1013 2506 Wed Oct 07 15:22:57 CEST 2020 USER      SYSTEM                              0 45363876    0 ACTIVE       0 <null>                                    LIST SESSIONS;     
       1234321    0 Wed Oct 07 13:10:11 CEST 2020 USER      SchedulingThread                    2 <null>    45363856    7 IDLE         0 <null>                                                       
       1234322    0 Wed Oct 07 13:10:11 CEST 2020 USER      GarbageThread                       2 <null>    45362320  737 IDLE         0 <null>                                                       
       1234323    0 Wed Oct 07 13:10:11 CEST 2020 USER      TriggerThread                       2 <null>    45363841   11 IDLE         0 <null>                                                       
       1234324    0 Wed Oct 07 13:10:11 CEST 2020 USER      PoolThread                          2 <null>    45363577  138 IDLE         0 <null>                                                       
      19630127    0 Wed Oct 07 13:10:11 CEST 2020 USER      TimerThread                         2 <null>    45363844   11 IDLE         0 <null>                                                       

9 Session(s) found

As you can see, no higher magic involved.
I hope you like it.

Best regards,


Reply all
Reply to author
0 new messages