AMPS C# Client  5.3.5.0
AMPS C# Client for .NET
AMPS.Client.MemoryPublishStore Class Reference

An in-memory publish store, used to provide republish capability when in case of failover to an AMPS secondary. More...

+ Inheritance diagram for AMPS.Client.MemoryPublishStore:

Public Member Functions

 MemoryPublishStore (int initialCapacity, bool errorOnPublishGap=false)
 Constructs an in-memory public store with the specified number of blocks as the initial capacity. Creates a new MemoryPublishStore. More...
 
override void discardUpTo (ulong sequence)
 Discard messages in the store, up to and including the message specified by the passed in sequnence number. This is called by the client when it's notified a message is persisted on the server. The space used by discarded messages is made available for reuse by later messages. More...
 
override bool getErrorOnPublishGap ()
 Get if a PublishStoreGapException can be thrown by the Store if there is an attempt to call discardUpTo with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination. More...
 
override void Dispose ()
 Disposes the MemoryPublishStore instance. More...
 
- Public Member Functions inherited from AMPS.Client.BlockPublishStore
void store (Message m)
 Stores a message in the BlockPublishStore. More...
 
void store (Message m, Boolean assignSequence)
 Internal utility method for storing messages in the BlockPublishStore. More...
 
ulong getLastPersisted ()
 Gets the last persisted sequence number More...
 
ulong getLowestUnpersisted ()
 Gets the lowest unpersisted sequence number. More...
 
ulong getHighestUnpersisted ()
 Gets the highest unpersisted sequence number. More...
 
void setMessage (Message message)
 Used internally by the Client to give the store a Message implementing the correct protocol for the connection. This Message instance is also used for replay operations. More...
 
virtual void replay (StoreReplayer replayer)
 Implemented to replay unpersisted messages from the stored blocks onto the provided StoreReplayer. More...
 
bool replaySingle (StoreReplayer replayer, ulong sequence)
 Implemented to find the unpersisted message with the specified sequence among the stored blocks, and replay it onto the provided StoreReplayer. Checks if the specified sequence is less than or equal to the stored metadata block's sequence number. More...
 
long unpersistedCount ()
 Returns the count of unpersisted messages in the store. This count represents the number of messages that have been received but not yet persisted. More...
 
void flush ()
 Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return. More...
 
void flush (int timeout)
 Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return. Throw an exception if this is not completed in the number of milliseconds specified by the timeout. More...
 
void setResizeHandler (PublishStoreResizeHandler handler)
 Set the resize handler for the publish store. An implementation can call the resize handler in the event that it needs to grow the size of the publish store. More...
 
void setErrorOnPublishGap (bool errorOnPublishGap_)
 Set if a PublishStoreGapException should be thrown by the Store if there is an attempt to call discardUpTo with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination. More...
 

Additional Inherited Members

- Protected Member Functions inherited from AMPS.Client.BlockPublishStore
 BlockPublishStore (Buffer buffer, int blocksPerRealloc, bool errorOnPublishGap_=false)
 Initializes a new instance of the BlockPublishStore class with the specified buffer and block allocation configuration. More...
 
 BlockPublishStore (Buffer buffer, bool useCrc=false, int blocksPerRealloc=10000, bool errorOnPublishGap_=false)
 Initializes a new instance of the BlockPublishStore class with the specified buffer. More...
 
void recover ()
 Recovers the state of the BlockPublishStore by reconstructing the used and free lists from the stored blocks in the buffer. More...
 
void growFreeListIfEmpty ()
 Ensures that the free list has at least one block available for use. More...
 
- Protected Attributes inherited from AMPS.Client.BlockPublishStore
bool _errorOnPublishGap = false
 
PublishStoreResizeHandler _resizeHandler = null
 
Buffer _buffer
 
Utilities.CRC32 _crc = null
 

Detailed Description

An in-memory publish store, used to provide republish capability when in case of failover to an AMPS secondary.

Publish stores hold messages until the AMPS server has acknowledged that they are persisted. When the client detects disconnection and reconnects, the client can republish any messages which have not been acknowledged by AMPS.

Use this PublishStore when you are concerned about server failover, only: MemoryPublishStore does not protect you in case of subscriber failure, because it has no on-disk backing store.

Constructor & Destructor Documentation

◆ MemoryPublishStore()

AMPS.Client.MemoryPublishStore.MemoryPublishStore ( int  initialCapacity,
bool  errorOnPublishGap = false 
)
inline

Constructs an in-memory public store with the specified number of blocks as the initial capacity. Creates a new MemoryPublishStore.

Parameters
initialCapacityThe initial capacity (in 2k blocks) of the store. This size is also used when resizing the store: the store is resized by this value each time the store grows. A general guideline for initial capacity is to set the capacity to messages_published_per_second * int(average_message_size / block_size) + 1.
errorOnPublishGapIndicates if an excpetion should be thrown if discardUpTo is called with an idex below the last persisted.

Member Function Documentation

◆ discardUpTo()

override void AMPS.Client.MemoryPublishStore.discardUpTo ( ulong  sequence)
inlinevirtual

Discard messages in the store, up to and including the message specified by the passed in sequnence number. This is called by the client when it's notified a message is persisted on the server. The space used by discarded messages is made available for reuse by later messages.

Parameters
sequenceThe highest sequence number of the messages that can be safely discarded. The specified message and all prior messages are removed from the store.
Exceptions
StoreExceptionIf an error occurred during discarding.

Reimplemented from AMPS.Client.BlockPublishStore.

◆ Dispose()

override void AMPS.Client.MemoryPublishStore.Dispose ( )
inlinevirtual

Disposes the MemoryPublishStore instance.

Reimplemented from AMPS.Client.BlockPublishStore.

◆ getErrorOnPublishGap()

override bool AMPS.Client.MemoryPublishStore.getErrorOnPublishGap ( )
inlinevirtual

Get if a PublishStoreGapException can be thrown by the Store if there is an attempt to call discardUpTo with a sequence number lower than the last persisted sequence number. This could occur during logon after a failover event if the new server was not current on messages due to being an async replication destination.

Returns
True if the exception will be thrown

Reimplemented from AMPS.Client.BlockPublishStore.


The documentation for this class was generated from the following file: