ManagedDestination mDest = dm.
getDestination(jmsDestination.getName(), jmsDestination.isQueue());
if (mDest == null)
{
throw new InvalidDestinationException("No such destination: " + jmsDestination);
}
if (jmsDestination.isTemporary())
{
// Can only create a consumer for a temporary destination on the same connection
// that created it
if (!connectionEndpoint.hasTemporaryDestination(jmsDestination))
{
String msg = "Cannot create a message consumer on a different connection " +
"to that which created the temporary destination";
throw new IllegalStateException(msg);
}
}
int consumerID = connectionEndpoint.getServerPeer().getNextObjectID();
Binding binding = null;
// Always validate the selector first
Selector selector = null;
if (selectorString != null)
{
selector = new Selector(selectorString);
}
if (jmsDestination.isTopic())
{
JMSCondition topicCond = new JMSCondition(false, jmsDestination.getName());
if (subscriptionName == null)
{
// non-durable subscription
if (log.isTraceEnabled()) { log.trace(this + " creating new non-durable subscription on " + jmsDestination); }
// Create the non durable sub
PagingFilteredQueue q;
if (postOffice.isLocal() || !mDest.isClustered())
{
q = new PagingFilteredQueue(new GUID().toString(), idm.getID(), ms, pm, true, false,
mDest.getMaxSize(), selector,
mDest.getFullSize(),
mDest.getPageSize(),
mDest.getDownCacheSize());
binding = postOffice.bindQueue(topicCond, q);
}
else
{
q = new LocalClusteredQueue((ClusteredPostOffice)postOffice, nodeId, new GUID().toString(),
idm.getID(), ms, pm, true, false,
mDest.getMaxSize(), selector, tr,
mDest.getFullSize(),
mDest.getPageSize(),
mDest.getDownCacheSize());
ClusteredPostOffice cpo = (ClusteredPostOffice)postOffice;
binding = cpo.bindClusteredQueue(topicCond, (LocalClusteredQueue)q);
}
String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + q.getName();
int dayLimitToUse = mDest.getMessageCounterHistoryDayLimit();
if (dayLimitToUse == -1)
{
//Use override on server peer
dayLimitToUse = sp.getDefaultMessageCounterHistoryDayLimit();
}
MessageCounter counter =
new MessageCounter(counterName, null, q, true, false,
dayLimitToUse);
sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
}
else
{
if (jmsDestination.isTemporary())
{
throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
}
// We have a durable subscription, look it up
String clientID = connectionEndpoint.getClientID();
if (clientID == null)