activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r954603 - in /websites/production/activemq/content: cache/main.pageCache how-do-i-embed-a-broker-inside-a-connection.html
Date Fri, 12 Jun 2015 16:20:59 GMT
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(&quot;tcp://localhost:61616&quot;);
 
 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(&quot;tcp://localhost:61616&quot;));
 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(&quot;fred&quot;);
 broker.addConnector(&quot;tcp://localhost:61616&quot;);
 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(&quot;fred&quot;);
 broker.setUseShutdownHook(false);
 //Add plugin
@@ -141,59 +116,23 @@ connector.setDuplex(true);
 broker.addConnector(&quot;tcp://localhost:61616&quot;);
 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[
-&lt;bean id=&quot;broker&quot; class=&quot;org.apache.activemq.xbean.BrokerFactoryBean&quot;&gt;
+</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[&lt;bean
id=&quot;broker&quot; class=&quot;org.apache.activemq.xbean.BrokerFactoryBean&quot;&gt;
     &lt;property name=&quot;config&quot; value=&quot;classpath:org/apache/activemq/xbean/activemq.xml&quot;
/&gt;
     &lt;property name=&quot;start&quot; value=&quot;true&quot; /&gt;
   &lt;/bean&gt;
 ]]></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[
-&lt;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[&lt;beans

   xmlns=&quot;http://www.springframework.org/schema/beans&quot; 
   xmlns:amq=&quot;http://activemq.apache.org/schema/core&quot;
   xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
@@ -215,15 +154,8 @@ BrokerService broker = BrokerFactory.cre
   &lt;/broker&gt;
 &lt;/beans&gt;
 ]]></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[
-&lt;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[&lt;beans

   xmlns=&quot;http://www.springframework.org/schema/beans&quot; 
   xmlns:amq=&quot;http://activemq.apache.org/schema/core&quot;
   xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
@@ -283,25 +215,11 @@ BrokerService broker = BrokerFactory.cre
 
 &lt;/beans&gt;
 ]]></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(&quot;vm://localhost?broker.persistent=false&quot;);
+</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(&quot;vm://localhost?broker.persistent=false&quot;);
 ]]></script>
-</div></div>
-
-<p>Use the query parameters "broker.&lt;property&gt;" to configure the broker,
where &lt;property&gt; 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(&quot;vm://localhost?create=false&quot;);
+</div></div><p>Use the query parameters "broker.&lt;property&gt;"
to configure the broker, where &lt;property&gt; 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(&quot;vm://localhost?create=false&quot;);
 ]]></script>
 </div></div></div>
         </td>



Mime
View raw message