Re: Accessing external DB inside RichFlatMap Function
Posted by
Kostas Kloudas on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/How-to-avoid-breaking-states-when-upgrading-Flink-job-tp7726p7857.html
Hi Simon,
If your job reads or writes to a DB, I would suggest to use one of the already existing Flink sources or sinks,
as this allows for efficient connection handling and managing.
If you want to write intermediate data to a DB from an operator, then I suppose that you should implement
your own custom operator that opens a DB connection in the open() method and closes it at close().
If you are planning to do so, I think that code of your custom operator would be the same as the StreamFlatMap,
with the addition of the openDBConnection method in the open(), and you should also override the close() method
of the AbstractUdfStreamOperator to 1) call super.close() and 2) close the db connection.
Let me know if this works,
Kostas
> On Jul 7, 2016, at 10:38 AM, simon peyer <
[hidden email]> wrote:
>
> Hi guys
>
> Is there a easy way to handle external DB connections inside a RichFlatMap Function?
>
> --Thanks Simon