ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

java application listens db2 file changes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • java application listens db2 file changes

    Hello,

    i am going to develop a web application that will listen on data changes in a DB2 file on iseries as400 machine.
    do you have any code example that i could use?

    i have found this example: http://geosoft.no/software/filemonit...itor.java.html
    but this is for .txt files, not for db2 files.

    thank you in advance

  • #2
    Re: java application listens db2 file changes

    Sounds like a trigger to me? I don't know how else you could do it.
    Ben

    Comment


    • #3
      Re: java application listens db2 file changes

      if i understand correctly, you suggest to create an SQL trigger on the file, to connect the trigger with an RPG program (using command ADDPFTRG) and to call the java method from inside RPG?

      Comment


      • #4
        Re: java application listens db2 file changes

        Not sure what you want to archieve, but ...

        A trigger is a program either written in an HLL (High Level Language) such as RPG or Cobol or written with SQL solely.
        An HLL trigger can be linked with the table by either executing the CL command ADDPFTRG or using the SQL Command CREATE TRIGGER.
        An SQL Trigger will be created with CREATE TRIGGER but in its (program)body only SQL Commands are used.

        For more information about triggers you may have a look at the following redbook:
        Stored Procedures, Triggers, and User-Defined Functions on DB2 Universal Database for iSeries

        An other way to handle table changes might be to register your files to a journal and read the journal entries.

        Birgitta
        Last edited by B.Hauser; July 11, 2010, 02:29 AM.

        Comment


        • #5
          Re: java application listens db2 file changes

          what i want to achieve is:
          -my java application to call another (third party) java application (a remote webService actually), if and only if, a new record is added in a specific db2 file.

          initially, i supposed that it could be done by implementing in my java application a java class like this: http://geosoft.no/software/filemonit...itor.java.html

          however, the solution that Ben suggested (a trigger on the db2 file) sounds interesting to me. i can implement a RPG program that listens the changes on db2 file and calls
          my java application.

          what i am still investigating is:
          -how can an RPG program call a jav web application? same way as it calls stand alone java applications?

          Comment


          • #6
            Re: java application listens db2 file changes

            Is your Java application really a web application? If you call the program directly and this sends a web service request to another system, then this is a simple standalone Java application. The Java program calling the other web service won't need to be running on a web server as it is only outbound HTTP requests. It is only required to be a web application running on a server if you need to listen for HTTP requests.

            So the trigger could be a simple RPG program that calls your Java program directly by prototyping the methods you want to call. Then the Java program could send it's web service request. You might want to look into the metro project to do this.

            I haven't tried any of this myself but it's the way I would first look into it.
            Ben

            Comment


            • #7
              Re: java application listens db2 file changes

              The way I would do this would be to write a Java class that monitors a data queue using the appropriate classes in the IBM Java Toobox (or JTOpen). Then write a small client CL that feeds data from a new row to the queue using the QSNDDTAQ API. This CL is called by triggers attached to your files/tables.

              Depending on your requirement, the Java class could be written as a stand-alone that runs own its own in batch, or you could drop it into a web app server being hosted on your iSeries.

              Comment

              Working...
              X