activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene Prokopiev <>
Subject Create producer restricting
Date Mon, 25 Sep 2006 11:28:00 GMT

Is it possible to restrict producer creating with ActiveMQ? I tried to 
use this context:


	<!-- ActiveMQ Broker configuration -->
	<bean id="broker" class="" 
init-method="start" destroy-method="stop">
		<property name="persistent" value="false"/>
		<property name="transportConnectorURIs">
		<property name="plugins">
				<bean class="activemq.RestrictPlugin"/>
	<!-- ActiveMQ connection configuration -->
	<bean id="jmsConnectionFactory" 
class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker">
		<property name="brokerURL" value="tcp://localhost:5000"/>
	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory" ref="jmsConnectionFactory"/>
		<property name="defaultDestinationName" value="error"/>

     <!-- Business logic beans -->
	<bean id="messageSender" class="activemq.MessageSender" init-method="send">
		<property name="jmsTemplate" ref="jmsTemplate"/>

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");
			super.addProducer(context, info);

public class MessageSender {
	private JmsTemplate jmsTemplate;

	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	public void send() {

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 
defining beans [broker,jmsConnectionFactory,jmsTemplate,messageSender]; 
root of BeanFactory hierarchy
INFO  ClassPathXmlApplicationContext - 4 beans defined in application 
INFO  ClassPathXmlApplicationContext - Unable to locate MessageSource 
with name 'messageSource': using default 
INFO  ClassPathXmlApplicationContext - Unable to locate 
ApplicationEventMulticaster with name 'applicationEventMulticaster': 
using default 
INFO  DefaultListableBeanFactory - Pre-instantiating singletons in 
defining beans [broker,jmsConnectionFactory,jmsTemplate,messageSender]; 
root of BeanFactory hierarchy]
INFO  BrokerService - ActiveMQ null JMS Message Broker (localhost) is 
INFO  BrokerService - For help or more information please see:
INFO  TransportServerThreadSupport - Listening for connections at: 
INFO  TransportConnector - Connector tcp:// 
INFO  BrokerService - ActiveMQ JMS Message Broker (localhost, started
INFO  ManagementContext - JMX consoles can connect to 

But there are no exception raised? Why can it be?

Eugene Prokopiev

View raw message