{"id":20476660,"url":"https://github.com/rabbitmq/hop","last_synced_at":"2025-05-15T10:07:47.023Z","repository":{"id":19765746,"uuid":"23023612","full_name":"rabbitmq/hop","owner":"rabbitmq","description":"RabbitMQ HTTP API client for Java, Groovy, and other JVM languages","archived":false,"fork":false,"pushed_at":"2025-05-14T02:06:47.000Z","size":2928,"stargazers_count":145,"open_issues_count":16,"forks_count":57,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-05-14T03:47:39.861Z","etag":null,"topics":["http","java","rabbitmq"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rabbitmq.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-08-16T17:44:23.000Z","updated_at":"2025-05-14T02:06:51.000Z","dependencies_parsed_at":"2023-12-04T09:25:22.180Z","dependency_job_id":"d7304cad-0759-430a-9e26-a4c6033f7484","html_url":"https://github.com/rabbitmq/hop","commit_stats":null,"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabbitmq%2Fhop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabbitmq%2Fhop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabbitmq%2Fhop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabbitmq%2Fhop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rabbitmq","download_url":"https://codeload.github.com/rabbitmq/hop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319720,"owners_count":22051073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","java","rabbitmq"],"created_at":"2024-11-15T15:22:12.251Z","updated_at":"2025-05-15T10:07:42.009Z","avatar_url":"https://github.com/rabbitmq.png","language":"Java","funding_links":[],"categories":["进程间通信"],"sub_categories":[],"readme":":rabbitmq-version: 4.0.0\n:hop-version: 5.3.0\n:jackson-version: 2.18.1\n:reactor-netty-version: 1.2.0\n:hop-snapshot: 5.4.0-SNAPSHOT\n:jackson-for-snapshot: 2.18.1\n\n= Hop, Java Client for the RabbitMQ HTTP API\n\nimage:https://github.com/rabbitmq/hop/actions/workflows/test.yml/badge.svg[\"Build Status\", link=\"https://github.com/rabbitmq/hop/actions/workflows/test.yml\"]\n\nHop is a Java client for the\nhttps://raw.githack.com/rabbitmq/rabbitmq-server/v{rabbitmq-version}/deps/rabbitmq_management/priv/www/api/index.html[RabbitMQ HTTP API].\n\n== Polyglot\n\nHop is designed to be easy to use from other JVM languages, primarily Groovy,\nScala, and Kotlin.\n\nN.B. that Clojure already includes an HTTP API client as part of\nhttp://clojurerabbitmq.info[Langohr], and you should use Langohr instead.\n\n== Reactive\n\nHop provides a reactive, non-blocking IO client based on https://projectreactor.io/[Reactor Netty].\nA blocking client is available as well.\n\n== Project Maturity\n\nThis project is mature and covers all key RabbitMQ HTTP API endpoints.\n\nMeaningful breaking API changes are reflected in the version.\nUser documentation is currently kept in this README.\n\n== Pre-requisites\n\nHop requires Java 11 or later.\n\n== Maven Artifacts\n\nimage:https://maven-badges.herokuapp.com/maven-central/com.rabbitmq/http-client/badge.svg[\"Maven Central\", link=\"https://maven-badges.herokuapp.com/maven-central/com.rabbitmq/http-client\"]\n\nProject artifacts are available from Maven Central.\n\nFor milestones and release candidates, declare the\n\u003c\u003cmilestone-rc-repository,milestone repository\u003e\u003e in your dependency manager.\n\n=== Dependency Manager Configuration\n\nIf you want to use the **blocking IO client**, add the following dependencies:\n\n.pom.xml\n[source,xml,subs=\"attributes,specialcharacters\"]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.rabbitmq\u003c/groupId\u003e\n  \u003cartifactId\u003ehttp-client\u003c/artifactId\u003e\n  \u003cversion\u003e{hop-version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.fasterxml.jackson.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejackson-databind\u003c/artifactId\u003e\n  \u003cversion\u003e{jackson-version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\n.build.gradle\n[source,groovy,subs=\"attributes,specialcharacters\"]\n----\ncompile \"com.rabbitmq:http-client:{hop-version}\"\ncompile \"com.fasterxml.jackson.core:jackson-databind:{jackson-version}\"\n----\n\nIf you want to use the **reactive, non-blocking IO client**, add the following dependencies:\n\n.pom.xml\n[source,xml,subs=\"attributes,specialcharacters\"]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.rabbitmq\u003c/groupId\u003e\n  \u003cartifactId\u003ehttp-client\u003c/artifactId\u003e\n  \u003cversion\u003e{hop-version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.projectreactor.netty\u003c/groupId\u003e\n  \u003cartifactId\u003ereactor-netty\u003c/artifactId\u003e\n  \u003cversion\u003e{reactor-netty-version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.fasterxml.jackson.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejackson-databind\u003c/artifactId\u003e\n  \u003cversion\u003e{jackson-version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\n.build.gradle\n[source,groovy,subs=\"attributes,specialcharacters\"]\n----\ncompile \"com.rabbitmq:http-client:{hop-version}\"\ncompile \"io.projectreactor.netty:reactor-netty:{reactor-netty-version}\"\ncompile \"com.fasterxml.jackson.core:jackson-databind:{jackson-version}\"\n----\n\n[[milestone-rc-repository]]\n=== Milestones and Release Candidates\n\nMilestones and release candidates are available on the RabbitMQ Milestone Repository:\n\nMaven:\n\n.pom.xml\n[source,xml,subs=\"attributes,specialcharacters\"]\n----\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cid\u003epackagecloud-rabbitmq-maven-milestones\u003c/id\u003e\n    \u003curl\u003ehttps://packagecloud.io/rabbitmq/maven-milestones/maven2\u003c/url\u003e\n    \u003creleases\u003e\n      \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/releases\u003e\n    \u003csnapshots\u003e\n      \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n----\n\nGradle:\n\n.build.gradle\n[source,groovy,subs=\"attributes,specialcharacters\"]\n----\nrepositories {\n  maven {\n    url \"https://packagecloud.io/rabbitmq/maven-milestones/maven2\"\n  }\n}\n----\n\n=== Snapshots\n\nTo use snapshots, add the following dependencies:\n\n.pom.xml\n[source,xml,subs=\"attributes,specialcharacters\"]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.rabbitmq\u003c/groupId\u003e\n  \u003cartifactId\u003ehttp-client\u003c/artifactId\u003e\n  \u003cversion\u003e{hop-snapshot}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.fasterxml.jackson.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejackson-databind\u003c/artifactId\u003e\n  \u003cversion\u003e{jackson-for-snapshot}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\n.build.gradle\n[source,groovy,subs=\"attributes,specialcharacters\"]\n----\ncompile \"com.rabbitmq:http-client:{hop-snapshot}\"\ncompile \"com.fasterxml.jackson.core:jackson-databind:{jackson-for-snapshot}\"\n----\n\nAdd the https://oss.sonatype.org/content/repositories/snapshots/com/rabbitmq/http-client/[Sonatype OSS snapshot repository] to your dependency manager:\n\nMaven:\n\n.pom.xml\n[source,xml,subs=\"attributes,specialcharacters\"]\n----\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cid\u003eossrh\u003c/id\u003e\n    \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n    \u003csnapshots\u003e\n      \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n    \u003creleases\u003e\n      \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/releases\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n----\n\nGradle:\n\n.build.gradle\n[source,groovy,subs=\"attributes,specialcharacters\"]\n----\nrepositories {\n  maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }\n  mavenCentral()\n}\n----\n\n\n== Usage Guide\n\n=== Instantiating a Client\n\nHop faithfully follows RabbitMQ HTTP API conventions in its API. You interact with the server\nusing a single class, `Client`, which needs an API endpoint and\na pair of credentials to be instantiated:\n\n[source,java]\n----\nimport com.rabbitmq.http.client.Client;\nimport com.rabbitmq.http.client.ClientParameters;\n\nClient c = new Client(\n  new ClientParameters()\n    .url(\"http://127.0.0.1:15672/api/\")\n    .username(\"guest\")\n    .password(\"guest\")\n);\n----\n\n=== HTTP Layer (Synchronous Client)\n\nThe synchronous client uses https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html[Java 11's `HttpClient`] internally.\n\n==== Advanced Configuration\n\nThe client uses sensible defaults, but it is possible to customize the `HttpClient` instance and requests creation with `JdkHttpClientHttpLayer#configure()`:\n\n[source,java]\n----\nHttpLayerFactory httpLayerFactory =\n  JdkHttpClientHttpLayer.configure()  // \u003c1\u003e\n    .clientBuilderConsumer(\n      clientBuilder -\u003e  // \u003c2\u003e\n        clientBuilder\n          .connectTimeout(Duration.ofSeconds(10)))\n    .requestBuilderConsumer(\n      requestBuilder -\u003e  // \u003c3\u003e\n        requestBuilder\n          .timeout(Duration.ofSeconds(10))\n          .setHeader(\"Authorization\", authorization(\"guest\", \"guest\")))\n    .create();  // \u003c4\u003e\n\nClient c =\n    new Client(\n        new ClientParameters()\n            .url(\"http://127.0.0.1:15672/api/\")\n            .username(\"guest\")\n            .password(\"guest\")\n            .httpLayerFactory(httpLayerFactory));  // \u003c5\u003e\n----\n\u003c1\u003e Configure the HTTP layer factory\n\u003c2\u003e Configure the creation of the `HttpClient` instance\n\u003c3\u003e Configure the creation of each request\n\u003c4\u003e Instantiate the HTTP layer factory\n\u003c5\u003e Set the HTTP layer factory\n\n==== TLS\n\nSet the `SSLContext` on the `HttpClient` builder to configure TLS:\n\n[source,java]\n----\nSSLContext sslContext = SSLContext.getInstance(\"TLSv1.3\");  // \u003c1\u003e\nsslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), random);  // \u003c2\u003e\nHttpLayerFactory factory =\n  JdkHttpClientHttpLayer.configure()\n    .clientBuilderConsumer(builder -\u003e builder.sslContext(sslContext))  // \u003c3\u003e\n    .create();\n----\n\u003c1\u003e Create the SSL context\n\u003c2\u003e Initialize the SSL context\n\u003c3\u003e Set the SSL context on the client builder\n\nNote the `HttpClient` enables https://tools.ietf.org/search/rfc2818#section-3.1[hostname verification] by default.\nThis is a good thing for security, but it can generate surprising failures.\n\nHostname verification can be disabled _globally_ with the https://bugs.openjdk.java.net/browse/JDK-8213309[`jdk.internal.httpclient.disableHostnameVerification` system property] for development or test purposes, but at no cost in a production environment.\n\n=== Getting Overview\n\n[source,java]\n----\nc.getOverview();\n----\n\n=== Node and Cluster Status\n\n[source,java]\n----\n// list cluster nodes\nc.getNodes();\n\n// get status and metrics of individual node\nc.getNode(\"rabbit@mercurio.local\");\n----\n\n=== Operations on Connections\n\n[source,java]\n----\n// list client connections\nc.getConnections();\n\n// get status and metrics of individual connection\nc.getConnection(\"127.0.0.1:61779 -\u003e 127.0.0.1:5672\");\n\n// forcefully close connection\nc.closeConnection(\"127.0.0.1:61779 -\u003e 127.0.0.1:5672\");\n----\n\n=== Operations on Channels\n\n[source,java]\n----\n// list all channels\nc.getChannels();\n\n// list channels on individual connection\nc.getChannels(\"127.0.0.1:61779 -\u003e 127.0.0.1:5672\");\n\n// list detailed channel info\nc.getChannel(\"127.0.0.1:61779 -\u003e 127.0.0.1:5672 (3)\");\n----\n\n=== Operations on Vhosts\n\n[source,java]\n----\n// get status and metrics of individual vhost\nc.getVhost(\"/\");\n----\n\n=== Managing Users\n\nTBD\n\n=== Managing Permissions\n\nTBD\n\n=== Operations on Exchanges\n\nTBD\n\n=== Operations on Queues\n\n[source,java]\n----\n// list all queues\nc.getQueues();\n\n// list all queues in a vhost\nc.getQueues();\n\n// declare a queue that's not durable, auto-delete,\n// and non-exclusive\nc.declareQueue(\"/\", \"queue1\", new QueueInfo(false, true, false));\n\n// bind a queue\nc.bindQueue(\"/\", \"queue1\", \"amq.fanout\", \"routing-key\");\n\n// delete a queue\nc.deleteQueue(\"/\", \"queue1\");\n----\n\n=== Operations on Bindings\n\n[source,java]\n----\n// list bindings where exchange \"an.exchange\" is source\n// (other things are bound to it)\nc.getBindingsBySource(\"/\", \"an.exchange\");\n\n// list bindings where exchange \"an.exchange\" is destination\n// (it is bound to other exchanges)\nc.getBindingsByDestination(\"/\", \"an.exchange\");\n----\n\n== Running Tests (with Docker)\n\nStart the broker:\n\n[source,sh]\n----\ndocker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4.0-management\n----\n\nConfigure the broker for the test suite:\n\n[source,sh]\n----\nexport HOP_RABBITMQCTL=\"DOCKER:rabbitmq\"\n./ci/before-build.sh\n----\n\nLaunch the test suite:\n\n[source,sh]\n----\n./mvnw test\n----\n\n== Running Tests\n\nTo run the suite against a specific RabbitMQ node, export `HOP_RABBITMQCTL`\nand `HOP_RABBITMQ_PLUGINS` to point at `rabbitmqctl` and `rabbitmq-plugins`\nfrom the installation.\n\nThen set up the node that is assumed to be running:\n\n[source,sh]\n----\n./ci/before-build.sh\n----\n\nThis will enable several plugins used by the test suite and configure the node\nto use a much shorter event refresh interval so that HTTP API reflects system state\nchanges with less of a delay.\n\nTo run the tests:\n\n[source,sh]\n----\n./mvnw test\n----\n\nThe test suite assumes RabbitMQ is running locally with\nstock settings and a few plugins are enabled:\n\n* `rabbitmq_management` (listening on port 15672)\n* `rabbitmq_shovel_management`\n* `rabbitmq_federation_management`\n\nTo run the suite against a specific RabbitMQ node, export `HOP_RABBITMQCTL`\nand `HOP_RABBITMQ_PLUGINS`\nto point at `rabbitmqctl` and `rabbitmq-plugins` from the installation.\n\nThe test suite can use a different port than 15672 by specifying it with the\n`rabbitmq.management.port` system property:\n\n[source,sh]\n----\n./mvnw test -Drabbitmq.management.port=15673\n----\n\n== Versioning\n\nThis library uses https://semver.org/[semantic versioning].\n\n== Support\n\nSee the https://www.rabbitmq.com/client-libraries/java-versions[RabbitMQ Java libraries support page]\nfor the support timeline of this library.\n\n== License\n\nhttps://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0].\n\n\n== Copyright\n\n(c) Michael Klishin, 2014-2016.\n(c) VMware, Inc. or its affiliates, 2014-2023.\n(c) Broadcom, 2023. All Rights Reserved. The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabbitmq%2Fhop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frabbitmq%2Fhop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabbitmq%2Fhop/lists"}