<?xml version="1.0"?>
<!--

 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you 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.

-->

<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Java-Broker-Getting-Started">
  <title>Getting Started</title>

  <section role="h2" xml:id="Java-Broker-Getting-Started-Introduction">
    <title>Introduction</title>
    <para>
      This section describes how to start and stop the Broker, and outlines the various command line options.
    </para>
    <para>
      For additional details about the broker configuration store and related command line arguments see
      <xref linkend="Java-Broker-Initial-Configuration"/>.
      The broker is fully configurable via its Web Management Console, for details of this see
      <xref linkend="Java-Broker-Management-Channel-Web-Console"/>.
    </para>
  </section>
  <section role="h2" xml:id="Java-Broker-Getting-Started-Starting-Stopping-Windows">
    <title>Starting/Stopping the broker on Windows</title>
    <para>Firstly change to the installation directory used during the <link linkend="Java-Broker-Installation-InstallationWindows">installation</link>
      and ensure that the <link linkend="Java-Broker-Installation-InstallationWindows-SettingQPIDWORK">QPID_WORK environment variable is set</link>.</para>
    <para>Now use the <command>qpid-server.bat</command> to start the server</para>
    <programlisting>bin\qpid-server.bat</programlisting>
    <para>Output similar to the following will be seen:</para>
    <screen>[Broker] BRK-1006 : Using configuration : C:\qpidwork\config.json
[Broker] BRK-1001 : Startup : Version: ${project.version} Build: 1478262
[Broker] BRK-1010 : Platform : JVM : Oracle Corporation version: 1.7.0_79-b15 OS : Windows 7 version: 6.1 arch: x86 cores: 4
[Broker] BRK-1011 : Maximum Memory : Heap : 518,979,584 bytes Direct : 1,610,612,736 bytes
[Broker] BRK-1002 : Starting : Listening on TCP port 5672
[Broker] MNG-1001 : Web Management Startup
[Broker] MNG-1002 : Starting : HTTP : Listening on port 8080
[Broker] MNG-1004 : Web Management Ready
[Broker] BRK-1004 : Qpid Broker Ready</screen>
    <para>The BRK-1004 message confirms that the Broker is ready for work.  The MNG-1002 and BRK-1002 confirm the ports on
      which the Broker is listening (for HTTP management and AMQP respectively).</para>
    <para>To stop the Broker, use Control-C from the controlling command prompt or
      <link linkend="Java-Broker-Management-Channel-REST-API-Operations">REST operation broker/shutdown</link>.
    </para>
  </section>
  <section role="h2" xml:id="Java-Broker-Getting-Started-Starting-Stopping-Unix">
    <title>Starting/Stopping the broker on Unix</title>
    <para>Firstly change to the installation directory used during the <link linkend="Java-Broker-Installation-InstallationUnix">installation</link>
      and ensure that the <link linkend="Java-Broker-Installation-InstallationUnix-SettingQPIDWORK">QPID_WORK environment variable is set</link>.</para>
    <para>Now use the <command>qpid-server</command> script to start the server:</para>
    <programlisting>bin/qpid-server</programlisting>
    <para>Output similar to the following will be seen:</para>
    <screen>[Broker] BRK-1006 : Using configuration : /var/qpidwork/config.json
[Broker] BRK-1001 : Startup : Version: ${project.version} Build: exported
[Broker] BRK-1010 : Platform : JVM : Oracle Corporation version: 1.7.0_79-b15 OS : Mac OS X version: 10.10.5 arch: x86_64 cores: 4
[Broker] BRK-1011 : Maximum Memory : Heap : 518,979,584 bytes Direct : 1,610,612,736 bytes
[Broker] BRK-1002 : Starting : Listening on TCP port 5672
[Broker] MNG-1001 : Web Management Startup
[Broker] MNG-1002 : Starting : HTTP : Listening on port 8080
[Broker] MNG-1004 : Web Management Ready
[Broker] BRK-1004 : Qpid Broker Ready</screen>
    <para>The BRK-1004 message confirms that the Broker is ready for work.  The MNG-1002 and BRK-1002 confirm the ports on
    which the Broker is listening (for HTTP management and AMQP respectively).</para>
    <para>To stop the Broker, use Control-C from the controlling shell, use the
        <command>bin/qpid.stop</command> script, use <command>kill -TERM &lt;pid&gt;</command>, or
      the <link linkend="Java-Broker-Management-Channel-REST-API-Operations">REST operation broker/shutdown</link>.</para>
  </section>
  <section role="h2" xml:id="Java-Broker-Getting-Started-Logging">
    <title>Log file</title>
    <para>The Broker writes a log file to record both details of its normal operation and any exceptional
      conditions.  By default the log file is written within the log subdirectory beneath the work directory
      - <computeroutput>$QPID_WORK/log/qpid.log</computeroutput> (UNIX) and
      <computeroutput>%QPID_WORK%\log\qpid.log</computeroutput> (Windows).</para>
    <para>For details of how to control the logging, see <xref linkend="Java-Broker-Runtime-Logging"/></para>
  </section>
  <section role="h2" xml:id="Java-Broker-Getting-Started-CommandLine">
    <title>Using the command line</title>
    <para>The Broker understands a number of command line options which may be used to customise the configuration.</para>
    <para>
      For additional details about the broker configuration and related command line arguments see
      <xref linkend="Java-Broker-Initial-Configuration"/>.
      The broker is fully configurable via its Web Management Console, for details of this see
      <xref linkend="Java-Broker-Management-Channel-Web-Console"/>.
    </para>
    <para>To see usage information for all command line options, use the <option>--help</option> option</para>
    <programlisting>bin/qpid-server --help</programlisting>
    <screen>usage: Qpid [-cic &lt;path&gt;] [-h] [-icp &lt;path&gt;] [-mm] [-mmhttp &lt;port&gt;]
       [-mmpass &lt;password&gt;] [-mmqv] [-os]
       [-prop &lt;name=value&gt;] [-props &lt;path&gt;] [-sp &lt;path&gt;] [-st &lt;type&gt;] [-v]
 -cic,--create-initial-config &lt;path&gt;                  create a copy of the
                                                      initial config file,
                                                      either to an
                                                      optionally specified
                                                      file path, or as
                                                      initial-config.json
                                                      in the current
                                                      directory
 -h,--help                                            print this message
 -icp,--initial-config-path &lt;path&gt;                    set the location of
                                                      initial JSON config
                                                      to use when
                                                      creating/overwriting
                                                      a broker
                                                      configuration store
 -mm,--management-mode                                start broker in
                                                      management mode,
                                                      disabling the AMQP
                                                      ports
 -mmhttp,--management-mode-http-port &lt;port&gt;           override http
                                                      management port in
                                                      management mode
 -mmpass,--management-mode-password &lt;password&gt;        Set the password for
                                                      the management mode
                                                      user mm_admin
 -mmqv,--management-mode-quiesce-virtualhosts         make virtualhosts
                                                      stay in the quiesced
                                                      state during
                                                      management mode.
 -os,--overwrite-store                                overwrite the broker
                                                      configuration store
                                                      with the current
                                                      initial
                                                      configuration
 -prop,--config-property &lt;name=value&gt;                 set a configuration
                                                      property to use when
                                                      resolving variables
                                                      in the broker
                                                      configuration store,
                                                      with format
                                                      "name=value"
 -props,--system-properties-file &lt;path&gt;               set the location of
                                                      initial properties
                                                      file to set
                                                      otherwise unset
                                                      system properties
 -sp,--store-path &lt;path&gt;                              use given
                                                      configuration store
                                                      location
 -st,--store-type &lt;type&gt;                              use given broker
                                                      configuration store
                                                      type
 -v,--version                                         print the version
                                                      information and exit
</screen>
  </section>
</chapter>
