sijms / go-ora

Pure go oracle client
MIT License
768 stars 169 forks source link

Using Oracle Advanced Queuing with go-ora #365

Open robstradling opened 1 year ago

robstradling commented 1 year ago

I'm about to migrate a project (from godror to go-ora) that currently uses godror's NewQueue and Dequeue functions.

Do you have any plans to implement equivalent API functions in go-ora?

(I'm aware that I can already get what I need via PL/SQL, but native go-ora API functions would be really nice :-) ).

sijms commented 1 year ago

I will see code first and inform you

sijms commented 11 months ago

I make simple implementation for AQ in go-ora/dbms example found in examples/dbms_aq

please see if it need more modification before release

robstradling commented 11 months ago

That seems like a good start. Thanks @sijms!

In my projects I use go_ora.NewConnection rather than sql.Open, so it looks like I can't use the functions you've added so far in aq.go. Would you be able to extend the aq.go functions to also support direct use of the package?

godror.Dequeue can dequeue an array of messages (rather than only a single message), similar to DBMS_AQ.DEQUEUE_ARRAY. (Ditto for godror.Enqueue). Would you be able to provide similar functionality in aq.go?

I make simple implementation for AQ in go-ora/dbms

I suspect that godror (via ODPI and OCI) accesses OracleAQ at a lower level than DBMS_AQ. Just out of interest... Do you think it might be possible to replace the "simple implementation" with code that doesn't rely on PL/SQL? If it's possible, would it be worth doing?

robstradling commented 11 months ago

In my projects I use go_ora.NewConnection rather than sql.Open, so it looks like I can't use the functions you've added so far in aq.go. Would you be able to extend the aq.go functions to also support direct use of the package?

I've been using go_ora.NewConnection only because the benefit here is that you can use pl/sql and output parameters. However, I noticed that your Dequeue and Enqueue functions in aq.go use pl/sql and output parameters in conjunction with sql.Open. Am I right that there's no longer any advantage to using go_ora.NewConnection instead of sql.Open?

sijms commented 11 months ago

sorry I am updating documentation as the package advance the support for database/sql package increase until now only feature that is not found in database/sql is query to struct using db tag which require direct package use

vtolstov commented 7 months ago

Hi! Thank you for such examples, but if i want to get for example 1000 events from AQ process them and if all ok - dequeue it, if something happens - able to read it again from aq? for example - i';m read 1000 messages from aq and pass it to kafka, if producing successful i'm remove this messsages from aq, if something bad happens - service restarted and re-read again this messages from aq ?

vtolstov commented 7 months ago

@sijms can you share some info for me?