Package com.streambase.liveview.client
Interface TablePublisher
-
- All Superinterfaces:
AutoCloseable,Closeable
public interface TablePublisher extends Closeable
An instance of a publisher for publishing tuples into a table. A publisher can be used to publish new or updated tuples to a table. The server determines if the tuple is new or updated based on the table's primary key. A publisher is created fromTable.getTablePublisher(String)where a publisher name is specified. Tuples published will include the name of the publisher and the specified sequenceNumber for tracking and recoverability purposes.
-
-
Field Summary
Fields Modifier and Type Field Description static intPUBLISH_BUFFER_SIZE_DEFAULTThe default number of tuples buffered on the client side before publishing to the server.static longPUBLISH_INTERVAL_DEFAULTThe default time between buffer flushes when the buffer does not fill up completely.static TimeUnitPUBLISH_INTERVAL_TIME_UNIT_DEFAULTDefault publish interval units:TimeUnit.MILLISECONDS.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes client and server resources held by the publishervoidflush()Force the currently buffered tuples to be sent to the server.PublisherListenergetPublisherListener()Gets thePublisherListenerassociated with thisTablePublisherSchemagetSchema()Schema needed to create tuples for the publish method.PublisherStatusgetStatus()Gets the latestPublisherStatusfor the currentTablePublishervoidpublish(long sequenceNumber, Tuple tuple)Publish a tuple with a sequenceNumber.voidpublish(long sequenceNumber, Boolean CQSDelete, Tuple tuple)Publish a tuple with a sequenceNumber.voidpublish(Tuple tuple)Publish a tuple without regard for recovering since no sequence number is specified.voidpublish(Boolean CQSDelete, Tuple tuple)Publish a tuple without regard for recovering since no sequence number is specified.
-
-
-
Field Detail
-
PUBLISH_BUFFER_SIZE_DEFAULT
static final int PUBLISH_BUFFER_SIZE_DEFAULT
The default number of tuples buffered on the client side before publishing to the server. Value 100.- See Also:
- Constant Field Values
-
PUBLISH_INTERVAL_DEFAULT
static final long PUBLISH_INTERVAL_DEFAULT
The default time between buffer flushes when the buffer does not fill up completely. Value 250L, inPUBLISH_INTERVAL_TIME_UNIT_DEFAULTunits.- See Also:
- Constant Field Values
-
PUBLISH_INTERVAL_TIME_UNIT_DEFAULT
static final TimeUnit PUBLISH_INTERVAL_TIME_UNIT_DEFAULT
Default publish interval units:TimeUnit.MILLISECONDS.
-
-
Method Detail
-
getSchema
Schema getSchema()
Schema needed to create tuples for the publish method. This schema does not include any internal fields maintained by LiveView. It will only be the necessary data fields of the table.- Returns:
- the schema
-
publish
void publish(long sequenceNumber, Tuple tuple) throws LiveViewExceptionPublish a tuple with a sequenceNumber. There are no specific requirements on sequenceNumber, but it can be used as a mechanism for recovery, so a monotonically increasing number is recommended such that the server, on recovery, can report what the last successfully published sequence number was per named publisher. With this approach, a publisher only needs to re-publish tuples starting from the last reported successful published sequenceNumber in LiveView.- Parameters:
sequenceNumber- the identifier known to the publishertuple- the tuple to publish- Throws:
LiveViewException- if any server side exception occurs during publishing
-
publish
void publish(long sequenceNumber, Boolean CQSDelete, Tuple tuple) throws LiveViewExceptionPublish a tuple with a sequenceNumber. If CQSDelete is true, the row that matches the primary key values set in the tuple will be deleted.- Parameters:
sequenceNumber- the identifier known to the publisherCQSDelete- - true if you wish to delete the row defined by the primary key valuestuple- the tuple to publish. If CQSDelete is true the row which matches the primary key values is removed.- Throws:
LiveViewException- if any server side exception occurs during publishing- Since:
- 1.6
-
publish
void publish(Tuple tuple) throws LiveViewException
Publish a tuple without regard for recovering since no sequence number is specified.- Parameters:
tuple- the tuple to publish- Throws:
LiveViewException- if any server side exception occurs during publishing
-
publish
void publish(Boolean CQSDelete, Tuple tuple) throws LiveViewException
Publish a tuple without regard for recovering since no sequence number is specified. If CQSDelete is true, the row that matches the primary key values set in the tuple will be deleted.- Parameters:
CQSDelete- true if you wish to delete the row defined by the primary key valuestuple- the tuple to publish. If CQSDelete is true the row which matches the primary key values is removed.- Throws:
LiveViewException- if any server side exception occurs during publishing- Since:
- 10.5.0
-
getStatus
PublisherStatus getStatus() throws LiveViewException
Gets the latestPublisherStatusfor the currentTablePublisher- Returns:
PublisherStatusto get the latestPublisherStatusof currentTablePublisher- Throws:
LiveViewException- Since:
- 10.5.0
-
getPublisherListener
PublisherListener getPublisherListener() throws LiveViewException
Gets thePublisherListenerassociated with thisTablePublisher- Returns:
PublisherListenerto receivePublisherStatusEvent. Returns null if there is no associatedPublisherListener.- Throws:
LiveViewException- Since:
- 10.5.0
-
flush
void flush() throws LiveViewExceptionForce the currently buffered tuples to be sent to the server. This method blocks while flushing occurs.- Throws:
LiveViewException
-
close
void close()
Closes client and server resources held by the publisher- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-