Informix

Informix

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
Expand all | Collapse all

Smart Triggers Push Data and restarting from commitTime or txnid

  • 1.  Smart Triggers Push Data and restarting from commitTime or txnid

    Posted Mon September 19, 2022 10:18 AM
    Hi, I'm trying to test out the push data feature of Informix to verify it can do what we need it to do, which is not lose data if our consumer goes down.

    I've got a java application based on this code
    public class BankMonitor implements IfmxSmartTriggerCallback {
      public static void main(String[] args) throws SQLException {
        IfxSmartTrigger trigger = new IfxSmartTrigger(args[0]);
        trigger.timeout(5).label("bank_alert");
        trigger.addTrigger("account", "informix", "bank",
              "SELECT * FROM account WHERE balance < 0", new BankMonitor());
        trigger.watch(); //blocking call
      }
    
      @Override
      public void notify(String json) {
        System.out.println("Bank Account Ping!");
        if(json.contains("ifx_isTimeout")) {
          System.out.println("-- No balance issues");
    
        } else {
          System.out.println("-- Bank Account Alert detected!");
          System.out.println(" " + json);
        }
      }
    }​

    I've connected this up to the informix developer docker image and this works, when I insert / update / delete records, I get them pushed out as json blobs.

    What I'm now trying to do is prove that if my java application goes down I can restart it and start from where it failed (or earlier) but for some reason I cannot get this to work.

    Acording to the docs for the ifxjdbc driver jdbc 4.50.8 javadoc (com.ibm.informix) the IfmxThreadedSmartTrigger includes options to set the commitTime or txnid of a previous message and begin from that position. However when I test this it doesn't work.

    What I've been doing is starting my java application, inserting some data into a table, taking the commit time or txnid from one of the messages I receive, stopping the java application, making further inserts / updates / deletes then starting the java application and changing the `trigger.timeout(5).label("bank_alert");` line to
    `trigger.timeout(5).transactionId(mytxnid).label("bank_alert");`
    starting the java application again expecting the DB changes I made while is was down to get pushed out to me, but I receive nothing.

    If I set commitTime then my trigger doesn't even push out new changes I make to the table, if I set transactionId then I do receive new changes but not the ones in between.

    Is what I'm trying to do possible with Ifx Smart Triggers? My searches for example code of their use doesn't find much beyond the bank example above, so if anyone has any example code that shows how a push data session can be restarted from a previous point that would be appreciated.

    Thanks






    ------------------------------
    Greg Morris
    ------------------------------

    #Informix


  • 2.  RE: Smart Triggers Push Data and restarting from commitTime or txnid

    Posted Mon September 19, 2022 10:46 AM
    Greg:

    What version of Informix are you running? The "survival" feature of Push Data/Smart Triggers didn't come in until version 14.10.FC4 and later! Before that you could only start a pushdata session at the current transaction point.

    Art

    ------------------------------
    Art S. Kagel, President and Principal Consultant
    ASK Database Management Corp.
    www.askdbmgt.com
    ------------------------------