Add support for query notifications#90
Conversation
|
Can you add a test for this feature? |
|
I'm also interested to see how it works. I don't know how to use @maxhauser do you use this in production? Does it work well? |
|
@denisenkom any idea how to use this? |
|
I used that just for a proof of concept but it did not made it into production. The use of the To get a Change notifications are then posted to the specified service broker service. For more information about query notifications and how to set up the service broker that is a good start. |
I tried that but I had an The following code give this error, I wonder if something changed in go-mssqldb or Go since the last time you tried it. package main
import (
"database/sql"
"time"
_ "github.com/maxhauser/go-mssqldb"
)
func main() {
cn, err := sql.Open("mssql", sqlStr)
if err != nil {
panic(err)
}
defer cn.Close()
stmt, err := cn.Prepare("SELECT Name FROM dbo.Test")
if err != nil {
panic(err)
}
sqlstmt := stmt.(*mssql.MssqlStmt)
sqlstmt.SetQueryNotification("ABC", "service=WebCacheNotifications", time.Hour)
} |
|
Sorry, I forgot to mention that you have to have a MssqlDriver connection. Try to open the connection directly with the mssql driver, like that: ... |
|
Thanks, it worked. I'm not sure if I do the right thing or maybe query notifications doesn't work the way I think. The following code executes the query, prints the output and exits. How do I get the notification? I was thinking that maybe the query would block until there's a change. stmt, err := cn.Prepare("SELECT test FROM dbo.test;")
if err != nil {
panic(err)
}
sqlstmt := stmt.(*mssql.MssqlStmt)
sqlstmt.SetQueryNotification("ABC", "service=WebCacheNotifications", time.Hour)
rows, errQuery := sqlstmt.Query(nil)
if errQuery != nil {
panic(errQuery)
}
defer rows.Close()
result := make([]driver.Value, 1)
if err := rows.Next(result); err != nil {
panic(err)
}
fmt.Println(result) |
|
Anyone? |
|
merged, thanks! |
use a non-zero exit code when no command is given
update azidentity to 1.2.1
Added SetQueryNotification method to MssqlStmt. Parameter semantics are the same as in
new SqlNotificationRequest(userData,options,timeout).