activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Create producer restricting
Date Mon, 25 Sep 2006 11:32:02 GMT
Currently creating a producer is an asynchronous operation on the JMS
Java client, so you'll only receive exceptions on the
ExceptionListener.


On 9/25/06, Eugene Prokopiev <prokopiev@stc.donpac.ru> wrote:
> Hi,
>
> Is it possible to restrict producer creating with ActiveMQ? I tried to
> use this context:
>
> <beans>
>
>         <!-- ActiveMQ Broker configuration -->
>         <bean id="broker" class="org.apache.activemq.broker.BrokerService"
> init-method="start" destroy-method="stop">
>                 <property name="persistent" value="false"/>
>                 <property name="transportConnectorURIs">
>                         <list>
>                                 <value>tcp://localhost:5000</value>
>                         </list>
>                 </property>
>                 <property name="plugins">
>                         <list>
>                                 <bean class="activemq.RestrictPlugin"/>
>                         </list>
>                 </property>
>         </bean>
>
>         <!-- ActiveMQ connection configuration -->
>         <bean id="jmsConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker">
>                 <property name="brokerURL" value="tcp://localhost:5000"/>
>         </bean>
>         <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
>                 <property name="connectionFactory" ref="jmsConnectionFactory"/>
>                 <property name="defaultDestinationName" value="error"/>
>         </bean>
>
>      <!-- Business logic beans -->
>         <bean id="messageSender" class="activemq.MessageSender" init-method="send">
>                 <property name="jmsTemplate" ref="jmsTemplate"/>
>         </bean>
>
> </beans>
>
> RestrictPlugin.java:
>
> public class RestrictPlugin extends BrokerPluginSupport {
>         private Log log = LogFactory.getLog(getClass());
>         public void addProducer(ConnectionContext context, ProducerInfo info)
> throws Exception {
>                 log.debug("addProducer interceptor");
>                 if (info.getDestination().getPhysicalName().contains("error"))
>                         throw new Exception("Error destination");
>                 else
>                         super.addProducer(context, info);
>         }
> }
>
> MessageSender.java:
>
> public class MessageSender {
>
>         private JmsTemplate jmsTemplate;
>
>         public void setJmsTemplate(JmsTemplate jmsTemplate) {
>                 this.jmsTemplate = jmsTemplate;
>         }
>
>         public void send() {
>                 jmsTemplate.convertAndSend("Hello!");
>         }
>
> }
>
> On running this context I got:
> INFO  CollectionFactory - JDK 1.4+ collections available
> INFO  XmlBeanDefinitionReader - Loading XML bean definitions from class
> path resource [activemq/context.xml]
> INFO  DefaultNamespaceHandlerResolver - Ignoring handler
> [org.apache.xbean.spring.context.v2.XBeanNamespaceHandler]: class not found
> INFO  ClassPathXmlApplicationContext - Bean factory for application
> context
> [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=17538308]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [broker,jmsConnectionFactory,jmsTemplate,messageSender];
> root of BeanFactory hierarchy
> INFO  ClassPathXmlApplicationContext - 4 beans defined in application
> context
> [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=17538308]
> INFO  ClassPathXmlApplicationContext - Unable to locate MessageSource
> with name 'messageSource': using default
> [org.springframework.context.support.DelegatingMessageSource@fc9944]
> INFO  ClassPathXmlApplicationContext - Unable to locate
> ApplicationEventMulticaster with name 'applicationEventMulticaster':
> using default
> [org.springframework.context.event.SimpleApplicationEventMulticaster@120a47e]
> INFO  DefaultListableBeanFactory - Pre-instantiating singletons in
> factory
> [org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [broker,jmsConnectionFactory,jmsTemplate,messageSender];
> root of BeanFactory hierarchy]
> INFO  BrokerService - ActiveMQ null JMS Message Broker (localhost) is
> starting
> INFO  BrokerService - For help or more information please see:
> http://incubator.apache.org/activemq/
> INFO  TransportServerThreadSupport - Listening for connections at:
> tcp://prokopiev.stc.donpac.ru:5000
> INFO  TransportConnector - Connector tcp://prokopiev.stc.donpac.ru:5000
> Started
> INFO  BrokerService - ActiveMQ JMS Message Broker (localhost,
> ID:prokopiev.stc.donpac.ru-45238-1159183199414-0:0) started
> INFO  ManagementContext - JMX consoles can connect to
> service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
>
>
> But there are no exception raised? Why can it be?
>
> --
> Thanks,
> Eugene Prokopiev
>
>
>
>
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Mime
View raw message