you need to pass the selector into the call to createConsumer.  Have a
look at the activemq virtual destinations or filtered queue feature,
this will allow you you to configure named queues that match a
selector, all in configuration. You clients just need to pick the
corresponding destination name.

On 13 September 2010 18:23, Alec Bickerton <alec.bicker...@net-m.ch> wrote:
> Hi,
>
> I'm looking for a way to configure a selector using JNDI. Is it possible?
>
> Here's my definitions inside the context.xml
>
>        <Resource name="jms/ConnectionFactory" auth="Container" 
> type="org.apache.activemq.ActiveMQConnectionFactory"
> description="ActiveMQ JMS Connection Factory"
>        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
> brokerURL="failover://(tcp:YYYYYYYYYY)?randomize=false&amp;trackMessages=true"
>  brokerName="JMSBroker"/>
>
> Dev platform
>    <Resource name="jms/topicX" auth="Container" 
> type="org.apache.activemq.command.ActiveMQTopic" description="Portal
> notifications"
>        factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
> physicalName="portal.notify" messageSelector="platform =
> dev"/>
>
> Production
>
>    <Resource name="jms/topicX" auth="Container" 
> type="org.apache.activemq.command.ActiveMQTopic" description="Portal
> notifications"
>        factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
> physicalName="portal.notify" messageSelector="platform =
> prod"/>
>
>
> unfortunately this doesn't appear to work with the code....
>
> connection = connFactory.createConnection();
> Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> Destination dest = (Destination) envContext.lookup("jms/topicX");
> MessageConsumer consumer = session.createConsumer(dest);
> setupConsumer(consumer);
> connection.start();
>
> ...
>
> private void setupConsumer(MessageConsumer consumer) throws JMSException {
>        consumer.setMessageListener(this);
> }
>
> All all messages to the topic are delivered to both production and dev. when 
> platform=dev is set in the admin interface
> and the message is sent.
>
> Can anyone suggest what I'm doing wrong here?
>
> Alec.
>



-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com

Reply via email to