Apollo 1.7.1 Management API
Overview
Apollo's REST API runs on port 61680 or via SSL on port 61681. If your running an Apollo broker on your local machine, you could access the API at the following HTTP URLs:
http://localhost:61680
https://localhost:61681
For all of the rest of this document, we will be leaving off that part, since it is the same for every API call.
Authentication
The broker requires all requests against the management API to supply user credentials which have administration privileges.
The user credentials can be supplied using via HTTP basic authentication. Example:
$ curl -u "admin:password" http://localhost:61680/broker
JSON Representation
The API routes are intended to be access programmatically as JSON services but they also provide an HTML representation so that the API services can easily be browsed using a standard web browser.
You must either set the HTTP Accept
header to application/json
or
append .json
to the URL to get the JSON representation of the data.
Example:
$ curl -H "Accept: application/json" -u "admin:password" \
http://localhost:61680/broker
$ curl -u "admin:password" http://localhost:61680/broker.json
Response Codes
You can use the HTTP response code to determine if your request succeeded or failed. Expect the following:
200
: If a GET, PUT, or DELETE request succeeds.303
: If a POST request succeeds.304
: If the resource cannot be modified at the current time.400
: The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.404
: If the resource cannot be found.401
: If the user does not have access to the resource.50x
: If an internal server error occurs while processing the request.
If your get a 40x
or 50x
response code, the response message
will contain a document describing the failure. For example, if we try
to use invalid query syntax you would get:
$ curl -i -u "admin:password" `echo 'http://localhost:61680/broker/virtual-hosts/apollo-01/queues.json?f=id&q=foo(id=="foo")'`
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
{"message":"Unable to find function (method): \"foo(java.lang.Boolean)\" in any user-defined function handlers or the default function handler"}
Working with Tabular Results
Many of the resource routes provided by the broker implement a selectable paged tabular interface. A good example of such a resource route is the connections list. It's route is:
/broker/connections
Example:
$ curl -u "admin:password" \
'http://localhost:61680/broker/connections.json'
Results in a Data Page :
{
"page":0,
"page_size":100,
"total_pages":1,
"total_rows":2,
"headers":[
"*"
],
"rows":[
{
"id":"4",
"state":"STARTED",
"state_since":1306848325102,
"read_counter":103,
"write_counter":239110628,
"connector":"tcp",
"protocol":"stomp",
"remote_address":"/127.0.0.1:61775",
"protocol_version":"1.0",
"user":"admin",
"waiting_on":"client request",
"subscription_count":1
},
{
"id":"5",
"state":"STARTED",
"state_since":1306848325102,
"read_counter":227739229,
"write_counter":113,
"connector:"tcp",
"protocol":"stomp",
"remote_address":"/127.0.0.1:61776",
"protocol_version":"1.0",
"user":"admin",
"waiting_on":"blocked sending to: org.apache.activemq.apollo.broker.Queue$$anon$1@13765e9b",
"subscription_count":0
}
]
}
The *
header field means the record was selected. To narrow down the selected fields you can add
multiple f
query parameters to pick the fields you want to retrieve.
Example:
$ curl -u "admin:password" \
'http://localhost:61680/broker/connections.json?f=id&f=read_counter'
Results in :
{
"page":0,
"page_size":100,
"total_pages":1,
"total_rows":2,
"headers":[
"id",
"read_counter"
],
"rows":[
[
"7",
110733109
],
[
"6",
103
]
]
}
If you want to narrow down the records which get selected, you can set a q
query parameter to SQL 92 style where clause which uses the record's fields
to filter down the selected records.
For example to only view local connection, you would want to use a where
clause like remote_address LIKE "/127.0.0.01:%"
which to execute with
curl
you would run:
curl -u "admin:password" \
'http://localhost:61680/broker/connections.json?q=remote_address%20LIKE%20"/127.0.0.1:%"'
The records are paged. The default page size is 100, so only the first 100
records will be displayed. If you want to view subsequent results, you must
set the p
query parameter to the page you wish to access. You can change
the page size by setting the ps
query parameter.
The results are typically return in the order in which the records were original
created. If you want to retrieve them in a different order, use the o
query
parameter to define the order in which they are returned. Example:
curl -u "admin:password" \
'http://localhost:61680/broker/connections.json?o=write_counter%20DESC&o=id'
Route Reference
Broker Management
Route | On Success | |
---|---|---|
POST
|
/broker/action/shutdown.json
|
303
|
Shuts down the JVM. |
||
GET
|
/broker.json
|
200
|
General information about the broker, JVM, and OS status. Example:
You can the |
||
GET
|
/broker/queue-metrics.json
|
200
|
Aggregates the messaging metrics for all the queue destinations. Example:
|
||
GET
|
/broker/topic-metrics.json
|
200
|
Aggregates the messaging metrics for all the topic destinations |
||
GET
|
/broker/dsub-metrics.json
|
200
|
Aggregates the messaging metrics for all the durable subscription destinations |
||
GET
|
/broker/dest-metrics.json
|
200
|
Aggregates the messaging metrics for all the destinations |
Virtual Host Management
Route | On Success | |
---|---|---|
GET
|
/broker/virtual-hosts.json
|
200
|
Provides tabular access to all the virtual hosts. |
||
GET
|
/broker/virtual-hosts/{host}.json
|
200
|
General details about the
|
||
GET
|
/broker/virtual-hosts/{host}/queue-metrics.json
|
200
|
Aggregates the messaging metrics for all the queue destinations on the
|
||
GET
|
/broker/virtual-hosts/{host}/topic-metrics.json
|
200
|
Aggregates the messaging metrics for all the topic destinations on the
|
||
GET
|
/broker/virtual-hosts/{host}/dsub-metrics.json
|
200
|
Aggregates the messaging metrics for all the durable subscription destinations on the
|
||
GET
|
/broker/virtual-hosts/{host}/dest-metrics.json
|
200
|
Aggregates the messaging metrics for all the destinations on the
|
||
GET
|
/broker/virtual-hosts/{host}/store.json
|
200
|
Gets metrics about the status of the message store used by the
|
||
GET
|
/broker/virtual-hosts/{host}/queues.json
|
200
|
Provides tabular access to all queue destinations on the |
||
GET
|
/broker/virtual-hosts/{host}/queues/{dest}.json
|
200
|
Gets metrics and details about the You can the
|
||
DELETE
|
/broker/virtual-hosts/{host}/queues/{dest}.json
|
200
|
Deletes the |
||
PUT
|
/broker/virtual-hosts/{host}/queues/{dest}.json
|
200
|
Creates the |
||
GET
|
/broker/virtual-hosts/{host}/topics.json
|
200
|
Provides tabular access to all topic destinations on the |
||
GET
|
/broker/virtual-hosts/{host}/topics/{dest}.json
|
200
|
Gets metrics and details about the You can the
|
||
DELETE
|
/broker/virtual-hosts/{host}/topics/{dest}.json
|
200
|
Deletes the |
||
PUT
|
/broker/virtual-hosts/{host}/topics/{dest}.json
|
200
|
Creates the |
||
GET
|
/broker/virtual-hosts/{host}/topic-queues/{dest}/{queue}.json
|
200
|
Gets metrics and details about |
||
GET
|
/broker/virtual-hosts/{host}/dsubs.json
|
200
|
Provides tabular access to all durable subscription destinations on the |
||
GET
|
/broker/virtual-hosts/{host}/dsubs/{dest}.json
|
200
|
Gets metrics and details about the |
Connection Management
Route | On Success | |
---|---|---|
GET
|
/broker/connectors.json
|
200
|
Provides tabular access to all connectors on the broker. |
||
GET
|
/broker/connectors/{connector}.json
|
200
|
Gets details about the
You can the |
||
POST
|
/broker/connectors/{connector}/action/stop.json
|
303
|
Stops the |
||
POST
|
/broker/connectors/{connector}/action/start.json
|
303
|
Starts the |
||
GET
|
/broker/connection-metrics.json
|
200
|
Aggregates metrics about the connections. |
||
GET
|
/broker/connections.json
|
200
|
Provides tabular access to all connections on the broker. |
||
GET
|
/broker/connections/{connection}.json
|
200
|
Gets details about the
|
||
DELETE
|
/broker/connections/{connection}.json
|
200
|
Deletes the |
||
POST
|
/broker/connections/{connection}/action/delete.json
|
303
|
Deletes the |
Broker Configuration Management
Route | On Success | |
---|---|---|
GET
|
/config/runtime.json
|
200
|
The runtime configuration the broker using. This version of the configuration has all property placeholders resolved and then password fields are cleared. |
||
GET
|
/config/runtime.json
|
200
|
The runtime configuration the broker using. This version of the configuration has all property placeholders resolved and then password fields are cleared. |
||
GET
|
/config/files.json
|
200
string array
|
A listing of the configuration files. |
||
GET
|
/config/files/{file}
|
200
bytes
|
Downloads the contents of the config file. |
||
POST
|
/config/files/{file}
|
303
|
Updates the contents of the config file. You can either post the raw bytes,
or post a url encoded form with a field |
Session Management
Route | On Success | |
---|---|---|
GET
|
/broker/whoami.json
|
200
|
Lists the principals associated with your username. Example: curl -u “admin:password” http://localhost:61680/broker/whoami.json
|
||
GET
|
/broker/signin.json
|
200
true
|
Log you in using the |
||
POST
|
/broker/signin.json
|
200
true
|
Signs you in using the |
||
GET
|
/broker/signout.json
|
200
true
|
Signs you off by invalidating your session. |