public class ClientSubscription extends Object implements ClientSubscriptionMBean, Serializable, Encodable
ClientSubscription
class holds the data of a client
subscription, and the methods managing the delivery and acknowledgement
of the messages.Modifier and Type | Class and Description |
---|---|
static class |
ClientSubscription.ClientSubscriptionFactory |
Modifier and Type | Field and Description |
---|---|
private int |
active
Give the maximum number of messages per request if the subscription is active,
0 if the subscription is passive.
|
private String |
clientID |
private int |
contextId
Identifier of the subscription context.
|
private int |
DEFAULT_MAX_NUMBER_OF_MSG_PER_REQUEST |
private Map<String,String> |
deliveredIds
Table of delivered messages identifiers.
|
private Map<String,Integer> |
deniedMsgs
Table keeping the denied messages identifiers.
|
private AgentId |
dmqId
Identifier of the subscriber's dead message queue,
null for
DMQ not set. |
private boolean |
durable
true if the subscription is durable. |
static org.objectweb.util.monolog.api.Logger |
logger |
static String |
MESSAGE_ID_LIST_PREFIX |
static String |
MESSAGE_TIME_ID_LIST_PREFIX |
private MessageIdList |
messageIds
List of identifiers of the messages to deliver.
|
private MessageTable |
messagesTable
Proxy messages table.
|
private MessageIdList |
messageTimeIds
List of identifiers of the messages delivery time.
|
boolean |
modified |
private String |
name
The subscription name.
|
protected int |
nbMaxMsg
Max number of Message stored in the queue (-1 no limit).
|
protected long |
nbMsgsDeliveredSinceCreation
the number of delivered messages
|
protected long |
nbMsgsSentToDMQSinceCreation
the number of erroneous messages forwarded to the DMQ
|
private boolean |
noFiltering
true if the subscription does not filter messages
in any way. |
private boolean |
noLocal
true if the subscriber does not wish to consume
messages published in the same context. |
private ProxyAgentItf |
proxy |
private AgentId |
proxyId
The proxy's agent identifier.
|
private long |
requestExpTime
Expiration time of the "receive" request, if any.
|
private int |
requestId
Identifier of the request requesting messages, either the listener's
request, or a "receive" request.
|
private String |
selector
The selector for filtering messages.
|
private static long |
serialVersionUID
define serialVersionUID for interoperability
|
private int |
subRequestId
Identifier of the subscription request.
|
private int |
threshold
Threshold above which messages are considered as undeliverable because
constantly denied.
0 stands for no threshold, -1 for value not set (use servers' default value).
|
private boolean |
toListener
true if the messages are destinated to a listener. |
private AgentId |
topicId
The topic identifier.
|
String |
txName |
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
Constructor and Description |
---|
ClientSubscription() |
ClientSubscription(AgentId proxyId,
int contextId,
int reqId,
boolean durable,
AgentId topicId,
String name,
String selector,
boolean noLocal,
AgentId dmqId,
int threshold,
int nbMaxMsg,
MessageTable messagesTable,
String clientID)
Constructs a
ClientSubscription instance. |
Modifier and Type | Method and Description |
---|---|
(package private) void |
acknowledge(Iterator acks)
Acknowledges messages.
|
(package private) void |
acknowledge(String id) |
(package private) void |
browseNewMessages(List newMessages)
Browses messages and keeps those which will have to be delivered
to the subscriber.
|
void |
clear()
Deletes all messages
|
(package private) void |
deactivate(boolean denies)
De-activates the subscription.
|
void |
decode(Decoder decoder)
Decodes the content of this object
|
private void |
decrAckCounters(String msgId,
Message message) |
void |
delete() |
void |
deleteMessage(String msgId)
Deletes a particular pending message in the subscription.
|
(package private) void |
deleteMessages()
Decreases the subscription's messages acknowledgement expectations,
deletes those not to be consumed anymore.
|
(package private) ConsumerMessages |
deliver()
Launches a delivery sequence, either for a listener, or for a receiver.
|
(package private) void |
deny(Iterator<String> denies,
boolean redelivered)
Denies messages.
|
private void |
deny(Iterator<String> denies,
boolean remove,
boolean redelivered)
Denies the messages.
|
void |
encode(Encoder encoder)
Encodes the content of this object
|
int |
getActive()
Returns the maximum number of messages per request if the subscription is active.
|
(package private) String |
getClientID() |
int |
getContextId()
Returns the subscription's context identifier.
|
(package private) Map<String,String> |
getDeliveredIds() |
int |
getDeliveredMessageCount()
Returns the number of messages delivered and waiting for acknowledge.
|
(package private) Map<String,Integer> |
getDeniedMsgs() |
boolean |
getDurable()
Returns
true if the subscription is durable. |
int |
getEncodableClassId()
Returns a unique class identifier.
|
int |
getEncodedSize()
Returns the size of the byte array that results
from the encoding of this object.
|
CompositeData |
getMessage(String msgId)
Returns the description of a particular pending message.
|
String[] |
getMessageIds()
Returns the list of message's identifiers for the subscription.
|
TabularData |
getMessages()
Returns the description of all pending messages.
|
List<MessageView> |
getMessagesView() |
String |
getName()
Returns the name of the subscription.
|
int |
getNbMaxMsg()
Returns the maximum number of message for the subscription.
|
long |
getNbMsgsDeliveredSinceCreation()
Returns the number of messages delivered to the client since creation time
of this subscription.
|
long |
getNbMsgsSentToDMQSinceCreation()
Returns the number of erroneous messages forwarded to the DMQ since
creation time of this subscription.
|
int |
getPendingDeliveryTimeMessageCount()
Returns the number of pending delivery time messages for the subscription.
|
int |
getPendingMessageCount()
Returns the number of pending messages for the subscription.
|
AgentId |
getProxyId() |
String |
getSelector()
Returns the selector.
|
(package private) Message |
getSubMessage(String msgId) |
int |
getSubRequestId()
Returns the identifier of the subscribing request.
|
(package private) Message |
getSubscriptionMessage(String msgId) |
int |
getThreshold()
Returns the threshold above which messages are considered undeliverable
because constantly denied.
|
AgentId |
getTopicId()
Returns the identifier of the subscription topic.
|
String |
getTopicIdAsString()
Returns the identifier of the subscription topic.
|
static String |
getTransactionPrefix(AgentId proxyId) |
private String |
getTxName() |
void |
initMessageIds() |
private boolean |
isUndeliverable(int deliveryAttempts)
Returns
true if a given message is considered as undeliverable,
because its delivery count matches the subscription's threshold, if any, or the
server's default threshold value (if any). |
void |
loadMessageIds() |
(package private) void |
reactivate(int contextId,
int reqId,
AgentId topicId,
String selector,
boolean noLocal)
Reactivates the subscription.
|
(package private) void |
reinitialize(MessageTable messagesTable,
List persistedMessages,
boolean denyDeliveredMessages)
Re-initializes the client subscription.
|
(package private) Message |
removeMessage(String msgId)
Removes a particular pending message in the subscription.
|
(package private) void |
removeMessagesTimeIds(String msgId) |
void |
save() |
(package private) void |
scheduleDeliveryTimeMessage(Message message)
schedule the delivery time message.
|
(package private) void |
setActive(int active) |
(package private) void |
setDMQId(AgentId dmqId)
Sets the subscription's dead message queue identifier.
|
(package private) void |
setListener(int requestId)
Sets a listener.
|
private void |
setModified() |
void |
setNbMaxMsg(int nbMaxMsg)
Sets the maximum number of message for the subscription.
|
(package private) void |
setProxyAgent(ProxyAgentItf px) |
void |
setProxyId(AgentId proxyId) |
(package private) void |
setReceiver(int requestId,
long timeToLive)
Sets a receiver request.
|
void |
setThreshold(int threshold)
Sets the subscription's threshold value.
|
String |
toString() |
(package private) void |
unsetListener()
Unsets the listener.
|
(package private) void |
unsetReceiver()
Unsets a receiver request.
|
private static final long serialVersionUID
public static org.objectweb.util.monolog.api.Logger logger
public static final String MESSAGE_ID_LIST_PREFIX
public static final String MESSAGE_TIME_ID_LIST_PREFIX
private AgentId proxyId
private boolean durable
true
if the subscription is durable.private AgentId topicId
private String name
private String selector
private AgentId dmqId
null
for
DMQ not set.private int threshold
protected int nbMaxMsg
private transient MessageIdList messageIds
private transient MessageIdList messageTimeIds
private transient int contextId
private transient int subRequestId
private transient boolean noLocal
true
if the subscriber does not wish to consume
messages published in the same context.private transient boolean noFiltering
true
if the subscription does not filter messages
in any way.private transient int active
private transient int requestId
private transient boolean toListener
true
if the messages are destinated to a listener.private transient long requestExpTime
private transient MessageTable messagesTable
private transient ProxyAgentItf proxy
protected long nbMsgsSentToDMQSinceCreation
protected long nbMsgsDeliveredSinceCreation
private int DEFAULT_MAX_NUMBER_OF_MSG_PER_REQUEST
public transient String txName
public transient boolean modified
private String clientID
ClientSubscription()
ClientSubscription(AgentId proxyId, int contextId, int reqId, boolean durable, AgentId topicId, String name, String selector, boolean noLocal, AgentId dmqId, int threshold, int nbMaxMsg, MessageTable messagesTable, String clientID) throws RequestException
ClientSubscription
instance.proxyId
- Proxy's identifier.contextId
- Context identifier.reqId
- Request identifier.durable
- true
for a durable subscription.topicId
- Topic identifier.name
- Subscription's name.selector
- Selector for filtering messages.noLocal
- true
for not consuming messages published
within the same proxy's context.dmqId
- Identifier of the proxy's dead message queue, if any.threshold
- Proxy's threshold value, if any.messagesTable
- Proxy's messages table.clientID
- the clientIDRequestException
public int getThreshold()
getThreshold
in interface ClientSubscriptionMBean
public void setThreshold(int threshold)
public int getNbMaxMsg()
getNbMaxMsg
in interface ClientSubscriptionMBean
public void setNbMaxMsg(int nbMaxMsg)
setNbMaxMsg
in interface ClientSubscriptionMBean
nbMaxMsg
- the maximum number of message for subscription (-1 set
no limit).public AgentId getProxyId()
public void setProxyId(AgentId proxyId)
public int getContextId()
getContextId
in interface ClientSubscriptionMBean
public int getSubRequestId()
getSubRequestId
in interface ClientSubscriptionMBean
public String getName()
getName
in interface ClientSubscriptionMBean
public AgentId getTopicId()
public String getTopicIdAsString()
getTopicIdAsString
in interface ClientSubscriptionMBean
public String getSelector()
getSelector
in interface ClientSubscriptionMBean
public boolean getDurable()
true
if the subscription is durable.getDurable
in interface ClientSubscriptionMBean
public int getActive()
getActive
in interface ClientSubscriptionMBean
public int getPendingMessageCount()
getPendingMessageCount
in interface ClientSubscriptionMBean
public int getPendingDeliveryTimeMessageCount()
public int getDeliveredMessageCount()
getDeliveredMessageCount
in interface ClientSubscriptionMBean
public String[] getMessageIds()
getMessageIds
in interface ClientSubscriptionMBean
void setProxyAgent(ProxyAgentItf px)
void reinitialize(MessageTable messagesTable, List persistedMessages, boolean denyDeliveredMessages)
messagesTable
- Proxy's table where storing the messages.persistedMessages
- Proxy's persisted messages.denyDeliveredMessages
- Denies already delivered messages.void reactivate(int contextId, int reqId, AgentId topicId, String selector, boolean noLocal)
context
- Re-activation context.reqId
- Re-activation request identifier.topicId
- Topic identifier.selector
- Selector for filtering messages.noLocal
- true
for not consuming messages published
within the same proxy's context.void deactivate(boolean denies)
denies
- denies the non acknowledged messages.void setActive(int active)
void setListener(int requestId)
requestId
- Identifier of the listener request.void unsetListener()
void setReceiver(int requestId, long timeToLive)
requestId
- Identifier of the "receive" request.timeToLive
- Request's time to live value.void unsetReceiver()
void setDMQId(AgentId dmqId)
void scheduleDeliveryTimeMessage(Message message)
msgId
- the message Idvoid removeMessagesTimeIds(String msgId)
void browseNewMessages(List newMessages)
ConsumerMessages deliver()
void acknowledge(Iterator acks)
void acknowledge(String id)
void deny(Iterator<String> denies, boolean redelivered)
denies
- all ids of the messages to denyredelivered
- true if redelivered.private void deny(Iterator<String> denies, boolean remove, boolean redelivered)
denies
- all ids of the messages to denyremove
- true to remove messages from deliveredIds map. Must be false
when denies iterates over deliveredIds map keys, to avoid a
ConcurrentModificationException.redelivered
- true if redelivered.void deleteMessages()
private boolean isUndeliverable(int deliveryAttempts)
true
if a given message is considered as undeliverable,
because its delivery count matches the subscription's threshold, if any, or the
server's default threshold value (if any).public long getNbMsgsSentToDMQSinceCreation()
ClientSubscriptionMBean
getNbMsgsSentToDMQSinceCreation
in interface ClientSubscriptionMBean
public long getNbMsgsDeliveredSinceCreation()
ClientSubscriptionMBean
getNbMsgsDeliveredSinceCreation
in interface ClientSubscriptionMBean
public CompositeData getMessage(String msgId) throws Exception
getMessage
in interface ClientSubscriptionMBean
msgId
- The unique message's identifier.Exception
MessageJMXWrapper
public TabularData getMessages() throws Exception
getMessages
in interface ClientSubscriptionMBean
Exception
MessageJMXWrapper
public List<MessageView> getMessagesView()
public void deleteMessage(String msgId)
ClientSubscriptionMBean
deleteMessage
in interface ClientSubscriptionMBean
msgId
- The unique message's identifier.public void clear()
ClientSubscriptionMBean
clear
in interface ClientSubscriptionMBean
Message removeMessage(String msgId)
msgId
- The unique message's identifier.public int getEncodableClassId()
Encodable
getEncodableClassId
in interface Encodable
public int getEncodedSize() throws Exception
Encodable
getEncodedSize
in interface Encodable
Exception
- if an error occurspublic void encode(Encoder encoder) throws Exception
Encodable
public void decode(Decoder decoder) throws Exception
Encodable
private String getTxName()
public void save()
public void delete()
private void setModified()
String getClientID()
Copyright © 2019 ScalAgent D.T.. All rights reserved.