activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From StefanL <stefan_...@yahoo.se>
Subject Re: Empty message selector throws InvalidSelectorException
Date Wed, 05 Sep 2007 11:22:13 GMT

I'll answer this myself, sorry for assuming that this was a problem in the
amq core when it's in nms.

In java an empty/blank selector is not passed on to the jms broker. See the
ctor in ActiveMQMessageConsumer.java which has this code:

        if (selector != null && selector.trim().length() != 0) {
            // Validate that the selector
            new SelectorParser().parse(selector);
            this.info.setSelector(selector);
        } else {
            this.info.setSelector(null);
        }

I suggest the following change to ActiveMQ.Session.CreateConsumerInfo
(session.cs), 
 - answer.Selector = selector;
 + answer.Selector = String.IsNullOrEmpty(selector) ? null : selector;

Which will set the selector to null if it's empty/blank.

I'll try to update the existing issue AMQNET-44 with this information.

Regards
 Stefan


StefanL wrote:
> 
> When I'm trying to apply the
> https://issues.apache.org/activemq/browse/AMQNET-44 patch in nms I get an
> exception in the broker since I send in an empty/blank selector.
> 
> According to jms doc I find this should be ok and null or empty shall be
> treated as no selector.
> 
> The stack trace I get is:
> Thread [ActiveMQ Transport: tcp:///127.0.0.1:2329] (Suspended (exception
> InvalidSelectorException))	
> 	SelectorParser.parse(String) line: 47	
> 	AbstractSubscription.parseSelector(ConsumerInfo) line: 66	
> 	TopicSubscription(AbstractSubscription).<init>(Broker, ConnectionContext,
> ConsumerInfo) line: 60	
> 	TopicSubscription.<init>(Broker, ConnectionContext, ConsumerInfo,
> UsageManager) line: 70	
> 	ManagedTopicRegion(TopicRegion).createSubscription(ConnectionContext,
> ConsumerInfo) line: 231	
> 	ManagedTopicRegion.createSubscription(ConnectionContext, ConsumerInfo)
> line: 44	
> 	ManagedTopicRegion(AbstractRegion).addConsumer(ConnectionContext,
> ConsumerInfo) line: 201	
> 	ManagedTopicRegion(TopicRegion).addConsumer(ConnectionContext,
> ConsumerInfo) line: 110	
> 	ManagedRegionBroker(RegionBroker).addConsumer(ConnectionContext,
> ConsumerInfo) line: 340	
> 	TransactionBroker(BrokerFilter).addConsumer(ConnectionContext,
> ConsumerInfo) line: 86	
> 	AdvisoryBroker.addConsumer(ConnectionContext, ConsumerInfo) line: 78	
> 	CompositeDestinationBroker(BrokerFilter).addConsumer(ConnectionContext,
> ConsumerInfo) line: 86	
> 	BrokerService$2(MutableBrokerFilter).addConsumer(ConnectionContext,
> ConsumerInfo) line: 96	
> 
> ManagedTransportConnection(TransportConnection).processAddConsumer(ConsumerInfo)
> line: 586	
> 	ConsumerInfo.visit(CommandVisitor) line: 313	
> 	ManagedTransportConnection(TransportConnection).service(Command) line:
> 294	
> 	TransportConnection$1.onCommand(Object) line: 185	
> 	MutexTransport(TransportFilter).onCommand(Object) line: 65	
> 	WireFormatNegotiator.onCommand(Object) line: 133	
> 	InactivityMonitor.onCommand(Object) line: 122	
> 	TcpTransport(TransportSupport).doConsume(Object) line: 84	
> 	TcpTransport.run() line: 137	
> 	Thread.run() line: 619	
> 
> And this test case I've written on the selector also gets the error
> 
> org.apache.activemq.selector
>     public void testEmptySelector() throws Exception {
>         Message message = createMessage();
>         assertSelector(message, "", true);
>     }
> 
> Is this a bug or am I doing something wrong? (4.1.1 release)
> /Stefan
> 
> 

-- 
View this message in context: http://www.nabble.com/Empty-message-selector-throws-InvalidSelectorException-tf4377911s2354.html#a12495969
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message