Repository
in
Implementations of this interface provide storage capabilities to an MQTT client.
Services of this type have three primary goals:
- Providing and keeping track of message identifiers, since they must be unique within the message flow (i.e. there may not be duplicates of different messages at the same time).
- Storing and keeping track of subscriptions, which is especially necessary in case of persisted sessions.
- Storing and keeping track of pending messages (i.e. sent messages, which have not been acknowledged yet by the broker).
Table of Contents
- addPendingIncomingMessage() : void
- Adds a pending outgoing message to the repository.
- addPendingOutgoingMessage() : void
- Adds a pending outgoing message to the repository.
- addSubscription() : void
- Adds a subscription to the repository.
- countPendingIncomingMessages() : int
- Returns the number of pending incoming messages.
- countPendingOutgoingMessages() : int
- Returns the number of pending outgoing messages.
- countSubscriptions() : int
- Returns the number of registered subscriptions.
- getPendingIncomingMessage() : PendingMessage|null
- Gets a pending incoming message with the given message identifier, if found.
- getPendingOutgoingMessage() : PendingMessage|null
- Gets a pending outgoing message with the given message identifier, if found.
- getPendingOutgoingMessagesLastSentBefore() : array<string|int, PendingMessage>
- Gets a list of pending outgoing messages last sent before the given date time.
- getSubscriptionsMatchingTopic() : array<string|int, Subscription>
- Gets all subscriptions matching the given topic.
- markPendingOutgoingPublishedMessageAsReceived() : bool
- Marks an existing pending outgoing published message as received in the repository.
- newMessageId() : int
- Returns a new message id. The message id might have been used before, but it is currently not being used (i.e. in a resend queue).
- removePendingIncomingMessage() : bool
- Removes a pending incoming message from the repository.
- removePendingOutgoingMessage() : bool
- Removes a pending outgoing message from the repository.
- removeSubscription() : bool
- Removes the subscription with the given topic filter from the repository.
- reset() : bool
- Re-initializes the repository by deleting all persisted data and restoring the original state, which was given when the repository was first created. This is used when a clean session is requested by a client during connection.
Methods
addPendingIncomingMessage()
Adds a pending outgoing message to the repository.
public
addPendingIncomingMessage(PendingMessage $message) : void
Parameters
- $message : PendingMessage
Tags
Return values
void —addPendingOutgoingMessage()
Adds a pending outgoing message to the repository.
public
addPendingOutgoingMessage(PendingMessage $message) : void
Parameters
- $message : PendingMessage
Tags
Return values
void —addSubscription()
Adds a subscription to the repository.
public
addSubscription(Subscription $subscription) : void
Parameters
- $subscription : Subscription
Return values
void —countPendingIncomingMessages()
Returns the number of pending incoming messages.
public
countPendingIncomingMessages() : int
Return values
int —countPendingOutgoingMessages()
Returns the number of pending outgoing messages.
public
countPendingOutgoingMessages() : int
Return values
int —countSubscriptions()
Returns the number of registered subscriptions.
public
countSubscriptions() : int
Return values
int —getPendingIncomingMessage()
Gets a pending incoming message with the given message identifier, if found.
public
getPendingIncomingMessage(int $messageId) : PendingMessage|null
Parameters
- $messageId : int
Return values
PendingMessage|null —getPendingOutgoingMessage()
Gets a pending outgoing message with the given message identifier, if found.
public
getPendingOutgoingMessage(int $messageId) : PendingMessage|null
Parameters
- $messageId : int
Return values
PendingMessage|null —getPendingOutgoingMessagesLastSentBefore()
Gets a list of pending outgoing messages last sent before the given date time.
public
getPendingOutgoingMessagesLastSentBefore([DateTime|null $dateTime = null ]) : array<string|int, PendingMessage>
If date time is null
, all pending messages are returned.
The messages are returned in the same order they were added to the repository.
Parameters
- $dateTime : DateTime|null = null
Return values
array<string|int, PendingMessage> —getSubscriptionsMatchingTopic()
Gets all subscriptions matching the given topic.
public
getSubscriptionsMatchingTopic(string $topicName) : array<string|int, Subscription>
Parameters
- $topicName : string
Return values
array<string|int, Subscription> —markPendingOutgoingPublishedMessageAsReceived()
Marks an existing pending outgoing published message as received in the repository.
public
markPendingOutgoingPublishedMessageAsReceived(int $messageId) : bool
If the message does not exists, an exception is thrown,
otherwise true
is returned if the message was marked as received, and false
in case it was already marked as received.
Parameters
- $messageId : int
Tags
Return values
bool —newMessageId()
Returns a new message id. The message id might have been used before, but it is currently not being used (i.e. in a resend queue).
public
newMessageId() : int
Tags
Return values
int —removePendingIncomingMessage()
Removes a pending incoming message from the repository.
public
removePendingIncomingMessage(int $messageId) : bool
If a pending message with the given identifier is found and
successfully removed from the repository, true
is returned.
Otherwise false
will be returned.
Parameters
- $messageId : int
Return values
bool —removePendingOutgoingMessage()
Removes a pending outgoing message from the repository.
public
removePendingOutgoingMessage(int $messageId) : bool
If a pending message with the given identifier is found and
successfully removed from the repository, true
is returned.
Otherwise false
will be returned.
Parameters
- $messageId : int
Return values
bool —removeSubscription()
Removes the subscription with the given topic filter from the repository.
public
removeSubscription(string $topicFilter) : bool
Returns true
if a topic subscription existed and has been removed.
Otherwise, false
is returned.
Parameters
- $topicFilter : string
Return values
bool —reset()
Re-initializes the repository by deleting all persisted data and restoring the original state, which was given when the repository was first created. This is used when a clean session is requested by a client during connection.
public
reset() : bool