001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018
019 package org.activemq.service.boundedvm;
020
021
022 import javax.jms.DeliveryMode;
023 import javax.jms.JMSException;
024 import org.activemq.filter.Filter;
025 import org.activemq.message.ActiveMQMessage;
026 import org.activemq.message.ConsumerInfo;
027 import org.activemq.broker.BrokerClient;
028
029 /**
030 * A holder for Transient Topic consumer info and message routing
031 *
032 * @version $Revision: 1.1.1.1 $
033 */
034 public class TransientTopicSubscription extends TransientSubscription{
035
036
037 /**
038 * Construct the TransientTopicSubscription
039 * @param filter
040 * @param info
041 */
042 public TransientTopicSubscription(Filter filter, ConsumerInfo info, BrokerClient client) {
043 super(filter, info, client);
044 }
045
046
047 /**
048 * determines if the Subscription is interested in the message
049 *
050 * @param message
051 * @return true if this Subscription will accept the message
052 * @throws JMSException
053 */
054 public boolean isTarget(ActiveMQMessage message) throws JMSException {
055 boolean result = false;
056 if (message != null) {
057 //make sure we don't loop messages around the cluster
058 if (!client.isClusteredConnection() || !message.isEntryCluster(clusterName)
059 || message.isEntryBroker(brokerName)) {
060 result = filter.matches(message);
061 //if we are durable, check we only send non-persistent messages
062 if (result && consumerInfo.isDurableTopic()) {
063 result = message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT;
064 }
065 }
066 }
067 return result;
068 }
069
070 public boolean isDurableTopic() {
071 return consumerInfo.isDurableTopic();
072 }
073 }