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: Problem with failover and consumer
Date Tue, 26 Sep 2006 10:24:59 GMT
1. You kinda answered your first question - failover: is only used on
the client side - you don't need it on a networkConnector.

2. I don't quite follow this question - when you shut down tomcat and
the JVM your consumer still gets messages? But how when its in the
same JVM? Maybe its just the prefetch buffer you're seeing which is
confusing you?

http://incubator.apache.org/activemq/what-is-the-prefetch-limit-for.html

On 9/26/06, nusa <setianusa07@yahoo.co.uk> wrote:
>
> Hi,
>
> I manage to integrate Tomcat_5.5.17, ActiveMQ_4.0.1 ( embeded broker ), and
> Spring_1.2.8
> using the following config :
>
> 1. activemq.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans>
>
> <!--beans xmlns="http://activemq.org/config/1.0"-->
>
>     <!-- Allows us to use system properties as variables in this
> configuration file -->
>     <bean id="propertyConfigurer"
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>         <property name="locations">
>             <value>classpath:ScanningServer.properties</value>
>         </property>
>     </bean>
>
>     <broker xmlns="http://activemq.org/config/1.0" useJmx="true"
> brokerName="brokerDA" useShutdownHook="true" >
>
>         <!-- Use the following to configure how ActiveMQ is exposed in JMX
>         -->
>         <managementContext>
>             <managementContext connectorPort="1099"
> jmxDomainName="org.apache.activemq"/>
>         </managementContext>
>
>         <!-- In ActiveMQ 4, you can setup destination policies -->
>         <destinationPolicy>
>             <policyMap>
>                  <policyEntries>
>                     <policyEntry queue="MYQUEUE.QUEUE>">
>                         <dispatchPolicy>
>                             <strictOrderDispatchPolicy />
>                         </dispatchPolicy>
>                         <subscriptionRecoveryPolicy>
>                             <lastImageSubscriptionRecoveryPolicy />
>                         </subscriptionRecoveryPolicy>
>                     </policyEntry>
>                 </policyEntries>
>             </policyMap>
>         </destinationPolicy>
>
>         <persistenceAdapter>
>             <journaledJDBC journalLogFiles="5"
> dataDirectory="../activemq-data" dataSource="#oracle-ds"/>
>         </persistenceAdapter>
>
>         <transportConnectors>
>             <transportConnector name="default" uri="tcp://localhost:61616"
> />
>             <transportConnector name="stomp"
> uri="stomp://localhost:61613"/>
>         </transportConnectors>
>
>         <networkConnectors>
>             <networkConnector name="default" uri="failover:tcp//localhost"
> failover="true"/>
>         </networkConnectors>
>
>     </broker>
>
>     <!-- Oracle DataSource Sample Setup -->
>     <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
>          ...
>     </bean>
>
> </beans>
>
>
> 2. applicationContext.xml
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE beans
>     PUBLIC "-//SPRING//DTD BEAN//EN"
> "http://www.springframework.org/dtd/spring-beans.dtd">
>
> <beans>
>
>     <!-- This will start the broker from inside Spring.
>     -->
>     <bean id="brokerDA" class="org.apache.activemq.xbean.BrokerFactoryBean">
>         <property name="config" value="/WEB-INF/activemq.xml"/>
>         <property name="start" value="true"/>
>     </bean>
>
>     <!-- JMS ConnectionFactory to use.
>          It depends on the broker to make sure that the JMS connection
> created AFTER the the
>          broker starts.
>     -->
>     <bean id="jmsFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="brokerDA">
>         <property name="brokerURL">
>             <value>${brokerURL}</value>
>         </property>
>     </bean>
>
>     <!-- Spring JMS Template -->
>     <bean id="myJmsTemplate"
> class="org.springframework.jms.core.JmsTemplate">
>         <property name="connectionFactory">
>             <!-- Lets wrap in a pool to avoid creating a connection per send
> -->
>             <bean
> class="org.springframework.jms.connection.SingleConnectionFactory">
>                 <property name="targetConnectionFactory" ref="jmsFactory" />
>             </bean>
>         </property>
>     </bean>
>
>     <bean id="destination" class="org.apache.activemq.command.ActiveMQQueue"
> autowire="constructor">
>         <constructor-arg>
>             <value>org.apache.activemq.spring.Test.spring.queue</value>
>         </constructor-arg>
>     </bean>
>
>     <!-- a sample POJO which uses a Spring JmsTemplate -->
>     <bean id="producer" class="com.ProducerBean">
>         <property name="template">
>             <ref local="myJmsTemplate"/>
>         </property>
>         <property name="destination">
>             <ref local="destination"/>
>         </property>
>     </bean>
>
>     <!-- a sample POJO consumer -->
>     <bean id="consumer" class="com.ConsumerBean" init-method="start">
>         <property name="template">
>             <ref local="myJmsTemplate"/>
>         </property>
>         <property name="destination">
>             <ref local="destination"/>
>         </property>
>     </bean>
>
>     <!-- End ActiveMQ. -->
>
> </beans>
>
>
> First problem, the failover did not work.
> I got the following error log :
>
> 13:30:32,751 ERROR [web.context.ContextLoader] Context initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'org.apache.activemq.xbean.XBeanBrokerService' defined in
> ServletContext resource [/WEB-INF/activemq.xml]: Cannot create inner bean
> 'default' while setting bean property 'networkConnectors' with key [0];
> nested exception is org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'default' defined in ServletContext resource
> [/WEB-INF/activemq.xml]: Error setting property values; nested exception is
> PropertyAccessExceptionsException (1 errors)
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'default' defined in ServletContext resource
> [/WEB-INF/activemq.xml]: Error setting property values; nested exception is
> PropertyAccessExceptionsException (1 errors)
> PropertyAccessExceptionsException (1 errors)
> org.springframework.beans.MethodInvocationException: Property 'uri' threw
> exception; nested exception is java.io.IOException: DiscoveryAgent scheme
> NOT recognized: [failover]
> java.io.IOException: DiscoveryAgent scheme NOT recognized: [failover]
>     at
> org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:24)
>     at
> org.apache.activemq.transport.discovery.DiscoveryAgentFactory.findDiscoveryAgentFactory(DiscoveryAgentFactory.java:49)
>     at
> org.apache.activemq.transport.discovery.DiscoveryAgentFactory.createDiscoveryAgent(DiscoveryAgentFactory.java:56)
>     at
> org.apache.activemq.network.DiscoveryNetworkConnector.setUri(DiscoveryNetworkConnector.java:57)
> ...
> Caused by: java.io.IOException: Could not find factory class for resource:
> META-INF/services/org/apache/activemq/transport/discoveryagent/failover
>     at
> org.apache.activeio.util.FactoryFinder.doFindFactoryProperies(FactoryFinder.java:87)
>     at
> org.apache.activeio.util.FactoryFinder.newInstance(FactoryFinder.java:57)
>     at
> org.apache.activeio.util.FactoryFinder.newInstance(FactoryFinder.java:46)
>     at
> org.apache.activemq.transport.discovery.DiscoveryAgentFactory.findDiscoveryAgentFactory(DiscoveryAgentFactory.java:45)
>
> If I use the following network configuration :
> <transportConnector name="default" uri="tcp://localhost:61616"
> discoveryUri="multicast://default"/>
> and
> <networkConnector name="default" uri="multicast://default"/>
>
> it works well.
>
> My second problem is that the consumer keeps receiving the messages even
> after I shutdown/startup
> the Tomcat, even I already specified AUTO_ACKNOWLEDGE :
>
> ...
>     public void start() throws JMSException {
>         try {
>             ConnectionFactory factory = template.getConnectionFactory();
>             connection = factory.createConnection();
>
>             // we might be a reusable connection in spring
>             // so lets only set the client ID once if its not set
>             synchronized (connection) {
>                 if (connection.getClientID() == null) {
>                     connection.setClientID(myId);
>                 }
>             }
>
>             connection.start();
>
>             session = connection.createSession(true,
> Session.AUTO_ACKNOWLEDGE);
>             consumer = session.createConsumer(destination, selector, false);
>             consumer.setMessageListener(this);
>         }
>         catch (JMSException ex) {
>             log.error("*** Error Starting Consumer !!!", ex);
>             throw ex;
>         }
>     }
> ...
>
>
> So, here are my questions :
> 1. What is the correct syntax for failover ? And where to define it ?
> 2. what's wrong with my consumer ?
>
> Thanks for any help/suggestion.
>
> --
> View this message in context: http://www.nabble.com/Problem-with-failover-and-consumer-tf2337476.html#a6504024
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

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

Mime
View raw message