Class Definitions
Definitions backup = admin.exportDefinitions();
Files.writeString(Path.of("broker.json"), backup.json());
// ... on the new broker
newAdmin.importDefinitions(Files.readString(Path.of("broker.json")));
Why this beats walking the topology
Queues, exchanges and bindings are the obvious things to export, and they are not all of it. Federation upstreams and shovels are runtime parameters, policies are separate again, and users, permissions and topic permissions are separate from all of those. A backup assembled by walking the topology misses every one of them, and the broker restored from it comes back looking complete while federating nothing.
This endpoint is the whole thing in one request, which is both a better backup and a cheaper one.
What it does not contain
No messages. This is configuration. Restoring definitions onto an empty broker gives you every queue, correctly configured, and every one of them empty.
Passwords are present but hashed. Users come back with
password_hash, which is enough to restore them onto another broker and not enough to
read anybody's password. It is still a credential: an exported definitions file lets anyone
holding it stand up a broker that accepts your users' passwords. Treat the file as a secret.
-
Method Details
-
json
- Returns:
- the document exactly as the broker sent it. This is what to write to a file and
what
RabbitAdmin.importDefinitions(String)takes — re-serialising the parsed form risks changing it in ways the import will notice
-
asMap
- Returns:
- the whole document, parsed
-
rabbitVersion
- Returns:
- the RabbitMQ version that produced this export
-
queues
- Returns:
- the exported queues, as the broker's own JSON shape
-
exchanges
-
bindings
-
vhosts
-
users
- Returns:
- users, each with a
password_hashrather than a password
-
permissions
-
topicPermissions
-
policies
-
parameters
- Returns:
- the runtime parameters: federation upstreams and shovels live here
-
globalParameters
-
summary
- Returns:
- a one-line count of what is in here, for a log line or a confirmation prompt
-
toString
-