/* 1935 */ dayLimitToUse = this.sp.getDefaultMessageCounterHistoryDayLimit();
/* */ }
/* */
/* 1939 */ if (!mDest.isTemporary())
/* */ {
/* 1941 */ MessageCounter counter = new MessageCounter(counterName, null, queue, true, false, dayLimitToUse);
/* */
/* 1943 */ this.sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
/* */ }
/* */ }
/* */ else
/* */ {
/* 1948 */ if (jmsDestination.isTemporary())
/* */ {
/* 1950 */ throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
/* */ }
/* */
/* 1954 */ String clientID = this.connectionEndpoint.getClientID();
/* 1955 */ if (clientID == null)
/* */ {
/* 1957 */ throw new JMSException("Cannot create durable subscriber without a valid client ID");
/* */ }
/* */
/* 1962 */ String name = MessageQueueNameHelper.createSubscriptionName(clientID, subscriptionName);
/* */
/* 1964 */ Binding binding = this.postOffice.getBindingForQueueName(name);
/* */
/* 1966 */ if (binding == null)
/* */ {
/* 1970 */ if (this.trace) log.trace(this + " creating new durable subscription on " + jmsDestination);
/* */
/* 1972 */ Queue queue = new MessagingQueue(this.nodeId, name, this.idm.getID(), this.ms, this.pm, true, mDest.getMaxSize(), selector, mDest.getFullSize(), mDest.getPageSize(), mDest.getDownCacheSize(), mDest.isClustered(), this.sp.getRecoverDeliveriesTimeout());
/* */
/* 1983 */ this.postOffice.addBinding(new Binding(new JMSCondition(false, jmsDestination.getName()), queue, true), (this.postOffice.isClustered()) && (mDest.isClustered()));
/* */
/* 1986 */ queue.activate();
/* */
/* 1989 */ if (!mDest.isTemporary())
/* */ {
/* 1991 */ String counterName = "Subscription." + queue.getName();
/* */
/* 1993 */ MessageCounter counter = new MessageCounter(counterName, subscriptionName, queue, true, true, mDest.getMessageCounterHistoryDayLimit());
/* */
/* 1997 */ this.sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 2004 */ Queue queue = binding.queue;
/* */
/* 2006 */ if (this.trace) log.trace(this + " subscription " + subscriptionName + " already exists");
/* */
/* 2011 */ if (queue.getLocalDistributor().getNumberOfReceivers() > 0)
/* */ {
/* 2013 */ throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
/* */ }
/* */
/* 2019 */ String counterName = "Subscription." + queue.getName();
/* */
/* 2021 */ boolean createCounter = false;
/* */
/* 2023 */ if (this.sp.getMessageCounterManager().getMessageCounter(counterName) == null)
/* */ {
/* 2025 */ createCounter = true;
/* */ }
/* */
/* 2034 */ String filterString = queue.getFilter() != null ? queue.getFilter().getFilterString() : null;
/* */
/* 2036 */ boolean selectorChanged = ((selectorString == null) && (filterString != null)) || ((filterString == null) && (selectorString != null)) || ((filterString != null) && (selectorString != null) && (!filterString.equals(selectorString)));
/* */
/* 2042 */ if (this.trace) log.trace("selector " + (selectorChanged ? "has" : "has NOT") + " changed");
/* */
/* 2044 */ String oldTopicName = ((JMSCondition)binding.condition).getName();
/* */
/* 2046 */ boolean topicChanged = !oldTopicName.equals(jmsDestination.getName());
/* */
/* 2048 */ if (log.isTraceEnabled()) log.trace("topic " + (topicChanged ? "has" : "has NOT") + " changed");
/* */
/* 2050 */ if ((selectorChanged) || (topicChanged))
/* */ {
/* 2052 */ if (this.trace) log.trace("topic or selector changed so deleting old subscription");
/* */
/* 2058 */ this.postOffice.removeBinding(queue.getName(), (this.postOffice.isClustered()) && (mDest.isClustered()));
/* */
/* 2062 */ queue = new MessagingQueue(this.nodeId, name, this.idm.getID(), this.ms, this.pm, true, mDest.getMaxSize(), selector, mDest.getFullSize(), mDest.getPageSize(), mDest.getDownCacheSize(), mDest.isClustered(), this.sp.getRecoverDeliveriesTimeout());
/* */
/* 2072 */ this.postOffice.addBinding(new Binding(new JMSCondition(false, jmsDestination.getName()), queue, true), (this.postOffice.isClustered()) && (mDest.isClustered()));
/* */
/* 2075 */ queue.activate();
/* */
/* 2077 */ if (!mDest.isTemporary())
/* */ {
/* 2079 */ createCounter = true;
/* */ }
/* */ }
/* */
/* 2083 */ if (createCounter)
/* */ {
/* 2085 */ MessageCounter counter = new MessageCounter(counterName, subscriptionName, queue, true, true, mDest.getMessageCounterHistoryDayLimit());
/* */
/* 2089 */ this.sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
/* */ }
/* */
/* */ }