Version 5.5
Copyright © 2012-2013 Red Hat, Inc. and/or its affiliates.
Updated: 27 Mar 2014
Table of Contents
List of Figures
This tutorial walks you through the process of creating a new Fuse Message Broker instance using the activemq-admin command.
In this tutorial you will:
Create a new Fuse Message Broker configuration file.
Edit the default configuration for you broker.
Create a new Fuse Message Broker instance using the configuration file.
This tutorial requires that you have Fuse Message Broker installed into a folder that you have read/write access.
To create a new broker instance:
Copy the default Fuse Message Broker configuration file from
to
InstallDir/conf/activemq.xml.InstallDir/conf/activemq-tutorial.xml
Open
in
an XML editor.InstallDir/conf/activemq-tutorial.xml
Locate the following line:
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
Change the line as follows:
<transportConnector name="openwire" uri="tcp://0.0.0.0:61600"/>
Save the file.
Open a command prompt at
.InstallDir
Enter the following command:
bin\activemq-admin.bat create --amqconf conf\activemq-tutorial.xml c:\tutorialbin/activemq-admin create --amqconf conf/activemq-tutorial.xml ~/tutorialThe activemq-admin create command creates a new instance of Fuse Message Broker in the specified location. To do this it creates a new directory containing the following:
bin—scripts to start the broker
tutorial.bat
tutorial
conf—configuration files for the broker
activemq.xml
broker.ts
credentials.properties
jetty.xml
broker.ks
camel.xml
jetty-realm.properties
log4j.properties
The --amqconf parameter specifies the
Fuse Message Broker configuration file to use for the new broker instance.
In this tutorial you will launch a Fuse Message Broker instance from the command line.
In this tutorial you will:
add the Fuse Message Broker command line tools to your system path
locate a Fuse Message Broker configuration file
start a Fuse Message Broker instance using the configuration file
This tutorial requires that you have Fuse Message Broker installed.
While you can use the default configuration for this tutorial it is recommended that you use an instance like the one created in Creating a Broker Instance.
To start a broker on Windows:
Locate the root folder for the broker instance you wish to start.
To use the default installation, the root folder is
.InstallDir
To use the instance created in
Creating a Broker Instance, the root folder is
c:\tutorial.
Open a command prompt at the instance's root folder.
Add the Fuse Message Broker command line tools your path by entering
c:\set PATH=%PATH%;InstallDir\bin
Locate the configuration file for the broker instance.
The default location for the configuration file is
conf\activemq.xml.
Start the broker instance by entering
c:\activemq xbean:conf/activemq.xml
This assumes the default location of the configuration file.
A number of messages, similar to Figure 2.1, will appear on the console.
Figure 2.1. Broker Output
Java Runtime: Sun Microsystems Inc. 1.6.0_16 C:\Program Files\Java\jdk1.6.0_16\jre
Heap sizes: current=260160k free=258524k max=1040512k
JVM args: -Dcom.sun.management.jmxremote -Xms256M -Xmx1G
-Dorg.apache.activemq.UseDedicatedTaskRunner=true
-Djava.util.logging.config.file=logging.properties
-Dactivemq.classpath=c:\apache-activemq-5.5.0-fuse-00-27\bin\../conf;c:\apache-activemq-5.5.0-fuse-00-27\bin\../conf;
-Dactivemq.home=c:\apache-activemq-5.5.0-fuse-00-27\bin\..
-Dactivemq.base=c:\apache-activemq-5.5.0-fuse-00-27\bin\..
ACTIVEMQ_HOME: c:\apache-activemq-5.5.0-fuse-00-27\bin\..
ACTIVEMQ_BASE: c:\apache-activemq-5.5.0-fuse-00-27\bin\..
Loading message broker from: xbean:conf/activemq.xml
INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@5a67c9: startup date
[Mon Sep 12 17:07:04 EDT 2011]; root of context hierarchy
INFO | PListStore:[c:\apache-activemq-5.5.0-fuse-00-27\bin\..\data\tutorial\tmp_storage ] started
INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[c:\apache-activemq-5.5.0-fuse-00-27\bin\..\data\kahadb]
INFO | ActiveMQ 5.5.0-fuse-00-27 JMS Message Broker (tutorial) is starting
INFO | For help or more information please see: http://activemq.apache.org/
INFO | Listening for connections at: tcp://nbbedemjohnso1:61616
INFO | Connector openwire Started
INFO | ActiveMQ JMS Message Broker (tutorial, ID:nbbedemjohnso1-3192-1315861625337-0:1) started
INFO | jetty-7.1.6.v20100715
INFO | ActiveMQ WebConsole initialized.
INFO | Initializing Spring FrameworkServlet 'dispatcher'
INFO | ActiveMQ Console at http://0.0.0.0:8161/admin
INFO | Initializing Spring root WebApplicationContext
INFO | OSGi environment not detected.
INFO | Apache Camel 2.7.1-fuse-00-27 (CamelContext: camel) is starting
INFO | JMX enabled. Using ManagedManagementStrategy.
INFO | Found 5 packages with 16 @Converter classes to load
INFO | Loaded 152 type converters in 0.563 seconds
WARN | Broker localhost not started so using tutorial instead
INFO | Connector vm://localhost Started
INFO | Route: route1 started and consuming from: Endpoint[activemq://example.A]
INFO | Total 1 routes, of which 1 is started.
INFO | Apache Camel 2.7.1-fuse-00-27 (CamelContext: camel) started in 1.000 seconds
INFO | Camel Console at http://0.0.0.0:8161/camel
INFO | ActiveMQ Web Demos at http://0.0.0.0:8161/demo
INFO | RESTful file access application at http://0.0.0.0:8161/fileserver
INFO | FUSE Web Console at http://0.0.0.0:8161/console
INFO | Started SelectChannelConnector@0.0.0.0:8161To start a broker:
Locate the root folder for the broker instance you wish to start.
To use the default installation, the root folder is
.InstallDir
To use the instance created in
Creating a Broker Instance, the root folder is
~/tutorial.
Open a command prompt at the instance's root folder.
Add the Fuse Message Broker command line tools your path by entering
%set PATH=$PATH;InstallDir/bin
Locate the configuration file for the broker instance.
The default location for the configuration file is
conf/activemq.xml.
Start the broker instance by entering
%activemq start xbean:conf/activemq.xml
This assumes the default location of the configuration file.
The message Running ActiveMQ Broker... will appear and
the command will return without error. The broker is now running as a daemon process.
To start the broker with a command console use activemq console in place of activemq start.
In this tutorial you will install a Fuse Message Broker instance as a Windows service.
In this tutorial you will:
configure the Java Wrapper Service for your system
install a broker instance as a Windows service
configure the broker's service to start up automatically
This tutorial requires that you have Fuse Message Broker installed on a Windows computer to which you have administrative privileges.
To install Fuse Message Broker as a Windows service:
Open
in a text editor.InstallDir\bin\win32\wrapper.conf
The wrapper.conf file configures the Java Wrapper Service
that Fuse Message Broker uses to create a Windows service.
Change the line containing set.default.ACTIVEMQ_HOME=../.. to
set.default.ACTIVEMQ_HOME=InstallDirThis tells the wrapper where the Fuse Message Broker installation is located so it can find the required libraries.
Change the line containing set.default.ACTIVEMQ_BASE=../.. to
set.default.ACTIVEMQ_BASE=InstallDirThis tells the wrapper where to find the configuration and data files for the broker instance being used for the service.
Save the file.
Open a command prompt.
Change to the
directory.InstallDir\bin\win32
Install the broker as a Windows service by executing the InstallService command.
You will see a message similar to:
C:\fmq\bin\win32>InstallServicewrapper | ActiveMQ installed.
From the Windows menu select |||.
The Services window opens.
Double click ActiveMQ from the list of services.
The ActiveMQ Properties window opens.
Specify that the service will start up when you login by selecting Automatic from the Startup Type drop-down list.
Click .
Open the context menu for the ActiveMQ entry in the service list.
Select to start the broker.
You can stop the broker service by selecting in the Service window's context menu.
To uninstall the broker as a Windows service use the
UninstallService in the
directory.InstallDir\bin\win32
For details see:
| Installing Fuse Message Broker as a Windows Service in Managing and Monitoring a Broker |
This tutorial demostrates how to shutdown a running message broker.
In this tutorial you will:
add the Fuse Message Broker command line tools to your system path
use a Fuse Message Broker configuration file to determine the broker's name
stop a Fuse Message Broker instance using it's name
To complete this tutorial you will need to have a broker instance running
in the default JMX context
(service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi).
While you can use the default configuration for this tutorial it is recommended that you use an instance like the one created in Creating a Broker Instance.
To shutdown a broker on Windows:
Locate the root folder for the broker instance you wish to start.
To use the default installation, the root folder is
.InstallDir
To use the instance created in
Creating a Broker Instance, the root folder is
c:\tutorial.
Open a command prompt at the instance's root folder.
Add the Fuse Message Broker command line tools your path by entering
c:\set PATH=%PATH%;InstallDir\bin
Open the configuration file for the broker instance.
The default location for the configuration file is
conf\activemq.xml.
Locate the broker element.
Write down the value of the brokerName attribute.
This is the name of the broker and is used to by the administration tool to determine which broker to shutdown.
The value for the broker created in
Creating a Broker Instance is
tutorial.
Shutdown the broker instance by entering
c:\activemq-admin stopbrokerName
A number of messages, similar to Figure 4.1, will appear on the console.
Figure 4.1. Broker Shutdown
Java Runtime: Sun Microsystems Inc. 1.6.0_16
C:\Program Files\Java\jdk1.6.0_16\jre
Heap sizes: current=5056k free=4761k max=65088k
JVM args: -Dactivemq.classpath=C:\apache-activemq-5.5.0-fuse-00-27\bin\../conf;
-Dactivemq.home=C:\apache-activemq-5.5.0-fuse-00-27\bin\..
-Dactivemq.base=C:\apache-activemq-5.5.0-fuse-00-27\bin\..
ACTIVEMQ_HOME: C:\apache-activemq-5.5.0-fuse-00-27\bin\..
ACTIVEMQ_BASE: C:\apache-activemq-5.5.0-fuse-00-27\bin\..
Connecting to pid: 4076
Stopping broker: tutorialTo start a broker:
Locate the root folder for the broker instance you wish to start.
To use the default installation, the root folder is
.InstallDir
To use the instance created in
Creating a Broker Instance, the root folder is
~/tutorial.
Open a command prompt at the instance's root folder.
Add the Fuse Message Broker command line tools your path by entering
%set PATH=$PATH;InstallDir/bin
Open the configuration file for the broker instance.
The default location for the configuration file is
conf/activemq.xml.
Locate the broker element.
Write down the value of the brokerName attribute.
This is the name of the broker and is used to by the administration tool to determine which broker to shutdown.
The value for the broker created in
Creating a Broker Instance is
tutorial.
Shutdown the broker by entering
%activemq stopbrokerName