Interface Topic

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface Topic
    extends java.lang.AutoCloseable
    The topic interface facilitates creating subscription and publishing of messages against the topic. This also provides event registrations for message delivery failure, receiving messages and deleting topics.
    • Method Detail

      • getName

        java.lang.String getName()
        Gets the name of the topic.
        Returns:
        The name of the topic.
      • getMessageCount

        long getMessageCount()
                      throws java.lang.Exception
        Gets the number of messages published for this topic.
        Returns:
        The number of published messages for this topic.
        Throws:
        java.lang.Exception
      • getPriority

        TopicPriority getPriority()
        The relative priority of the topic.
        Returns:
        The priority of the topic.
      • getExpirationTime

        TimeSpan getExpirationTime()
        Gets the expiry time of messsage for this topic. Its default value is TimeSpan.MaxValue.
        Returns:
        Time interval after which the message expires.
      • setExpirationTime

        void setExpirationTime​(TimeSpan value)
        Sets the expiry time of messsage for this topic.
        Parameters:
        value - The expiry time of message for this topic.
      • getIsClosed

        boolean getIsClosed()
        Specifies whether topic is closed or not.
        Returns:
        True, if topic is closed otherwise, false.
      • getSearchOptions

        TopicSearchOptions getSearchOptions()
        Specifies whether the user has subscribed to pattern based or the simple subscription.
        Returns:
        The topic search options for this topic.
      • createSubscription

        TopicSubscription createSubscription​(MessageReceivedListener messageReceivedEventListener)
                                      throws java.lang.Exception
        This method is used to subscribe against a topic on cache if topic exists, otherwise throws exception. This method uses synchronous delivery mode that enables registered subscribers to receive messages in the same order as they are published.
        Parameters:
        messageReceivedEventListener - The Message is delivered through this listener.
        Returns:
        It returns the created topic subscription.
        Throws:
        java.lang.Exception
      • createSubscription

        TopicSubscription createSubscription​(MessageReceivedListener messageReceivedEventListener,
                                             DeliveryMode deliveryMode)
                                      throws java.lang.Exception
        This method is used to subscribe against a topic on cache if topic exists, otherwise throws exception.
        Parameters:
        messageReceivedEventListener - The Message is delivered through this listener.
        deliveryMode - Specifies whether to deliver messages to register subscribers synchronously or asynchronously.
        Returns:
        It returns the created topic subscription.
        Throws:
        java.lang.Exception
      • createDurableSubscription

        DurableTopicSubscription createDurableSubscription​(java.lang.String subscriptionName,
                                                           SubscriptionPolicy subscriptionPolicy,
                                                           MessageReceivedListener messageReceivedListener,
                                                           TimeSpan expirationTime,
                                                           DeliveryMode deliveryMode)
                                                    throws CacheException
        This method is used to create a Durable Subscription to this topic.
        Parameters:
        subscriptionName - Subscription policy whether Shared or Exclusive.
        subscriptionPolicy - Policy that is subscription is Shared or Exclusive.
        messageReceivedListener - Message is delivered through this listener.
        expirationTime - A timespan that determines the expiration time of the subscription..
        deliveryMode - Specifies whether to deliver messages to register subscribers synchronously or asynchronously.
        Returns:
        Instance of DurableTopicSubscription.
        Throws:
        CacheException
      • createDurableSubscription

        DurableTopicSubscription createDurableSubscription​(java.lang.String subscriptionName,
                                                           SubscriptionPolicy subscriptionPolicy,
                                                           MessageReceivedListener messageReceivedListener,
                                                           TimeSpan expirationTime)
                                                    throws CacheException
        This method is used to create a Durable Subscription to this topic.
        Parameters:
        subscriptionName - Name of the Durable Subscription.
        subscriptionPolicy - Policy that is subscription is Shared or Exclusive.
        messageReceivedListener - Message is delivered to registered user through this listener.
        expirationTime - A timespan that specifies the expiration time of the subscription.
        Returns:
        Instance of DurableTopicSubscription.
        Throws:
        CacheException
      • publish

        void publish​(Message message,
                     DeliveryOption deliverOption)
              throws java.lang.Exception
        This method is used to publish the message in the cache with the specified DeliveryOption. And the option to notify the publisher if the message has failed to deliver because of expiration, eviction or internal system issue.
        Parameters:
        message - Message to be published.
        deliverOption - Specifies how message is delivered to registered subscribers.
        Throws:
        java.lang.Exception
      • publish

        void publish​(Message message,
                     DeliveryOption deliverOption,
                     boolean notifyDeliveryFailure)
              throws java.lang.Exception
        This method is used to publish the message in the cache with the specified DeliveryOption. And the option to notify the publisher if the message has failed to deliver because of expiration, eviction or internal system issue.
        Parameters:
        message - Message to be published.
        deliverOption - Specifies how message is delivered to registered subscribers.
        notifyDeliveryFailure - Specifies if MessageDeliveryFailure event is required for this message.
        Throws:
        java.lang.Exception
      • publish

        void publish​(Message message,
                     DeliveryOption deliverOption,
                     java.lang.String sequenceName)
              throws java.lang.Exception
        This method is used to publish the message in the cache with the specified DeliveryOption. And the option to notify the publisher if the message has failed to deliver because of expiration, eviction or internal system issue.
        Parameters:
        message - Message to be published.
        deliverOption - Specifies how message is delivered to registered subscribers.
        sequenceName - Sequence name of the message to be publsihed. The messages with same sequence name will be delivered in the same order as they are published.
        Throws:
        java.lang.Exception
      • publish

        void publish​(Message message,
                     DeliveryOption deliverOption,
                     java.lang.String sequenceName,
                     boolean notifyDeliveryFailure)
              throws java.lang.Exception
        This method is used to publish the message to the topic with the specified DeliveryOption and sequence name. Order of messages with same sequence name is retained.
        Parameters:
        message - Message to be published.
        deliverOption - Specifies how message is delivered to registered subscribers.
        sequenceName - Sequence name of the message to be publsihed. The messages with same sequence name will be delivered in the same order as they are published.
        notifyDeliveryFailure - Specifies whether MessageDeliveryFailure event is required for this message.
        Throws:
        java.lang.Exception
      • publishAsync

        java.util.concurrent.FutureTask publishAsync​(Message message,
                                                     DeliveryOption deliverOption)
                                              throws java.lang.Exception
        This method is used to publish a message asynchronously in the cache with the specified DeliveryOption and the option to notify the publisher if the message has failed to deliver because of expiration, eviction or internal system issue.
        Parameters:
        message - Message to be published.
        deliverOption - Specifies how message is delivered to registered subscribers.
        Returns:
        Future Task that performs a delete operation in the background. Methods of FutureTask can be used to determine status of the task, i.e., isDone(), isCancelled().
        Throws:
        java.lang.Exception
      • publishAsync

        java.util.concurrent.FutureTask publishAsync​(Message message,
                                                     DeliveryOption deliverOption,
                                                     boolean notifyDeliveryFailure)
                                              throws java.lang.Exception
        This method is used to publish a message asynchronously in the cache with the specified DeliveryOption and the option to notify the publisher if the message has failed to deliver because of expiration, eviction or internal system issue.
        Parameters:
        message - Message to be published.
        deliverOption - Specifies how message is delivered to registered subscribers.
        notifyDeliveryFailure - Specifies if MessageDeliveryFailure event is required for this message.
        Returns:
        Future Task that performs a delete operation in the background. Methods of FutureTask can be used to determine status of the task, i.e., isDone(), isCancelled().
        Throws:
        java.lang.Exception
      • publishBulk

        java.util.Map<Message,​java.lang.Exception> publishBulk​(java.util.Map<Message,​DeliveryOption> messages)
                                                              throws CacheException
        This method is used to publish messages to the topic with the specified DeliveryOption.
        Parameters:
        messages - Collection of message - delivery option pairs in form of a Map.
        Returns:
        Map that contains message along with the exception that occured while message publishing.
        Throws:
        CacheException
      • publishBulk

        java.util.Map<Message,​java.lang.Exception> publishBulk​(java.util.Map<Message,​DeliveryOption> messages,
                                                                     boolean notifyDeliveryFailure)
                                                              throws CacheException
        This method is used to publish messages to the topic with the specified DeliveryOption.
        Parameters:
        messages - Collection of message - delivery option pairs in form of a Map.
        notifyDeliveryFailure - Specifies whether MessageDeliveryFailure event is required for this message.
        Returns:
        Map that contains message along with the exception that occured while message publishing.
        Throws:
        CacheException
      • addTopicDeletedListener

        void addTopicDeletedListener​(TopicListener deleteEventListener)
        This method registers for topic deleted event.
        Parameters:
        deleteEventListener - The listener that is invoked whenever this topic is deleted.
      • removeTopicDeletedListener

        void removeTopicDeletedListener()
        This method unregisters for topic deleted event.
      • addMessageDeliveryFailureListener

        void addMessageDeliveryFailureListener​(TopicListener messageFailedEventListener)
                                        throws java.lang.Exception
        This method registers for message delivery failure events on this topic.
        Parameters:
        messageFailedEventListener - The listener that is invoked whenever there is failure in message delivery.
        Throws:
        java.lang.Exception
      • removeMessageDeliveryFailureListener

        void removeMessageDeliveryFailureListener()
                                           throws java.lang.Exception
        This method unregisters for message delivery failure events on this topic.
        Throws:
        java.lang.Exception