Author: buildbot
Date: Fri Jun 12 16:20:58 2015
New Revision: 954603
Log:
Production update by buildbot for activemq
Modified:
websites/production/activemq/content/cache/main.pageCache
websites/production/activemq/content/how-do-i-embed-a-broker-inside-a-connection.html
Modified: websites/production/activemq/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified:
websites/production/activemq/content/how-do-i-embed-a-broker-inside-a-connection.html
==============================================================================
---
websites/production/activemq/content/how-do-i-embed-a-broker-inside-a-connection.html
(original)
+++
websites/production/activemq/content/how-do-i-embed-a-broker-inside-a-connection.html
Fri Jun 12 16:20:58 2015
@@ -81,56 +81,31 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><p>In many messaging topologies there
are JMS Brokers (server side) and a JMS client side. Often it makes sense to
deploy a broker within your JVM. This allows you to optimise away a network
hop; making the networking of JMS as efficient as pure RMI, but with all the
usual JMS features of location independence, reliability, load balancing
etc.</p>
-
-<p>There are various ways to embed a broker in ActiveMQ depending on if you
are using Java, Spring, XBean or using the ActiveMQConnectionFactory .</p>
-
-<h3 id="HowdoIembedaBrokerinsideaConnection-UsingexplicitJavacode">Using
explicit Java code</h3>
-
-<p>The following Java code will create an embedded broker</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-BrokerService broker = new BrokerService();
+<div class="wiki-content maincontent"><p>In many messaging topologies there
are JMS Brokers (server side) and a JMS client side. Often it makes sense to
deploy a broker within your JVM. This allows you to optimise away a network
hop; making the networking of JMS as efficient as pure RMI, but with all the
usual JMS features of location independence, reliability, load balancing
etc.</p><p>There are various ways to embed a broker in ActiveMQ depending on if
you are using Java, Spring, XBean or using the ActiveMQConnectionFactory
.</p><h3 id="HowdoIembedaBrokerinsideaConnection-UsingexplicitJavacode">Using
explicit Java code</h3><p>The following Java code will create an embedded
broker</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[BrokerService broker = new BrokerService();
// configure the broker
broker.addConnector("tcp://localhost:61616");
broker.start();
]]></script>
-</div></div>
-
-<p>If you want to lazily bind the transport connector as part of start(),
useful when start() will block pending a store lock (as in a slave start), you
can use the following code</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-BrokerService broker = new BrokerService();
+</div></div><p>If you want to lazily bind the transport connector as part of
start(), useful when start() will block pending a store lock (as in a slave
start), you can use the following code</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[BrokerService broker = new BrokerService();
TransportConnector connector = new TransportConnector();
connector.setUri(new URI("tcp://localhost:61616"));
broker.addConnector(connector);
broker.start();
]]></script>
-</div></div>
-
-<p>In the same JVM clients can then use the <a shape="rect"
href="vm-transport-reference.html">vm:// transport</a> to connect to the
embedded broker - whilst external clients can use the <a shape="rect"
href="tcp-transport-reference.html">tcp:// protocol</a></p>
-
-<p>If you have more than one embedded broker, ensure that you give them a
unique name and - e.g.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-BrokerService broker = new BrokerService();
+</div></div><p>In the same JVM clients can then use the <a shape="rect"
href="vm-transport-reference.html">vm:// transport</a> to connect to the
embedded broker - whilst external clients can use the <a shape="rect"
href="tcp-transport-reference.html">tcp:// protocol</a></p><p>If you have more
than one embedded broker, ensure that you give them a unique name and -
e.g.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[BrokerService broker = new BrokerService();
// configure the broker
broker.setBrokerName("fred");
broker.addConnector("tcp://localhost:61616");
broker.start();
]]></script>
-</div></div>
-
-<p>Then if you want to connect to the broker named 'fred' from within the same
JVM, you can by using the uri <strong>vm://fred</strong></p>
-
-<p>It is possible to fully configure a broker through application code e.g.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-BrokerService broker = new BrokerService();
+</div></div><p>Then if you want to connect to the broker named 'fred' from
within the same JVM, you can by using the uri
<strong>vm://fred</strong></p><p>It is possible to fully configure a broker
through application code e.g.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[BrokerService broker = new BrokerService();
broker.setBrokerName("fred");
broker.setUseShutdownHook(false);
//Add plugin
@@ -141,59 +116,23 @@ connector.setDuplex(true);
broker.addConnector("tcp://localhost:61616");
broker.start();
]]></script>
-</div></div>
-
- <div class="aui-message warning shadowed information-macro">
+</div></div> <div class="aui-message warning shadowed information-macro">
<span class="aui-icon icon-warning">Icon</span>
<div class="message-content">
<p>Please note that you should add plugins before
connectors or they will not be initialized</p>
</div>
</div>
-
-
-<p>For more details on the available properties you can specify, see the <a
shape="rect" class="external-link"
href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/broker/BrokerService.html">BrokerService
javadoc</a></p>
-
-<h3 id="HowdoIembedaBrokerinsideaConnection-UsingtheBrokerFactory">Using the
BrokerFactory</h3>
-
-<p>There is a helper class called <a shape="rect" class="external-link"
href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/broker/BrokerFactory.html">BrokerFactory</a>
which can be used to create a broker via URI for configuration.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-BrokerService broker = BrokerFactory.createBroker(new URI(someURI));
+<p>For more details on the available properties you can specify, see the <a
shape="rect" class="external-link"
href="http://activemq.apache.org/maven/5.11.0/apidocs/org/apache/activemq/broker/BrokerService.html">BrokerService
javadoc</a></p><h3
id="HowdoIembedaBrokerinsideaConnection-UsingtheBrokerFactory">Using the
BrokerFactory</h3><p>There is a helper class called <a shape="rect"
class="external-link"
href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/broker/BrokerFactory.html">BrokerFactory</a>
which can be used to create a broker via URI for configuration.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[BrokerService broker =
BrokerFactory.createBroker(new URI(someURI));
]]></script>
-</div></div>
-
-<p>The available values of the URI are</p>
-
-<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th
colspan="1" rowspan="1" class="confluenceTh"><p>URI scheme</p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p>Example </p></th><th
colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>xbean: </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> xbean:activemq.xml </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Searches the classpath (and file system)
for an XML document with the given URI (activemq.xml in this case) which will
then be used as the <a shape="rect" href="xml-configuration.html">Xml
Configuration</a></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>broker: </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> broker:tcp://localhost:61616 </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Uses the <a shape="rect"
href="broker-configuration-uri.html">Broker Co
nfiguration URI</a> to confgure the broker </p></td></tr></tbody></table></div>
-
-
-
-
-
-<h3 id="HowdoIembedaBrokerinsideaConnection-UsingSpring">Using Spring</h3>
-
-<p>There is a factory bean that can refer to an external ActiveMQ XML
configuration file</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<bean id="broker"
class="org.apache.activemq.xbean.BrokerFactoryBean">
+</div></div><p>The available values of the URI are</p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>URI scheme</p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p>Example</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>xbean:</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>xbean:activemq.xml</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Searches the classpath (and file system) for an XML
document with the given URI (activemq.xml in this case) which will then be used
as the <a shape="rect" href="xml-configuration.html">Xml
Configuration</a></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>broker:</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>broker:tcp://localhost:61616</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Uses the <a shape="rect" h
ref="broker-configuration-uri.html">Broker Configuration URI</a> to confgure
the broker</p></td></tr></tbody></table></div><h3
id="HowdoIembedaBrokerinsideaConnection-UsingSpring">Using Spring</h3><p>There
is a factory bean that can refer to an external ActiveMQ XML configuration
file</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[<bean id="broker"
class="org.apache.activemq.xbean.BrokerFactoryBean">
<property name="config"
value="classpath:org/apache/activemq/xbean/activemq.xml" />
<property name="start" value="true" />
</bean>
]]></script>
-</div></div>
-
-<p>In this case the usual Spring
'classpath:org/apache/activemq/xbean/activemq.xml' resource mechanism is being
used so that the activemq.xml file would be found on the classpath by looking
inside all the directories on the classpath then looking for
'org/apache/activemq/xbean/activemq.xml'. You can of course change this to any
value you like. e.g. use classpath:activemq.xml if you just want to drop it in
a directory that is in the classpath; like WEB-INF/classes in a web
application.</p>
-
-<p>If you wish you can use a URL instead using the <strong>file:* or
*http:</strong> prefixes. For more details see how <a shape="rect"
class="external-link"
href="http://static.springframework.org/spring/docs/1.2.x/reference/beans.html#context-functionality-resources"
rel="nofollow">Spring deals with resources</a></p>
-
-<h3 id="HowdoIembedaBrokerinsideaConnection-UsingXBean">Using XBean</h3>
-
-<p>If you are already using <a shape="rect" class="external-link"
href="http://geronimo.apache.org/xbean/">XBean</a> then you can just mix and
match your Spring/XBean <a shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/xbean/activemq.xml">XML
configuration</a> with ActiveMQ's configuration.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<beans
+</div></div><p>In this case the usual Spring
'classpath:org/apache/activemq/xbean/activemq.xml' resource mechanism is being
used so that the activemq.xml file would be found on the classpath by looking
inside all the directories on the classpath then looking for
'org/apache/activemq/xbean/activemq.xml'. You can of course change this to any
value you like. e.g. use classpath:activemq.xml if you just want to drop it in
a directory that is in the classpath; like WEB-INF/classes in a web
application.</p><p>If you wish you can use a URL instead using the
<strong>file:* or *http:</strong> prefixes. For more details see how <a
shape="rect" class="external-link"
href="http://static.springframework.org/spring/docs/1.2.x/reference/beans.html#context-functionality-resources"
rel="nofollow">Spring deals with resources</a></p><h3
id="HowdoIembedaBrokerinsideaConnection-UsingXBean">Using XBean</h3><p>If you
are already using <a shape="rect" class="external-link"
href="http://geronimo.apache.org/x
bean/">XBean</a> then you can just mix and match your Spring/XBean <a
shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/xbean/activemq.xml">XML
configuration</a> with ActiveMQ's configuration.</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -215,15 +154,8 @@ BrokerService broker = BrokerFactory.cre
</broker>
</beans>
]]></script>
-</div></div>
-
-<h3 id="HowdoIembedaBrokerinsideaConnection-UsingSpring2.0">Using Spring
2.0</h3>
-
-<p>If you are using Spring 2.0 and ActiveMQ 4.1 or later (and xbean-spring 2.5
or later) you can embed the ActiveMQ broker XML inside any regular Spring.xml
file without requiring the above factory bean. e.g. here is an <a shape="rect"
class="external-link"
href="http://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/test/resources/spring-embedded-xbean.xml">example</a>
of a regular Spring XML file in Spring 2.0 which also configures a broker.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<beans
+</div></div><h3 id="HowdoIembedaBrokerinsideaConnection-UsingSpring2.0">Using
Spring 2.0</h3><p>If you are using Spring 2.0 and ActiveMQ 4.1 or later (and
xbean-spring 2.5 or later) you can embed the ActiveMQ broker XML inside any
regular Spring.xml file without requiring the above factory bean. e.g. here is
an <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/test/resources/spring-embedded-xbean.xml">example</a>
of a regular Spring XML file in Spring 2.0 which also configures a
broker.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -283,25 +215,11 @@ BrokerService broker = BrokerFactory.cre
</beans>
]]></script>
-</div></div>
-
-<h3
id="HowdoIembedaBrokerinsideaConnection-UsingActiveMQConnectionFactory">Using
ActiveMQConnectionFactory </h3>
-
-<p>An embedded broker can also be created using an ActiveMQConnectionFactory
and using a vm connector as a uri. e.g. </p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+</div></div><h3
id="HowdoIembedaBrokerinsideaConnection-UsingActiveMQConnectionFactory">Using
ActiveMQConnectionFactory</h3><p>An embedded broker can also be created using
an ActiveMQConnectionFactory and using a vm connector as a uri. e.g.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
]]></script>
-</div></div>
-
-<p>Use the query parameters "broker.<property>" to configure the broker,
where <property> matches the bean properties on the BrokerService.</p>
-
-<p>The broker will be created upon creation of the first connection. </p>
-
-<p>You can turn off auto creation by setting the create property on the VM
Transport to false:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory("vm://localhost?create=false");
+</div></div><p>Use the query parameters "broker.<property>" to configure
the broker, where <property> matches the bean properties on the
BrokerService.</p><p>The broker will be created upon creation of the first
connection.</p><p>You can turn off auto creation by setting the create property
on the VM Transport to false:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory("vm://localhost?create=false");
]]></script>
</div></div></div>
</td>