mirror of https://github.com/apache/activemq.git
added an example of running an embedded broker in Java code
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@366477 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6285f96b15
commit
be19f9aabd
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
ant consumer creates a consumer which waits until a specific number of messages have been received
|
ant consumer creates a consumer which waits until a specific number of messages have been received
|
||||||
ant producer creates a producer publishing a number of messages
|
ant producer creates a producer publishing a number of messages
|
||||||
|
ant embedBroker runs an embedded broker inside Java code
|
||||||
|
|
||||||
ant war creates a WAR deployment unit of the ActiveMQ Broker
|
ant war creates a WAR deployment unit of the ActiveMQ Broker
|
||||||
</echo>
|
</echo>
|
||||||
|
@ -126,8 +127,7 @@
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
<!-- Create the war file -->
|
<!-- Create the war file -->
|
||||||
<jar jarfile="${app.dist.dir}/${app.name}.war"
|
<jar jarfile="${app.dist.dir}/${app.name}.war" basedir="${app.base.dir}" />
|
||||||
basedir="${app.base.dir}"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="consumer" depends="compile" description="Runs a simple consumer">
|
<target name="consumer" depends="compile" description="Runs a simple consumer">
|
||||||
|
@ -166,4 +166,13 @@
|
||||||
</java>
|
</java>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="embedBroker" depends="compile" description="Runs a simple producer">
|
||||||
|
|
||||||
|
<echo>Running an embedded broker example</echo>
|
||||||
|
<java classname="EmbeddedBroker" fork="yes" maxmemory="100M">
|
||||||
|
<classpath refid="javac.classpath" />
|
||||||
|
<jvmarg value="-server" />
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This example demonstrates how to run an embedded broker inside your Java code
|
||||||
|
*
|
||||||
|
* @version $Revision$
|
||||||
|
*/
|
||||||
|
public class EmbeddedBroker {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
BrokerService broker = new BrokerService();
|
||||||
|
broker.setUseJmx(true);
|
||||||
|
broker.addConnector("tcp://localhost:61616");
|
||||||
|
broker.start();
|
||||||
|
|
||||||
|
// now lets wait forever to avoid the JVM terminating immediately
|
||||||
|
Object lock = new Object();
|
||||||
|
synchronized (lock) {
|
||||||
|
lock.wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue