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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMessageDeliveryFailureListener(TopicListener messageFailedEventListener)
This method registers for message delivery failure events on this topic.void
addTopicDeletedListener(TopicListener deleteEventListener)
This method registers for topic deleted event.DurableTopicSubscription
createDurableSubscription(java.lang.String subscriptionName, SubscriptionPolicy subscriptionPolicy, MessageReceivedListener messageReceivedListener, TimeSpan expirationTime)
This method is used to create a durable subscription to this topic.DurableTopicSubscription
createDurableSubscription(java.lang.String subscriptionName, SubscriptionPolicy subscriptionPolicy, MessageReceivedListener messageReceivedListener, TimeSpan expirationTime, DeliveryMode deliveryMode)
This method is used to create a durable subscription to this topic.TopicSubscription
createSubscription(MessageReceivedListener messageReceivedEventListener)
This method is used to subscribe against topic on cache if topic exists.TopicSubscription
createSubscription(MessageReceivedListener messageReceivedEventListener, DeliveryMode deliveryMode)
This method is used to subscribe against topic on cache if topic exists.TimeSpan
getExpirationTime()
Gets the expiry time of messsage for this topic.boolean
getIsClosed()
Specifies whether topic is closed or not.long
getMessageCount()
Gets the number of messages published for this topic.java.lang.String
getName()
Gets the name of the Topic.TopicPriority
getPriority()
The relative priority of the topic.TopicSearchOptions
getSearchOptions()
Specifies whether user has subscribed to pattern based or simple subscription.void
publish(Message message, DeliveryOption deliverOption)
This method is used to publish the message to the topic with the specified DeliveryOption.void
publish(Message message, DeliveryOption deliverOption, boolean notifyDeliveryFailure)
This method is used to publish the message to the topic with the specified DeliveryOption.void
publish(Message message, DeliveryOption deliverOption, java.lang.String sequenceName)
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.void
publish(Message message, DeliveryOption deliverOption, java.lang.String sequenceName, boolean notifyDeliveryFailure)
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.java.util.concurrent.FutureTask
publishAsync(Message message, DeliveryOption deliverOption)
This method is used to Publish a message asynchronously to the topic with specified delivery option.java.util.concurrent.FutureTask
publishAsync(Message message, DeliveryOption deliverOption, boolean notifyDeliveryFailure)
This method is used to Publish a message asynchronously to the topic with specified delivery option.java.util.Map<Message,java.lang.Exception>
publishBulk(java.util.Map<Message,DeliveryOption> messages)
This method is used to Publish messages to the topic with specified DeliveryOption.java.util.Map<Message,java.lang.Exception>
publishBulk(java.util.Map<Message,DeliveryOption> messages, boolean notifyDeliveryFailure)
This method is used to Publish messages to the topic with specified DeliveryOption.void
removeMessageDeliveryFailureListener()
This method unregisters for message delivery failure events on this topic.void
removeTopicDeletedListener()
This method unregisters for topic deleted event.void
setExpirationTime(TimeSpan value)
Sets the expiry time of messsage for this topic.
-
-
-
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 messages published 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:
- The expiry time of message for this topic.
-
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 user has subscribed to pattern based or 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 topic on cache if topic exists. This method uses synchronous delivery mode that enables registered subscribers to receive messages in the same order as they are published.- Parameters:
messageReceivedEventListener
- The listener that is invoked whenever a message is published against the topic.- Returns:
- The created topoc subscription.
- Throws:
java.lang.Exception
-
createSubscription
TopicSubscription createSubscription(MessageReceivedListener messageReceivedEventListener, DeliveryMode deliveryMode) throws java.lang.Exception
This method is used to subscribe against topic on cache if topic exists.- Parameters:
messageReceivedEventListener
- The listener that is invoked whenever a message is published against the topic.deliveryMode
- Specifies whether to deliver messages to register subscribers synchronously or asynchronously.- Returns:
- The created topoc 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
- 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.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 to the topic with the specified DeliveryOption.- 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 to the topic with the specified DeliveryOption.- Parameters:
message
- Message to be published.deliverOption
- Specifies how message is delivered to registered subscribers.notifyDeliveryFailure
- Specifies whether 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 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.- 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 to the topic with specified delivery option.- Parameters:
message
- Message to be published.deliverOption
- Specifies how message is delivered to registered subscribers.- Returns:
- Future Task that performs an 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 to the topic with specified delivery option.- Parameters:
message
- Message to be published.deliverOption
- Specifies how message is delivered to registered subscribers.notifyDeliveryFailure
- Specifies whether MessageDeliveryFailure event is required for this message.- Returns:
- Future Task that performs an 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 specified DeliveryOption.- Parameters:
messages
- Collection of message-deliveryoption 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 specified DeliveryOption.- Parameters:
messages
- Collection of message-deliveryoption 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
-
-