Discussion:
Create a broker with vm and tcp transport connectors
Kuppe
2006-05-03 12:44:23 UTC
Permalink
Can you please demonstrate how i can create a BrokerService that allows me to
connect using the VM connector for local connections and the TCP connector
for remote connections? I am interested specifically in how to create the
BrokerService in java. Is it possible to separate the broker creation from
the client that uses the broker even if they exist in the same virtual
machine - meaning, besides the urlString allow the client to be ignorant of
the fact that the broker is local or remote?
--
View this message in context: http://www.nabble.com/Create-a-broker-with-vm-and-tcp-transport-connectors-t1549616.html#a4209405
Sent from the ActiveMQ - User forum at Nabble.com.
James Strachan
2006-05-03 13:19:48 UTC
Permalink
Post by Kuppe
Can you please demonstrate how i can create a BrokerService that allows me to
connect using the VM connector for local connections and the TCP connector
for remote connections? I am interested specifically in how to create the
BrokerService in java.
Details here...
http://activemq.org/How+do+I+embed+a+Broker+inside+a+Connection
Post by Kuppe
Is it possible to separate the broker creation from
the client that uses the broker even if they exist in the same virtual
machine - meaning, besides the urlString allow the client to be ignorant of
the fact that the broker is local or remote?
Yes - the ActiveMQConnectionFactory just uses a URL to connect to.
Though clearly "vm://localhost" only works if the broker is actually
in the same JVM.

--

James
-------
http://radio.weblogs.com/0112098/
Kuppe
2006-05-04 09:18:34 UTC
Permalink
Thanks for the link james, but i had already reviewed this and many other
pages on your site, and did not manage to find a clear description as to how
this is done. Perhaps (obviously) i am missing something...

Ideally, i am interested in using the ActiveMQConnectionFactory to manage
the creation of the broker and all connections to it - I am assuming this is
in fact the purpose of this Administered factory. So i have a singleton that
is used to create the ActiveMQConnectionFactory and for globally getting
connections for clients.

In the broker VM i create the ActiveMQConnectionFactory with the following
url :
vm:(broker:(tcp://localhost:61616)?persistent=false&useJmx=false)?marshal=false.
I then create a client with a connection from the ActiveMQConnectionFactory.

In the remote VM i create the ActiveMQConnectionFactory with the following
url :
tcp://localhost:61616. I then create a client with a connection from the
ActiveMQConnectionFactory.

Can you firstly confirm that this is in fact the correct approach and that
my understanding so far is correct?

Thanks

--
View this message in context: http://www.nabble.com/Create-a-broker-with-vm-and-tcp-transport-connectors-t1549616.html#a4225664
Sent from the ActiveMQ - User forum at Nabble.com.
Hiram Chirino
2006-05-04 14:10:10 UTC
Permalink
that should work.
Post by Kuppe
Thanks for the link james, but i had already reviewed this and many other
pages on your site, and did not manage to find a clear description as to how
this is done. Perhaps (obviously) i am missing something...
Ideally, i am interested in using the ActiveMQConnectionFactory to manage
the creation of the broker and all connections to it - I am assuming this is
in fact the purpose of this Administered factory. So i have a singleton that
is used to create the ActiveMQConnectionFactory and for globally getting
connections for clients.
In the broker VM i create the ActiveMQConnectionFactory with the following
vm:(broker:(tcp://localhost:61616)?persistent=false&useJmx=false)?marshal=false.
I then create a client with a connection from the ActiveMQConnectionFactory.
In the remote VM i create the ActiveMQConnectionFactory with the following
tcp://localhost:61616. I then create a client with a connection from the
ActiveMQConnectionFactory.
Can you firstly confirm that this is in fact the correct approach and that
my understanding so far is correct?
Thanks
--
View this message in context: http://www.nabble.com/Create-a-broker-with-vm-and-tcp-transport-connectors-t1549616.html#a4225664
Sent from the ActiveMQ - User forum at Nabble.com.
--
Regards,
Hiram
Kuppe
2006-05-05 05:38:22 UTC
Permalink
Ok, i now have a use case working with the example below. Thanks.

However when using the ActiveMQConnectionFactory to create the broker, how
do I explicitly start or stop the BrokerService, or even better get a
reference to the running BrokerService?
--
View this message in context: http://www.nabble.com/Create-a-broker-with-vm-and-tcp-transport-connectors-t1549616.html#a4241810
Sent from the ActiveMQ - User forum at Nabble.com.
James Strachan
2006-05-05 06:06:32 UTC
Permalink
Post by Kuppe
Ok, i now have a use case working with the example below. Thanks.
However when using the ActiveMQConnectionFactory to create the broker, how
do I explicitly start or stop the BrokerService, or even better get a
reference to the running BrokerService?
Why not just create a BrokerService explicitly using the Java APIs
http://activemq.org/How+do+I+embed+a+Broker+inside+a+Connection

then you can do whatever you like with it; or use Spring to dependency
inject it into your code.

--

James
-------
http://radio.weblogs.com/0112098/
Kuppe
2006-05-05 07:52:12 UTC
Permalink
Ok, i now programatically create the BrokerService. Can you explain to me how
i can set the vm transport options from the BrokerService?

Additionallly is there a way to programatically create the BrokerService
whilst using an xml file to configure the broker?

Thanks for the support!!
--
View this message in context: http://www.nabble.com/Create-a-broker-with-vm-and-tcp-transport-connectors-t1549616.html#a4243093
Sent from the ActiveMQ - User forum at Nabble.com.
James Strachan
2006-05-05 08:18:39 UTC
Permalink
Post by Kuppe
Ok, i now programatically create the BrokerService. Can you explain to me how
i can set the vm transport options from the BrokerService?
See
http://activemq.codehaus.org/maven/apidocs/org/apache/activemq/broker/BrokerService.html#addConnector(java.lang.String)

that string is then using the URI syntax documented here
http://activemq.org/Configuring+Transports
Post by Kuppe
Additionallly is there a way to programatically create the BrokerService
whilst using an xml file to configure the broker?
Its one or the other. The XML file creates a BrokerService - or you
can create it with Java.

--

James
-------
http://radio.weblogs.com/0112098/
Javier Leyba
2006-05-05 08:25:14 UTC
Permalink
Post by James Strachan
Post by Kuppe
Additionallly is there a way to programatically create the BrokerService
whilst using an xml file to configure the broker?
Its one or the other. The XML file creates a BrokerService - or you
can create it with Java.
Is this true ?

I'm creating a service with java that reads its config from a xml file !!!

----------
URI brokerURI = new URI("xbean:" +
System.getProperty("jboss.server.config.url") + "activemq_slave.xml");
serviceSlave = BrokerFactory.createBroker(brokerURI);
if (serviceSlave != null) {
serviceSlave.start();
}
------------


Am I wrong ?




--
Javier Leyba
Barcelona - Spain
http://blog.leyba.com.ar
James Strachan
2006-05-05 08:42:00 UTC
Permalink
Post by Javier Leyba
Post by James Strachan
Post by Kuppe
Additionallly is there a way to programatically create the BrokerService
whilst using an xml file to configure the broker?
Its one or the other. The XML file creates a BrokerService - or you
can create it with Java.
Is this true ?
I'm creating a service with java that reads its config from a xml file !!!
----------
URI brokerURI = new URI("xbean:" +
System.getProperty("jboss.server.config.url") + "activemq_slave.xml");
serviceSlave = BrokerFactory.createBroker(brokerURI);
if (serviceSlave != null) {
serviceSlave.start();
}
------------
Am I wrong ?
So you can instantiate the BrokerService and configure it explicitly
in Java code - or you can create it via the XML configuration file
using the above method or the spring factory bean. But still its one
or the other - your Java code instantiates and configures the
BrokerService - or the XML does it for you.

--

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

Loading...