ManagedDestination mDest = dm.getDestination(jmsDestination.getName(), jmsDestination.isQueue());
if (mDest == null)
{
throw new InvalidDestinationException("No such destination: " + jmsDestination + " has it been deployed?");
}
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);
}
}
String consumerID = GUIDGenerator.generateGUID();
// Always validate the selector first
Selector selector = null;
if (selectorString != null)
{
selector = new Selector(selectorString);
}
Queue queue;
if (jmsDestination.isTopic())
{
if (subscriptionName == null)
{
// non-durable subscription
if (log.isTraceEnabled()) { log.trace(this + " creating new non-durable subscription on " + jmsDestination); }
// Create the non durable sub
queue = new MessagingQueue(nodeId, GUIDGenerator.generateGUID(),
idm.getID(), ms, pm, false,
mDest.getMaxSize(), selector,
mDest.getFullSize(),
mDest.getPageSize(),
mDest.getDownCacheSize(),
mDest.isClustered(),
sp.getRecoverDeliveriesTimeout());
JMSCondition topicCond = new JMSCondition(false, jmsDestination.getName());
postOffice.addBinding(new Binding(topicCond, queue, false), false);
queue.activate();
String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queue.getName();
int dayLimitToUse = mDest.getMessageCounterHistoryDayLimit();
if (dayLimitToUse == -1)
{
//Use override on server peer
dayLimitToUse = sp.getDefaultMessageCounterHistoryDayLimit();
}
//We don't create message counters on temp topics
if (!mDest.isTemporary())
{
MessageCounter counter = new MessageCounter(counterName, null, queue, 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)