From: | Dirk Mika <Dirk(dot)Mika(at)mikatiming(dot)de> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | How to run a task continuously in the background |
Date: | 2019-07-11 08:24:05 |
Message-ID: | 7932668C-EA48-436B-AA15-DB7C8446D57F@mikatiming.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
another oracle -> postgreSQL migration question.
I have a database in which a job runs continuously to perform tasks that are inserted into a table in the form of records.
The current Oracle implementation is to use DBMS_JOB to start a job (to be precise, there can be multiple jobs working in parallel) that goes through the following loop:
* is there anything to do?
* Yes -> Do Tasks
* No -> 1 second sleep
* Was the EXIT command sent to me?
* Yes -> Exit loop.
The question now is how do I start in PostgreSQL a background task that meets the following requirements:
1. It must continue to run even if the connection in which the task was started is terminated.
2. I need to be able to check if a background task exists.
3. I need to be able to finish the background task without explicitly sending the EXIT command (see above) to the task.
I've already looked at the pg_background extension, but I don't think it meets either requirement 2 or requirement 3. But maybe I just didn’t look hard enough. And with regard to requirement 1, I'm not sure that's guaranteed.
Any suggestions on how this might be realized. Preferably without an external application. ☺
BR
Dirk
--
Dirk Mika
Software Developer
[cid:image001_d0a5cf51-5dd3-4ff5-b428-1016a6d95a0f.png]
mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany
fon +49 2202 2401-1197
dirk(dot)mika(at)mikatiming(dot)de
www.mikatiming.de
AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika
[cid:CCh2U_f27a5ce6-8556-4db1-8aa4-fd610d6e9efe.jpg]<https://youtu.be/qfOFXrpSKLQ>
From | Date | Subject | |
---|---|---|---|
Next Message | Steven Winfield | 2019-07-11 10:44:07 | RE: How to run a task continuously in the background |
Previous Message | Gavin Flower | 2019-07-11 08:17:14 | Re: migrating from Oracle to PostgreSQL 11 |