You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by SP Liu <sp...@gmail.com> on 2006/05/11 16:29:23 UTC

How to run multi jms-assembly deployed in ServiceMix within Geronimo

Hi Guillaume!
It can be incompatble between Geronimo's ActiveMQ and ServiceMix's.so I
followed your instruction that embedding a broker and creating an ActiveMQ
connection factory in servicemix.xml file using spring.It seemed to work
fine.
Unfortunately,if i deployed two different jms's SA by this method,some
errors occur in Geronimo as below:  

...
21:09:22,984 INFO  [DefaultListableBeanFactory] Pre-instantiating singletons
in factory
[org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [org.apache.activemq.xbean.XBeanBrokerService]; root of
BeanFactory hierarchy]
21:09:22,984 INFO  [BrokerService] ActiveMQ 4.0-RC2 JMS Message Broker
(localhost) is starting
21:09:22,984 INFO  [BrokerService] For help or more information please see:
http://incubator.apache.org/activemq/
21:09:23,000 ERROR [BrokerService] Failed to start ActiveMQ JMS Message
Broker. Reason: javax.management.InstanceAlreadyExistsException:
org.apache.activemq:BrokerName=localhost,Type=Broker
javax.management.InstanceAlreadyExistsException:
org.apache.activemq:BrokerName=localhost,Type=Broker
...
	
The similar problem occur when running two different jms's example in SM's
standalone mode as below:

...
 Loading Apache ServiceMix from file: servicemix.xml
WARN - ManagementContext$1.run(86) | Failed to start jmx connector: Cannot
bind
to URL [rmi://localhost:1099/jmxrmi]:
javax.naming.NameAlreadyBoundException: jm
xrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]
ERROR - BrokerService.start(370) | Failed to start ActiveMQ JMS Message
Broker.
Reason: java.net.BindException: Address already in use: JVM_Bind
java.net.BindException: Address already in use: JVM_Bind
...

I know that both of above are caused because we start a broker for each by
embedding activemq.xml.
then I try to add a shared broker to solve these by ServiceMixGBean's
doStart() Method,but failed to start broker by gbean.

Thanks! SP Liu
--
View this message in context: http://www.nabble.com/How-to-run-multi-jms-assembly-deployed-in-ServiceMix-within-Geronimo-t1601059.html#a4341466
Sent from the ServiceMix - User forum at Nabble.com.


Re: How to run multi jms-assembly deployed in ServiceMix within Geronimo

Posted by SP Liu <sp...@gmail.com>.
I had downloaded activemq source from
https://svn.apache.org/repos/asf/incubator/activemq/trunk.Thanks for your
information and being so helpful!
After reading GBeans for ActiveMQ and ServiceMix,I still adopted the same
way to start broker in ServiceMix's doStart() Method through BrokerService
and TransportConnector.The difference from last time is that the codes refer
to BrokerServiceGBeanImpl and TransportConnectorGBeanImpl's.

It is disappointed that broker doesn't start.I guess that JMS broker won't
work if through servicemix's gbean.Should I use a gbean reference? Is it
requried to deploy ActiveMQ 4.0 as a gbean firstly in Geronimo so that other
gbeans can get it?
           SP Liu
--
View this message in context: http://www.nabble.com/How+to+run+multi+jms-assembly+deployed+in+ServiceMix+within+Geronimo-t1601059.html#a4508253
Sent from the ServiceMix - User forum at Nabble.com.


Re: How to run multi jms-assembly deployed in ServiceMix within Geronimo

Posted by Bruce Snyder <br...@gmail.com>.
On 5/11/06, SP Liu <sp...@gmail.com> wrote:
>
> Thank Bruce for reply!
> Previously if I disabled Geronimo's ActiveMQ,JMS client will not connect
> 61616 port as if ServiceMix's JMS connect factory don't start at all within
> Geronimo.
> Lately I follow Guillaume's insturction by embedding a
> broker(tcp://localhost:61626) in servicemix.xml.Here I don't disable
> Geronimo's ActiveMQ,just start a broker on port 61626 in ServiceMix so thar
> it will not use Geronimo's ActiveMQ.
>
>   <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"
> singleton="true">
>     <property name="config" value="classpath:broker.xml"/>
>   </bean>
>
>         <sm:serviceunit id="jbi" depends-on="broker">
>                 <sm:activationSpecs>
>         ...
>         <bean id="jmsFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>                 <property name="connectionFactory">
>                 <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                         <property name="brokerURL" value="tcp://localhost:61626" />
>                 </bean>
>                 </property>
>         </bean>

Yes, that's good advice as the version of ActiveMQ in Geronimo 1.0 is
not new enough for ServiceMix 3.0. But Geronimo 1.2 will contain
ActiveMQ 4.0 so you'll be able to point to it when it comes out.

>    Someone argue that more things can integrated into Geronimo so that I
> have some interest in running ServiceMix on Geronimo, and this problem can't
> be solved from then on.In the future I will mostly run ServiceMix
> standalone.

Considering that ServiceMix is built specifically for integration, I
find this statemetn a bit odd. There are only so many ways to
integrate with Geronimo whereas ServiceMix offers an many, many more
methods of integration. In fact, some of us make the point that
integration with Geronimo outside of J2EE should occur via ServiceMix.

>    If I add a broker in ServiceMixGBean's doStart() Method,no error/stack
> trace was thrown.I found no listening in port 61626.
>
> // code
> public class ServiceMixGBean implements GBeanLifecycle, ServiceMixContainer
> {
>     ...
>     public void doStart() throws Exception {
>         ...
>         try{
>                 if(broker == null){
>                 broker = new BrokerService();
>                 broker.addConnector("tcp://localhost:61626");
>                 broker.start();
>                 }
>         }catch(Exception e){
>                 log.error("Cannot start broker", e);
>         }
>
>         try {
>             if (container == null) {
>                 container = createContainer();
>                 container.init();
>                 container.start();
>
>                 // Create a JMX Connector
>                 JMXServiceURL url = new
> JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + namingPort
>                         + "/jmxrmi");
>                 // Create and start the RMIConnectorServer
>                 MBeanServer server = container.getMBeanServer();
>                 connectorServer =
> JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
>                 connectorServer.start();
>
>                 //
>                 connectionFactory = new
> ActiveMQConnectionFactor("tcp://localhost:61626");
>             }
>         } finally {
>             Thread.currentThread().setContextClassLoader(old);
>         }
>     }
>
>  Do you give me some suggestion on this method?

Take a look at the GBeans for ActiveMQ and ServiceMIx that integrate
each project into Geronimo to get an idea of how this all takes place
there. I'd point to the Subversion repositories but they're still down
at the ASF due to a kernel panic. Just take a look at
http://activemq.org/Source and http://servicemix.org/Source for the
Subversion repositories. I'll try to remember to post a link when
Subversion is back up again.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache Geronimo - http://geronimo.apache.org/
Apache ActiveMQ - http://incubator.apache.org/activemq/
Apache ServiceMix - http://incubator.apache.org/servicemix/
Castor - http://castor.org/

Re: How to run multi jms-assembly deployed in ServiceMix within Geronimo

Posted by SP Liu <sp...@gmail.com>.
Thank Bruce for reply!
Previously if I disabled Geronimo's ActiveMQ,JMS client will not connect
61616 port as if ServiceMix's JMS connect factory don't start at all within
Geronimo.
Lately I follow Guillaume's insturction by embedding a
broker(tcp://localhost:61626) in servicemix.xml.Here I don't disable
Geronimo's ActiveMQ,just start a broker on port 61626 in ServiceMix so thar
it will not use Geronimo's ActiveMQ.  
  
  <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"
singleton="true">
    <property name="config" value="classpath:broker.xml"/>
  </bean>      
                     
	<sm:serviceunit id="jbi" depends-on="broker">
		<sm:activationSpecs> 
	...	
	<bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
	        <property name="connectionFactory">
		<bean class="org.apache.activemq.ActiveMQConnectionFactory">
			<property name="brokerURL" value="tcp://localhost:61626" />
		</bean>
	        </property>
	</bean>
	
   Someone argue that more things can integrated into Geronimo so that I
have some interest in running ServiceMix on Geronimo, and this problem can't
be solved from then on.In the future I will mostly run ServiceMix
standalone.
    
   If I add a broker in ServiceMixGBean's doStart() Method,no error/stack
trace was thrown.I found no listening in port 61626.

// code 
public class ServiceMixGBean implements GBeanLifecycle, ServiceMixContainer
{
    ...   
    public void doStart() throws Exception {
        ...
        try{
           	if(broker == null){    
	        broker = new BrokerService();
	        broker.addConnector("tcp://localhost:61626");
	        broker.start();              
        	}
        }catch(Exception e){
        	log.error("Cannot start broker", e);
        }          
        
        try {
            if (container == null) {
                container = createContainer();
                container.init();
                container.start();  
                
                // Create a JMX Connector
                JMXServiceURL url = new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + namingPort
                        + "/jmxrmi");
                // Create and start the RMIConnectorServer
                MBeanServer server = container.getMBeanServer();
                connectorServer =
JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
                connectorServer.start();
                
                //  
                connectionFactory = new
ActiveMQConnectionFactor("tcp://localhost:61626");                
            }
        } finally {
            Thread.currentThread().setContextClassLoader(old);
        }  
    }

 Do you give me some suggestion on this method?
						SP Liu

   
--
View this message in context: http://www.nabble.com/How-to-run-multi-jms-assembly-deployed-in-ServiceMix-within-Geronimo-t1601059.html#a4352797
Sent from the ServiceMix - User forum at Nabble.com.


Re: How to run multi jms-assembly deployed in ServiceMix within Geronimo

Posted by Bruce Snyder <br...@gmail.com>.
On 5/11/06, SP Liu <sp...@gmail.com> wrote:
>
> Hi Guillaume!
> It can be incompatble between Geronimo's ActiveMQ and ServiceMix's.so I
> followed your instruction that embedding a broker and creating an ActiveMQ
> connection factory in servicemix.xml file using spring.It seemed to work
> fine.
> Unfortunately,if i deployed two different jms's SA by this method,some
> errors occur in Geronimo as below:
>
> ...
> 21:09:22,984 INFO  [DefaultListableBeanFactory] Pre-instantiating singletons
> in factory
> [org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [org.apache.activemq.xbean.XBeanBrokerService]; root of
> BeanFactory hierarchy]
> 21:09:22,984 INFO  [BrokerService] ActiveMQ 4.0-RC2 JMS Message Broker
> (localhost) is starting
> 21:09:22,984 INFO  [BrokerService] For help or more information please see:
> http://incubator.apache.org/activemq/
> 21:09:23,000 ERROR [BrokerService] Failed to start ActiveMQ JMS Message
> Broker. Reason: javax.management.InstanceAlreadyExistsException:
> org.apache.activemq:BrokerName=localhost,Type=Broker
> javax.management.InstanceAlreadyExistsException:
> org.apache.activemq:BrokerName=localhost,Type=Broker
> ...

You'll need to disable one of the ActiveMQ instances. It looks like
the one started by Geronimo (ActiveMQ 3.x) is conflicting with the one
started by ServiceMix (ActiveMQ 4.x). Is there a particular reason
that you're trying to run ServiceMix on Geronimo? The reason I ask is
because running ServiceMix standalone may be suitable.

> The similar problem occur when running two different jms's example in SM's
> standalone mode as below:
>
> ...
>  Loading Apache ServiceMix from file: servicemix.xml
> WARN - ManagementContext$1.run(86) | Failed to start jmx connector: Cannot
> bind
> to URL [rmi://localhost:1099/jmxrmi]:
> javax.naming.NameAlreadyBoundException: jm
> xrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]
> ERROR - BrokerService.start(370) | Failed to start ActiveMQ JMS Message
> Broker.
> Reason: java.net.BindException: Address already in use: JVM_Bind
> java.net.BindException: Address already in use: JVM_Bind
> ...
>

You'll need to tell the each RMI registry instance to run on it's own
port. Below is a portion of the ws-notification configuration from the
examples included with ServiceMix (I am unable to offer the URL as the
Subversion repo is still down):

<sm:container id="jbi"
                name="wsn1"
                embedded="true"
                MBeanServer="#mbeanServer">
  <sm:flow>
    <bean class="org.apache.servicemix.jbi.nmr.flow.jms.JMSFlow">
      <property name="connectionFactory" ref="connectionFactory" />
    </bean>
  </sm:flow>
...
  </sm:container>

  <!-- JMX server and connector -->
  <bean id="mbeanServer"
class="org.springframework.jmx.support.MBeanServerFactoryBean"/>

  <bean id="registry" class="mx4j.tools.naming.NamingService"
init-method="start">
    <!-- tell each RMI registry to run on it's own port! -->
    <property name="port" value="1092"/>
  </bean>

  <bean id="serverConnector"
class="org.springframework.jmx.support.ConnectorServerFactoryBean"
depends-on="registry">
    <property name="objectName" value="connector:name=rmi"/>
    <property name="serviceUrl"
value="service:jmx:rmi:///jndi/rmi://localhost:1092/jmxrmi"/>
    <property name="threaded" value="true"/>
    <property name="daemon" value="true"/>
  </bean>

  <bean id="connectionFactory"
        class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL"
value="peer://localhost/wsnbroker2?broker.persistent=false" />
  </bean>

The configuration above tells the RMI registry to run on it's own port
and since the JMS flow is specificed it starts a broker instance and
sets up a ActiveMQConnectionFactory using the peer protocol to point
to this broker instance. Other ServiceMix instances use this same
broker URL and protocol.

> I know that both of above are caused because we start a broker for each by
> embedding activemq.xml.
> then I try to add a shared broker to solve these by ServiceMixGBean's
> doStart() Method,but failed to start broker by gbean.

What's error/stack trace was thrown when this happened?

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache Geronimo - http://geronimo.apache.org/
Apache ActiveMQ - http://incubator.apache.org/activemq/
Apache ServiceMix - http://incubator.apache.org/servicemix/
Castor - http://castor.org/