The C# TransIterator Class

TransIterator contains helper iterator classes used by HA replica applications to receive transaction-level output from the replication stream. In the current C# API the main built-in implementation is TransIterator.JsonIterator, which writes replication events and object images to a System.IO.Stream in JSON format.

For an overview see page C# Classes

Class Definition

    public class TransIterator
    {
        public abstract class Iterator
        {
            public Iterator(Connection con);
            public void Close();
        }

        public class JsonIterator : Iterator
        {
            public JsonIterator(Connection con, System.IO.Stream s, bool compact,
                                bool ignore_stream_errors);
            public JsonIterator(Connection con, System.IO.Stream s);
        }
    }

Member Descriptions

TransIterator class
Container class for iterator implementations that can be assigned to ReplicaConnection.Parameters.Iterator.
Iterator abstract class
Base class for transaction iterators. It stores the wrapper context associated with the specified Connection and owns the native iterator handle created by a concrete implementation.
Iterator(Connection con)
Initializes the iterator base with the wrapper context of the specified connection. Use the same connection that is associated with the replica session where the iterator will be used.
Close()
Closes the native iterator handle and releases resources associated with the iterator instance. Call this method when replication no longer needs the iterator. Closing the iterator does not close the underlying Stream; stream lifetime is controlled by the application.
JsonIterator class
Built-in iterator implementation that converts transaction events and affected objects to JSON records written to a managed System.IO.Stream.
JsonIterator(Connection con, Stream s, bool compact, bool ignore_stream_errors)
Creates a JSON iterator for the specified connection and output stream. When compact is true, compact JSON is generated; otherwise the output is formatted for readability. When ignore_stream_errors is false, stream write errors stop replication; when it is true, replication continues and stream errors are ignored.
JsonIterator(Connection con, Stream s)
Convenience constructor using the wrapper defaults: compact JSON output and stream errors not ignored.
ReplicaConnection Integration
Assign an iterator instance to ReplicaConnection.Parameters.Iterator before calling AttachMaster(). The iterator then receives object and schema-change output from the master-side replication stream.
JSON Output
The JSON iterator is intended for dynamic schema replication and similar inspection scenarios. Output records are written to the provided stream and can be processed by the application incrementally.
Typical Usage
Create ReplicaConnection.Parameters, assign new TransIterator.JsonIterator(con, stream) to Parameters.Iterator, call AttachMaster(), and finally call Close() on the iterator when replication is stopped.
Related Guide
For the JSON object format, supported operation names, and dynamic schema replication workflow, see Dynamic Schema Modification.