Search code examples
javaplsqlspring-jdbcspring-jmsoracle19c

Retrieving new oracle table records on insert to process in Java client application


I am trying to retrieve the new inserts from a table in my java client application (Spring JMS), to do some processing and send them to a message broker. I do not have access to any CDC tool like Goldengate. I only need the new inserts and not the updates or deletes. I am having difficulty finding a way to do this. Is there a way to do this? I read that there is an option to do these with triggers, but will it have a high throughput on the db, because this table gets a lot of inserts in a day (approximately around 50K records inserted in a day).

Thanks in advance


Solution

  • 50,000 rows per day is actually rather a low volume. Some data warehouse tables get 50 million rows a day. So an insert trigger is unlikely to make any appreciable difference on the loading job. Add a date column (e.g. LOAD_DATE) and have a before insert trigger assign :new.LOAD_DATE := SYSDATE.

    That being said, if you wanted to avoid a trigger, you can modify the loading job itself to load such a date a column with SYSDATE.

    With either method, your retrieval is then simple: each day as you retrieve records, record the maximum LOAD_DATE value you retrieved. The next day, pull only records with a LOAD_DATE >= that value.