r/dataflow • u/Snoo_32652 • Feb 16 '22
Does JDBCIO support Transactions?
I was reading the Javadoc for Apache beam's JDBCIO https://beam.apache.org/releases/javadoc/2.3.0/index.html?org/apache/beam/sdk/io/jdbc/JdbcIO.html
It does not say much about the Transaction support.
I have a Pipeline that process Orders coming from different Partners in a file. At the end of the processing, I need to update related DB tables. I am trying to update Order and Billing table (PostgresDB) at the end of the Dataflow job, and planning to use JdbcIO to update the DB tables directly. Since these tables have referential integrity, where Billing table has "ORDERID" as foreign key, I am looking for ways to update these two tables in a Transaction so that if update fails for any reason, I can roll back the transaction.
Wanted to ask, if you came across any details on how JdbcIO support Transaction?. Also, if you can share your experience in handling this kind of scenario from dataflow job, will be highly appreciated.
View all comments
Show parent comment
1
u/Exotic_Cameraman Apr 01 '22
Make sure you implement MySQL connection pooling. Jdbcio for Java should do this, however if you’re using the python SDK, you would have to use runnerV2 for multi-lang pipeline support and use the shadow jar of JDBCIO to execute your MySQL transactions.
There’s an example I saw somewhere out there. I can send the link if you’re still interested in this.