You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/asciidoc/chapters/events/events.adoc
+34-35Lines changed: 34 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,42 +1,41 @@
1
1
[[events]]
2
2
== Working with Events
3
3
4
-
Firebird supports events.
5
-
Events are a feature that provides asynchronous notification to the connected applications about events triggered by the database or other applications.
4
+
Events are a Firebird feature that provides asynchronous notification to connected applications about events triggered by the database or other applications.
6
5
Instead of requiring applications to reread the database tables to check for changes, events make it possible to avoid that: triggers in the database can post an event in case of a change.
7
6
And even more, the event can be so specific that an application would need to reread only a limited set of records, possibly only one.
8
7
9
8
This chapter describes the event mechanism in Firebird and the common usage scenarios.
10
9
11
10
=== Database events
12
11
13
-
An _event_ is a message generated in PSQL code that is delivered to subscribed applications.
14
-
The event is characterized only by a name which is used when the event is posted, therefore two different events must have two different names.
15
-
The applications that subscribe for events are required to specify the event names of interest, no wildcards are allowed;
16
-
and applications either provide a callback function that will be invoked in case of event or are required to poll for the posted events periodically.
12
+
An _event_ is a message generated in PSQL code using https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-psql-coding.html#fblangref50-psql-postevent[`POST_EVENT`] that is delivered to subscribed applications.
13
+
An event is characterized only by its name, so two different events must use different names.
14
+
Applications subscribing for events specify the event names of interest, no wildcards are allowed;
15
+
an applications either provides a callback function that will be invoked asynchronously for the event, or it polls for the posted events periodically.
17
16
18
17
Events are delivered to the application only on (after) commit of the transaction that generated the event.
19
18
Firebird does not provide any guarantees about the time of event delivery, it depends on the load of the Firebird engine, application load, network delays between application and the database system.
20
19
The database engine will continue operating even if no application subscribes to events or when the subscribed application crashed in the meantime.
21
20
22
-
It can also happen that multiple transactions will be committed before the events are delivered to the client system.
23
-
But even in such case the callback function will be invoked only once, and only the event name and the count of the events will be passed as parameters.
24
-
The same applies to periodical polling, the application will receive event names and counts of the events since last poll.
21
+
It's possible that multiple transactions have been committed before the events are delivered to subscribed applications.
22
+
In that case, the callback function is invoked only once, and only the event name and the count of the events are passed as parameters.
23
+
The same applies to periodical polling, the application will receive event names and counts of the events since the last poll.
25
24
26
25
Internally, Firebird can be thought to store the subscription information in a table where columns contain event names, rows correspond to the subscribed applications and the cells contain the count of the particular event for a particular application.
27
-
When an event is posted in trigger or stored procedure, Firebird checks the subscription information and increases the event count for the subscribed applications.
28
-
Another thread checks the table periodically and notifies the application about all new events relevant to the particular application.
26
+
When an event is posted in a trigger or stored procedure, Firebird checks the subscription information and increases the event count for the subscribed applications.
27
+
Another thread checks the table periodically and notifies subscribed applications about all new events relevant to the particular application.
29
28
Such mechanism allows Firebird to keep the event notification table very smallfootnote:[
30
29
For example, the effective size for 100 applications subscribed for 100 different events is about 40k in memory.]
31
30
and to reduce the number of messages sent to the application.
32
31
33
32
It is not possible to pass parameters with the event, e.g. an ID of the modified records.
34
-
It is also not possible to encode such information in the event names, wildcards are not supported.
33
+
It is also not possible to encode such information in the event names, as wildcards are not supported.
35
34
For such cases, applications should maintain a change tracking table where the IDs of the modified records are stored and the event mechanism is used to tell the application that new records were added to the table.
36
35
37
36
=== Posting events
38
37
39
-
Events are posted from PSQL code (trigger, stored procedure, execute block, function) using the https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-psql-coding.html#fblangref50-psql-postevent[`POST_EVENT`^] statement.
38
+
Events are posted from PSQL code (trigger, stored procedure, execute block, function) using the https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-psql-coding.html#fblangref50-psql-postevent[`POST_EVENT`] statement.
40
39
It is possible to create a stored procedure with the sole purpose of posting events (e.g. to notify events from an application):
41
40
42
41
[source,sql]
@@ -50,7 +49,7 @@ END
50
49
51
50
The https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-dml-execblock.html#fblangref50-dml-execblock[`EXECUTE BLOCK`^] statement can be used to execute PSQL statements within DSQL code:
The design of the classes and interfaces in the `org.firebirdsql.event` package is similar to the Services API support;
65
-
there is a central manager-class that establishes a database connection and provides service methods to work with the events, a callback interface that applications must implement to use the asynchronous event notification and an interface representing a database event with two properties, event name and occurrence count.
64
+
there is a central manager-class that establishes a database connection and provides service methods to work with the events, a callback interface that applications must implement to use the asynchronous event notification, and an interface representing a database event with two properties, event name and occurrence count.
66
65
67
-
Applications have to configure the following properties before starting use of the implementation `EventManager` interface:
66
+
Applications have to configure the following properties before starting use of the implementation of the `EventManager` interface:
68
67
69
-
[cols="1m,2m,4",options="header",]
68
+
[cols="1m,2m,4a",options="header",]
70
69
|===
71
70
|Name |Type |Description
72
71
73
-
a|`host` +
74
-
`serverName`
72
+
a|`serverName` +
73
+
`host` (until:[Jaybird 6])
75
74
|String
76
75
|Name or the IP address of the host to which we subscribe for events. __Required__.
77
76
78
-
a|`port` +
79
-
`portNumber`
77
+
a|`portNumber` +
78
+
`port` (until:[Jaybird 6])
80
79
|int
81
80
|Port to which we connect to, 3050 by default.
82
81
83
-
|`database` +
84
-
`databaseName`
82
+
|`databaseName` +
83
+
`database` (until:[Jaybird 6])
85
84
|String
86
85
|Path to the database.
87
86
The path is specified for the remote host but must be absolute. __Required__.
@@ -102,52 +101,52 @@ The path is specified for the remote host but must be absolute. __Required__.
102
101
103
102
|expectedDb
104
103
|String
105
-
a|since:[Jaybird 5] With Firebird 3.0 and higher, this is used to find the non-default security database to use when authenticating.
104
+
|since:[Jaybird 5] With Firebird 3.0 and higher, this is used to find the non-default security database to use when authenticating.
106
105
Value is a database path or alias the user can connect to. _Optional_.
107
106
108
107
|authPlugins
109
108
|String
110
-
a|Comma-separated list of authentication plugins to use (ignored for Firebird 2.5 or earlier).
109
+
|Comma-separated list of authentication plugins to use (ignored for Firebird 2.5 or earlier).
111
110
Use `null` (the default) to use Jaybird defaults.
112
111
113
112
|processId
114
113
|int
115
-
a|since:[Jaybird 5] Process id to report to the server.
114
+
|since:[Jaybird 5] Process id to report to the server.
116
115
117
116
|processName
118
117
|String
119
-
a|since:[Jaybird 5] Process name to report to the server.
118
+
|since:[Jaybird 5] Process name to report to the server.
120
119
121
120
|socketBufferSize
122
121
|int
123
-
a|since:[Jaybird 5] Socket buffer size in bytes
122
+
|since:[Jaybird 5] Socket buffer size in bytes
124
123
125
124
|soTimeout
126
125
|int
127
-
a|since:[Jaybird 5] Socket blocking read timeout in milliseconds (`0` is OS default timeout)
126
+
|since:[Jaybird 5] Socket blocking read timeout in milliseconds (`0` is OS default timeout)
128
127
129
128
|connectTimeout
130
129
|int
131
-
a|since:[Jaybird 5] Socket connect timeout in milliseconds (`0` is OS default timeout)
130
+
|since:[Jaybird 5] Socket connect timeout in milliseconds (`0` is OS default timeout)
Copy file name to clipboardExpand all lines: src/docs/asciidoc/reference/connection/authenticationplugins.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,7 +137,7 @@ This support is experimental and comes with a number of caveats:
137
137
138
138
* We haven't tested this extensively (except for loading Jaybird's own plugins internally)
139
139
* The authentication plugin (and provider) interfaces should be considered unstable;
140
-
they may change with point-releases (although we will try to avoid that)
140
+
they may change with point-releases (though we will try to avoid that)
141
141
* For now, it is probably necessary for the JAR containing the authentication plugin to be loaded by the same class loader -- or at least, from the same classpath -- as Jaybird itself
142
142
143
143
If you implement a custom authentication plugin and run into problems, contact us on the https://groups.google.com/g/firebird-java[firebird-java Google Group^].
Copy file name to clipboardExpand all lines: src/docs/asciidoc/reference/connection/catalogaspackage.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ When this connection property is enabled, the `DatabaseMetaData` of that connect
31
31
32
32
The `useCatalogAsPackage` connection property does not result in any other behaviour.
33
33
34
-
Keep in mind, that this is non-standard behaviour, and standard JDBC tools or libraries may not work correctly when this property is enabled.
34
+
Keep in mind that this is non-standard behaviour, and standard JDBC tools or libraries may not work correctly when this property is enabled.
35
35
This feature may be discontinued and removed in the future if Jaybird needs to implement "`real`" catalogs (e.g. because Firebird started supporting catalogs).
36
36
37
37
See also https://github.com/FirebirdSQL/jaybird/blob/master/devdoc/jdp/jdp-2023-09-use-catalog-as-package.adoc[jdp-2023-08: Use Catalog as Package^]
Copy file name to clipboardExpand all lines: src/docs/asciidoc/reference/connection/clientinfoproperties.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Client info properties allow you to set properties on a connection for informati
7
7
==== Support in Jaybird 5 and earlier
8
8
9
9
Support for client info properties was introduced in Jaybird 2.2, storing properties in the `USER_SESSION` context of https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-functions.html#fblangref50-functions-workcontext[`RDB$GET/SET_CONTEXT`].
10
-
Support is quite limited, allowing you to:
10
+
Support in Jaybird 5 and earlier is quite limited, allowing you to:
11
11
12
12
* Set properties individually or collectively using a `Properties` object (`Connection#setClientInfo(String,String)`, `Connection#setClientInfo(Properties)`)
13
13
* Clear properties individually (setting them to `null`) (`Connection#setClientInfo(String,String)`
Copy file name to clipboardExpand all lines: src/docs/asciidoc/reference/connection/firebirdautocommit.adoc
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,10 @@
3
3
4
4
[CAUTION]
5
5
====
6
-
This functionality is experimental, and will remain so unless Firebird changes how its auto-commit mode works.
7
6
**Do not use this unless you really know what you're doing.**
8
7
8
+
This functionality is experimental, and will remain so unless Firebird changes how its auto-commit mode works.
9
+
9
10
Incorrect use of this functionality can result in excessive growth of the database due to increases in back-version chains of records, which can also cause performance degradation.
10
11
Additionally, when used with an isolation level other than READ COMMITTED, the connection will only see changes committed at the time the initial transaction was started;
11
12
the auto-commit barrier will not make new committed changes visible to the current transaction.
@@ -30,5 +31,9 @@ If you manually add `isc_tpb_autocommit` to the transaction parameter buffer, an
30
31
31
32
Artificial testing with repeated inserts (using a prepared statement) against a Firebird server on localhost shows that this leads to a reduction of execution time of +/- 7%.
32
33
33
-
Support for this option is experimental, and should only be enabled if you 1) know what you're doing, and 2) really need this feature.
34
+
Support for this option is experimental, and should only be enabled if you
35
+
36
+
. know what you're doing, and
37
+
. really need this feature.
38
+
34
39
Internally `isc_tpb_autocommit` uses `commit_retaining`, which means that using this feature may increase the transaction gap with associated sweep and garbage collection impact.
0 commit comments