activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From petera <peter.ander...@egsgroup.com>
Subject Re: activeMQ embedded broker in separate war
Date Tue, 17 Oct 2006 11:17:23 GMT


I am having the same problem using the embedded broker in Tomcat 5.5 in two
separate web apps.

I have the activemq.xml (SEE BELOW) called in my first web app as follows in
the context.xml :


    <Resource
        name="jms/ConnectionFactory"
        auth="Container"
        type="org.apache.activemq.ActiveMQConnectionFactory"
        description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
        brokerName="LocalActiveMQBroker"
        useEmbeddedBroker="true"/>


Yet when I try to connect in the second web app using: 

    <Resource
        name="jms/ConnectionFactory"
        auth="Container"
        type="org.apache.activemq.ActiveMQConnectionFactory"
        description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        brokerURL="tcp://localhost:61616"
        brokerName="LocalActiveMQBroker"
        useEmbeddedBroker="true"/>

I get the following error message: 
Could not connect to broker URL: tcp://localhost:61616. Reason:
java.net.ConnectException: Connection refused

What I doing wrong ??

TIA Peter

activemq.xml================================
<beans>

  <!-- Allows us to use system properties as variables in this configuration
file -->
   
  <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
 
  
  <broker useJmx="true" xmlns="http://activemq.org/config/1.0">
  
    <persistenceAdapter>
      <journaledJDBC journalLogFiles="5" dataDirectory="../activemq-data"
dataSource="#postgres-ds"/>
    </persistenceAdapter>
  
    <transportConnectors>
       <transportConnector name="default" uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
    </transportConnectors>
    
    <networkConnectors>
      <!-- by default just auto discover the other brokers -->
      <networkConnector name="default" uri="multicast://default"/>
      <!--
      <networkConnector name="host1 and host2"
uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
      -->
    </networkConnectors>
    
  </broker>
  
  <!--  This xbean configuration file supports all the standard spring xml
configuration options -->
  
  <!-- Postgres DataSource Sample Setup -->
  <bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
    <property name="serverName" value="localhost"/>
    <property name="databaseName" value="efed-messaging"/>
    <property name="portNumber" value="0"/>
    <property name="user" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="dataSourceName" value="postgres"/>
    <property name="initialConnections" value="1"/>
    <property name="maxConnections" value="10"/>
  </bean>

</beans>






James.Strachan wrote:
> 
> On 8/2/06, Hyatt <mhyatt@brainbout.com> wrote:
>>
>> I am an ActiveMQ newbie.  I am having some of the same issues expressed
>> in
>> this thread.  I'd like to use embedded broker(s); but, I want to separate
>> the management web-app (console example) from the end-user web-app (chat
>> example).
>> + Config and run the ActiveMQ web-console example: Okay, Done, works
>> great
>> + Config and run the ActiveMQ chat example: Okay, Done, works great
>> + Run the web-console AND the chat example, as two separate web-apps:
>> Crash,
>> Burn, Smoke, Fire (I can reproduce and send errors if needed, but the
>> errors
>> are more inline with other email threads about Journal file already
>> in-use
>> and cannot create broker because broker is already running....I read
>> those
>> threads, and decided that the solutions provided here are closer to what
>> I
>> think I need).
> 
> So WARs are their own separate class loaders. So running an embedded
> broker in each war will cause problems as you are really running 2
> brokers.
> 
> So either...
> 
> (i) put the ActiveMQ classes in your system classpath so there is only
> 1 broker shared in each WAR's class loader
> 
> (ii) remove the embedded broker from one of the wars and connect to
> the embedded broker via tcp
> 
> We could also change the web console so that it doesn't use an
> embedded broker but so that it connects to the other broker via JMX.
> 
>> Let's start with the chat example, and start with James Strachan's
>> comment:
>> > The VM transport only works when the JMS client and broker are in the
>> > same classloader. If you are using 2 separate WARs then the VM
>> > transport cannot be used - so you'll have to use TCP to connect to the
>> > same broker
>>
>> Excellent, I've read that embedded brokers can be created with EITHER:
>> vm://localhost OR tcp://localhost:port.  CORRECT?
>>
>> I changed the web.xml file.  I changed what worked (vm://localhost) to (I
>> tried all of these):
>> tcp://localhost FAILED
>> tcp://localhost:61616 FAILED
>> tcp://localhost:8084 (the port used by NetBean's Bundled Tomcat server at
>> runtime) FAILED
>> If I can get the chat example to work with an embedded broker using
>> tcp://
>> rather than vm://, then I should be able to use the rest of the
>> information
>> in this thread to access the embedded broker from two web-apps.
>>
>> Am I doing enough by changing the web.xml, or do I need to change the
>> broker
>> connections in the Java code?  What am I doing wrong?
>>
>> Using Linux, Tomcat, ActiveMQ 4.0.1, Java 1.5
>>
>> Thanks for your help.
> 
> So configure an embedded broker in one of the WARs with a speciifc TCP
> port (e.g. using the default activemq.xml that comes with the web
> console) - then connect to it with tcp://localhost:61616
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/activeMQ-embedded-broker-in-separate-war-tf1713647.html#a6852950
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message