├── bin └── before_build.sh ├── .mvn ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── release-versions.txt ├── src ├── main │ └── java │ │ └── com │ │ └── rabbitmq │ │ └── http │ │ └── client │ │ ├── domain │ │ ├── MqttVhostPortInfo.java │ │ ├── DestinationType.java │ │ ├── GlobalRuntimeParameter.java │ │ ├── UpstreamInfo.java │ │ ├── UpstreamSetInfo.java │ │ ├── ClusterId.java │ │ ├── OwnerPidDetails.java │ │ ├── AlivenessTestResult.java │ │ ├── UserConnectionInfo.java │ │ ├── QueueDetails.java │ │ ├── Sample.java │ │ ├── UpstreamSetDetails.java │ │ ├── AuthMechanism.java │ │ ├── ErlangApp.java │ │ ├── ConnectionDetails.java │ │ ├── VhostLimits.java │ │ ├── CurrentUserDetails.java │ │ ├── DeleteQueueParameters.java │ │ ├── TopicPermissions.java │ │ ├── NetworkListener.java │ │ ├── PluginContext.java │ │ ├── RuntimeParameter.java │ │ ├── ExchangeType.java │ │ ├── RateDetails.java │ │ ├── ObjectTotals.java │ │ ├── PolicyInfo.java │ │ ├── OutboundMessage.java │ │ ├── Page.java │ │ ├── AckMode.java │ │ ├── UserInfo.java │ │ ├── ChannelDetails.java │ │ ├── ShovelInfo.java │ │ ├── UserPermissions.java │ │ ├── InboundMessage.java │ │ ├── ExchangeMessageStats.java │ │ ├── ClientProperties.java │ │ ├── ShovelDefinition.java │ │ ├── QueueTotals.java │ │ ├── BindingInfo.java │ │ ├── ShovelStatus.java │ │ ├── ExchangeInfo.java │ │ ├── ConsumerDetails.java │ │ ├── DetailsParameters.java │ │ ├── Definitions.java │ │ ├── QueryParameters.java │ │ ├── VhostInfo.java │ │ ├── OverviewResponse.java │ │ ├── ChannelInfo.java │ │ ├── MessageStats.java │ │ └── ShovelDetails.java │ │ ├── HttpException.java │ │ ├── HttpEndpoint.java │ │ ├── HttpClientException.java │ │ ├── HttpServerException.java │ │ ├── GetEncoding.java │ │ ├── HttpResponse.java │ │ ├── GetAckMode.java │ │ ├── PercentEncoder.java │ │ ├── HttpLayer.java │ │ ├── ReactorNettyClientOptions.java │ │ ├── ParameterizedTypeReference.java │ │ ├── ClientParameters.java │ │ └── Utils.java ├── test │ ├── resources │ │ └── logback-test.xml │ └── java │ │ ├── SanityCheck.java │ │ └── com │ │ └── rabbitmq │ │ ├── http │ │ └── client │ │ │ ├── PercentEncoderTest.java │ │ │ ├── HttpParametersEncodingTest.java │ │ │ ├── domain │ │ │ └── PageTest.java │ │ │ ├── TestUtils.java │ │ │ └── UtilsTest.java │ │ └── AppTest.java └── api │ └── overview.html ├── .gitignore ├── .github ├── dependabot.yml └── workflows │ ├── publish-snapshot.yml │ ├── release.yml │ ├── test-supported-java-versions.yml │ ├── test-rabbitmq-alphas.yml │ └── test.yml ├── ci ├── release-hop.sh ├── start-broker.sh └── before-build.sh └── mvnw.cmd /bin/before_build.sh: -------------------------------------------------------------------------------- 1 | ci/before-build.sh -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Dmaven.wagon.http.retryHandler.count=10 2 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/hop/main/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /release-versions.txt: -------------------------------------------------------------------------------- 1 | RELEASE_VERSION="5.5.0" 2 | DEVELOPMENT_VERSION="5.5.0-SNAPSHOT" 3 | RELEASE_BRANCH="main" 4 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/MqttVhostPortInfo.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | import java.util.Map; 4 | 5 | public class MqttVhostPortInfo extends GlobalRuntimeParameter> {} 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | gradle-app.setting 4 | .gradletasknamecache 5 | 6 | /target 7 | *.jar 8 | *.log 9 | 10 | *~ 11 | *# 12 | ~* 13 | .project 14 | .classpath 15 | .settings 16 | /.idea 17 | /*.iml 18 | /*.ipr 19 | /*.iws 20 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/DestinationType.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum DestinationType { 6 | @JsonProperty("queue") 7 | QUEUE, 8 | 9 | @JsonProperty("exchange") 10 | EXCHANGE 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/api/overview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This document is the API specification for Java Client for the 4 | RabbitMQ HTTP API 5 |
6 |
7 |

8 | For further API reference and developer documentation, see the 9 | Project Home Page. 10 | That documentation contains more detailed, developer-targeted 11 | descriptions, with conceptual overviews, definitions of terms, 12 | workarounds, and working code examples. 13 |

14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Please see the documentation for all configuration options: 2 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 3 | version: 2 4 | updates: 5 | - package-ecosystem: "maven" 6 | directory: "/" 7 | schedule: 8 | interval: "daily" 9 | open-pull-requests-limit: 20 10 | ignore: 11 | - dependency-name: "ch.qos.logback:logback-classic" 12 | versions: [ "[1.3,)" ] 13 | - dependency-name: "org.junit.jupiter:*" 14 | versions: [ "[6.0,)" ] 15 | - dependency-name: "org.junit.platform:*" 16 | versions: [ "[6.0,)" ] 17 | - package-ecosystem: "github-actions" 18 | directory: "/" 19 | schedule: 20 | interval: "daily" 21 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/GlobalRuntimeParameter.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | @JsonInclude(JsonInclude.Include.NON_NULL) 6 | public class GlobalRuntimeParameter { 7 | private String name; 8 | private T value; 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public T getValue() { 19 | return value; 20 | } 21 | 22 | public void setValue(T value) { 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "RuntimeParameter{" + 29 | "name='" + name + '\'' + 30 | ", value=" + value + 31 | '}'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ci/release-hop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source ./release-versions.txt 4 | git checkout $RELEASE_BRANCH 5 | 6 | ./mvnw release:clean release:prepare -DdryRun=true -Darguments="-DskipTests" --no-transfer-progress \ 7 | --batch-mode -Dtag="v$RELEASE_VERSION" \ 8 | -DreleaseVersion=$RELEASE_VERSION \ 9 | -DdevelopmentVersion=$DEVELOPMENT_VERSION \ 10 | 11 | ./mvnw release:clean release:prepare -Darguments="-DskipTests" --no-transfer-progress \ 12 | --batch-mode -Dtag="v$RELEASE_VERSION" \ 13 | -DreleaseVersion=$RELEASE_VERSION \ 14 | -DdevelopmentVersion=$DEVELOPMENT_VERSION 15 | 16 | git checkout "v$RELEASE_VERSION" 17 | 18 | if [[ $RELEASE_VERSION == *[RCM]* ]] 19 | then 20 | MAVEN_PROFILE="milestone" 21 | echo "prerelease=true" >> $GITHUB_ENV 22 | else 23 | MAVEN_PROFILE="release" 24 | echo "prerelease=false" >> $GITHUB_ENV 25 | fi 26 | 27 | ./mvnw clean deploy -P $MAVEN_PROFILE -DskipTests --no-transfer-progress -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/UpstreamInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | public class UpstreamInfo extends RuntimeParameter { 20 | 21 | public UpstreamInfo() { 22 | this.setComponent("federation-upstream"); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/publish-snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Publish snapshot 2 | 3 | on: workflow_dispatch 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-24.04 8 | 9 | steps: 10 | - uses: actions/checkout@v6 11 | - name: Set up JDK 12 | uses: actions/setup-java@v5 13 | with: 14 | distribution: 'temurin' 15 | java-version: '25' 16 | cache: 'maven' 17 | server-id: central 18 | server-username: MAVEN_USERNAME 19 | server-password: MAVEN_PASSWORD 20 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 21 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 22 | - name: Publish snapshot 23 | run: ./mvnw clean deploy -Psnapshots -DskipITs -DskipTests --no-transfer-progress 24 | env: 25 | MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 26 | MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }} 27 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 28 | -------------------------------------------------------------------------------- /src/test/java/SanityCheck.java: -------------------------------------------------------------------------------- 1 | ///usr/bin/env jbang "$0" "$@" ; exit $? 2 | //DEPS com.rabbitmq:http-client:${version} 3 | //DEPS org.slf4j:slf4j-simple:1.7.36 4 | 5 | import org.slf4j.LoggerFactory; 6 | import com.rabbitmq.http.client.Client; 7 | import com.rabbitmq.http.client.ClientParameters; 8 | 9 | public class SanityCheck { 10 | 11 | public static void main(String[] args) { 12 | try { 13 | Client c = 14 | new Client( 15 | new ClientParameters() 16 | .url("http://127.0.0.1:15672/api/") 17 | .username("guest") 18 | .password("guest")); 19 | c.getOverview(); 20 | LoggerFactory.getLogger("rabbitmq") 21 | .info("Test succeeded with Hop {}", Client.class.getPackage().getImplementationVersion()); 22 | System.exit(0); 23 | } catch (Exception e) { 24 | LoggerFactory.getLogger("rabbitmq").info("Test failed", e); 25 | System.exit(1); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/UpstreamSetInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.List; 20 | 21 | public class UpstreamSetInfo extends RuntimeParameter> { 22 | 23 | public UpstreamSetInfo() { 24 | this.setComponent("federation-upstream-set"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /ci/start-broker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | RABBITMQ_IMAGE=${RABBITMQ_IMAGE:-rabbitmq:4.2} 4 | 5 | wait_for_message() { 6 | while ! docker logs "$1" | grep -q "$2"; 7 | do 8 | sleep 5 9 | echo "Waiting 5 seconds for $1 to start..." 10 | done 11 | } 12 | 13 | 14 | mkdir -p rabbitmq-configuration 15 | 16 | echo "[rabbitmq_management, rabbitmq_shovel,rabbitmq_shovel_management,rabbitmq_federation,rabbitmq_federation_management,rabbitmq_mqtt]." \ 17 | > rabbitmq-configuration/enabled_plugins 18 | 19 | echo "Running RabbitMQ ${RABBITMQ_IMAGE}" 20 | 21 | docker rm -f rabbitmq 2>/dev/null || echo "rabbitmq was not running" 22 | docker run -d --name rabbitmq \ 23 | --network host \ 24 | -v "${PWD}"/rabbitmq-configuration:/etc/rabbitmq \ 25 | "${RABBITMQ_IMAGE}" 26 | 27 | wait_for_message rabbitmq "completed with" 28 | 29 | docker exec rabbitmq rabbitmqctl enable_feature_flag --opt-in khepri_db 30 | docker exec rabbitmq rabbitmq-diagnostics erlang_version 31 | docker exec rabbitmq rabbitmqctl version 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Hop 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-24.04 9 | 10 | steps: 11 | - uses: actions/checkout@v6 12 | - name: Set up JDK 13 | uses: actions/setup-java@v5 14 | with: 15 | distribution: 'temurin' 16 | java-version: '11' 17 | cache: 'maven' 18 | server-id: central 19 | server-username: MAVEN_USERNAME 20 | server-password: MAVEN_PASSWORD 21 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 22 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 23 | - name: Release Hop 24 | run: | 25 | git config user.name "rabbitmq-ci" 26 | git config user.email "rabbitmq-ci@users.noreply.github.com" 27 | ci/release-hop.sh 28 | env: 29 | MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 30 | MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }} 31 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 32 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/HttpException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | /** 20 | * Base exception. 21 | */ 22 | public class HttpException extends RuntimeException { 23 | 24 | static final long serialVersionUID = 1; 25 | 26 | public HttpException(Throwable cause) { 27 | super(cause); 28 | } 29 | 30 | public HttpException(String message) { 31 | super(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ClusterId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | public class ClusterId { 20 | private String name; 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "ClusterId{" + 33 | "name='" + name + '\'' + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/OwnerPidDetails.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | /* 4 | "owner_pid_details": { 5 | "name": "127.0.0.1:57130 -> 127.0.0.1:5672", 6 | "peer_host": "127.0.0.1", 7 | "peer_port": 57130 8 | }, 9 | "pol 10 | */ 11 | public class OwnerPidDetails { 12 | private String name; 13 | private String peerHost; 14 | private int peerPort; 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getPeerHost() { 25 | return peerHost; 26 | } 27 | 28 | public void setPeerHost(String peerHost) { 29 | this.peerHost = peerHost; 30 | } 31 | 32 | public int getPeerPort() { 33 | return peerPort; 34 | } 35 | 36 | public void setPeerPort(int peerPort) { 37 | this.peerPort = peerPort; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "OwnerPidDetails{" + 43 | "name='" + name + '\'' + 44 | ", peerHost='" + peerHost + '\'' + 45 | ", peerPort=" + peerPort + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /.github/workflows/test-supported-java-versions.yml: -------------------------------------------------------------------------------- 1 | name: Test against supported Java versions 2 | 3 | on: 4 | schedule: 5 | - cron: '0 4 * * *' 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-24.04 11 | strategy: 12 | matrix: 13 | distribution: [ 'temurin' ] 14 | version: [ '11', '17', '21', '25' ] 15 | include: 16 | - distribution: 'semeru' 17 | version: '17' 18 | name: Test against Java ${{ matrix.distribution }} ${{ matrix.version }} 19 | steps: 20 | - uses: actions/checkout@v6 21 | - name: Set up JDK 22 | uses: actions/setup-java@v5 23 | with: 24 | distribution: ${{ matrix.distribution }} 25 | java-version: ${{ matrix.version }} 26 | cache: 'maven' 27 | - name: Start RabbitMQ 28 | run: ci/start-broker.sh 29 | - name: Configure broker 30 | run: HOP_RABBITMQCTL=DOCKER:rabbitmq ci/before-build.sh 31 | - name: Show version 32 | run: ./mvnw --version 33 | - name: Test 34 | run: ./mvnw test --no-transfer-progress 35 | - name: Stop broker 36 | run: docker stop rabbitmq && docker rm rabbitmq 37 | -------------------------------------------------------------------------------- /.github/workflows/test-rabbitmq-alphas.yml: -------------------------------------------------------------------------------- 1 | name: Test against RabbitMQ latest alphas 2 | 3 | on: 4 | schedule: 5 | - cron: '0 4 * * *' 6 | push: 7 | branches: 8 | - main 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-24.04 14 | strategy: 15 | matrix: 16 | rabbitmq-image: 17 | - pivotalrabbitmq/rabbitmq:v4.2.x-otp27 18 | - pivotalrabbitmq/rabbitmq:main-otp27 19 | name: Test against ${{ matrix.rabbitmq-image }} 20 | steps: 21 | - uses: actions/checkout@v6 22 | - name: Set up JDK 23 | uses: actions/setup-java@v5 24 | with: 25 | distribution: 'temurin' 26 | java-version: '25' 27 | cache: 'maven' 28 | - name: Start RabbitMQ 29 | run: ci/start-broker.sh 30 | env: 31 | RABBITMQ_IMAGE: ${{ matrix.rabbitmq-image }} 32 | - name: Configure broker 33 | run: HOP_RABBITMQCTL=DOCKER:rabbitmq ci/before-build.sh 34 | - name: Show version 35 | run: ./mvnw --version 36 | - name: Test 37 | run: ./mvnw test --no-transfer-progress 38 | - name: Stop broker 39 | run: docker stop rabbitmq && docker rm rabbitmq 40 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/HttpEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | /** 20 | * Representation of an HTTP endpoint. 21 | * 22 | * @since 3.0.0 23 | */ 24 | public class HttpEndpoint { 25 | 26 | private final String uri; 27 | 28 | private final String method; 29 | 30 | public HttpEndpoint(String uri, String method) { 31 | this.uri = uri; 32 | this.method = method; 33 | } 34 | 35 | public String uri() { 36 | return uri; 37 | } 38 | 39 | public String method() { 40 | return method; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/AlivenessTestResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class AlivenessTestResult { 21 | private static final String SUCCESS = "ok"; 22 | private String status; 23 | 24 | public String getStatus() { 25 | return status; 26 | } 27 | 28 | public void setStatus(String status) { 29 | this.status = status; 30 | } 31 | 32 | public boolean isSuccessful() { 33 | return status.equals(SUCCESS); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "AlivenessTestResult{" + 39 | "status='" + status + '\'' + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/HttpClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | /** 20 | * Java exception for 4xx HTTP responses. 21 | * 22 | * @since 2.1.0 23 | */ 24 | public class HttpClientException extends HttpException { 25 | 26 | static final long serialVersionUID = 1; 27 | 28 | private final int status; 29 | private final String reason; 30 | 31 | public HttpClientException(int status, String reason) { 32 | super(reason); 33 | this.status = status; 34 | this.reason = reason; 35 | } 36 | 37 | public int status() { 38 | return status; 39 | } 40 | 41 | public String reason() { 42 | return reason; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/HttpServerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | /** 20 | * Java exception for 5xx HTTP responses. 21 | * 22 | * @since 3.0.0 23 | */ 24 | public class HttpServerException extends HttpException { 25 | 26 | static final long serialVersionUID = 1; 27 | 28 | private final int status; 29 | private final String reason; 30 | 31 | public HttpServerException(int status, String reason) { 32 | super(reason); 33 | this.status = status; 34 | this.reason = reason; 35 | } 36 | 37 | public int status() { 38 | return status; 39 | } 40 | 41 | public String reason() { 42 | return reason; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/UserConnectionInfo.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public class UserConnectionInfo { 6 | private String name; 7 | @JsonProperty("user") 8 | private String username; 9 | private String vhost; 10 | private String node; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getUsername() { 21 | return username; 22 | } 23 | 24 | public void setUsername(String username) { 25 | this.username = username; 26 | } 27 | 28 | public String getVhost() { 29 | return vhost; 30 | } 31 | 32 | public void setVhost(String vhost) { 33 | this.vhost = vhost; 34 | } 35 | 36 | public String getNode() { 37 | return node; 38 | } 39 | 40 | public void setNode(String node) { 41 | this.node = node; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "UserConnectionInfo{" + 47 | "name='" + name + '\'' + 48 | ", username='" + username + '\'' + 49 | ", vhost='" + vhost + '\'' + 50 | ", node='" + node + '\'' + 51 | '}'; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/QueueDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class QueueDetails { 21 | private String name; 22 | private String vhost; 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getVhost() { 33 | return vhost; 34 | } 35 | 36 | public void setVhost(String vhost) { 37 | this.vhost = vhost; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "QueueDetails{" + 43 | "name='" + name + '\'' + 44 | ", vhost='" + vhost + '\'' + 45 | '}'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/GetEncoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client; 17 | 18 | /** 19 | * The type of expected encoding when consuming messages. 20 | * 21 | * @see Client#get(String, String, int, GetAckMode, GetEncoding, int) 22 | * @see ReactorNettyClient#get(String, String, int, GetAckMode, GetEncoding, int) 23 | * @since 3.4.0 24 | */ 25 | public enum GetEncoding { 26 | 27 | /** 28 | * The payload will be returned as a string if it is valid UTF-8, 29 | * and base64 encoded otherwise 30 | */ 31 | AUTO("auto"), 32 | 33 | /** 34 | * The payload will be base64 encoded 35 | */ 36 | BASE64("base64"); 37 | 38 | final String encoding; 39 | 40 | GetEncoding(String encoding) { 41 | this.encoding = encoding; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/Sample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | /** 22 | * 23 | */ 24 | public class Sample { 25 | 26 | private final long sample; 27 | private final long timestamp; 28 | 29 | public Sample(@JsonProperty("sample") long sample, 30 | @JsonProperty("timestamp") long timestamp) { 31 | this.sample = sample; 32 | this.timestamp = timestamp; 33 | } 34 | 35 | public long getSample() { 36 | return sample; 37 | } 38 | 39 | public long getTimestamp() { 40 | return timestamp; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "Sample{" + 46 | "sample=" + sample + 47 | ", timestamp=" + timestamp + 48 | '}'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/UpstreamSetDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | /** 20 | * Any of the properties from an upstream can be overridden in an upstream set. 21 | */ 22 | public class UpstreamSetDetails extends UpstreamDetails { 23 | /** 24 | * The name of an upstream. Mandatory. 25 | */ 26 | private String upstream; 27 | 28 | public String getUpstream() { 29 | return upstream; 30 | } 31 | 32 | public UpstreamSetDetails setUpstream(String upstream) { 33 | this.upstream = upstream; 34 | return this; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "UpstreamSetDetails{" + 40 | "upstream='" + upstream + '\'' + 41 | "} " + super.toString(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test against RabbitMQ stable 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-24.04 15 | 16 | steps: 17 | - uses: actions/checkout@v6 18 | - name: Set up JDK 19 | uses: actions/setup-java@v5 20 | with: 21 | distribution: 'temurin' 22 | java-version: '25' 23 | cache: 'maven' 24 | server-id: central 25 | server-username: MAVEN_USERNAME 26 | server-password: MAVEN_PASSWORD 27 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 28 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 29 | - name: Start RabbitMQ 30 | run: ci/start-broker.sh 31 | - name: Configure broker 32 | run: HOP_RABBITMQCTL=DOCKER:rabbitmq ci/before-build.sh 33 | - name: Show version 34 | run: ./mvnw --version 35 | - name: Test 36 | run: ./mvnw test --no-transfer-progress 37 | - name: Stop broker 38 | run: docker stop rabbitmq && docker rm rabbitmq 39 | - name: Publish snapshot 40 | run: ./mvnw clean deploy -Psnapshots -DskipITs -DskipTests --no-transfer-progress 41 | if: ${{ github.event_name != 'pull_request' }} 42 | env: 43 | MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 44 | MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }} 45 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 46 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/http/client/PercentEncoderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.junit.jupiter.params.ParameterizedTest; 21 | import org.junit.jupiter.params.provider.CsvSource; 22 | 23 | public class PercentEncoderTest { 24 | 25 | @ParameterizedTest 26 | @CsvSource({ 27 | "test,test", 28 | "foo bar,foo%20bar", 29 | "foo%bar,foo%25bar", 30 | "foo/bar,foo%2Fbar", 31 | "foo+bar,foo+bar", 32 | "/foo/bar,%2Ffoo%2Fbar" 33 | }) 34 | void encodePathSegmentTest(String segment, String expected) { 35 | assertThat(PercentEncoder.encodePathSegment(segment)).isEqualTo(expected); 36 | } 37 | 38 | @ParameterizedTest 39 | @CsvSource({"test,test", "foobar,foobar", "foo bar,foo%20bar", "foo&bar,foo%26bar"}) 40 | void encodeParamTest(String param, String expected) { 41 | assertThat(PercentEncoder.encodeParameter(param)).isEqualTo(expected); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/AuthMechanism.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class AuthMechanism { 21 | private String name; 22 | private String description; 23 | private boolean enabled; 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getDescription() { 34 | return description; 35 | } 36 | 37 | public void setDescription(String description) { 38 | this.description = description; 39 | } 40 | 41 | public boolean isEnabled() { 42 | return enabled; 43 | } 44 | 45 | public void setEnabled(boolean enabled) { 46 | this.enabled = enabled; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "AuthMechanism{" + 52 | "name='" + name + '\'' + 53 | ", description='" + description + '\'' + 54 | ", enabled=" + enabled + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ErlangApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class ErlangApp { 21 | private String name; 22 | private String description; 23 | private String version; 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getDescription() { 34 | return description; 35 | } 36 | 37 | public void setDescription(String description) { 38 | this.description = description; 39 | } 40 | 41 | public String getVersion() { 42 | return version; 43 | } 44 | 45 | public void setVersion(String version) { 46 | this.version = version; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "ErlangApp{" + 52 | "name='" + name + '\'' + 53 | ", description='" + description + '\'' + 54 | ", version='" + version + '\'' + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ci/before-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CTL=${HOP_RABBITMQCTL:="DOCKER:rabbitmq"} 4 | PLUGINS=${HOP_RABBITMQ_PLUGINS:="DOCKER:rabbitmq"} 5 | 6 | case $CTL in 7 | DOCKER*) 8 | PLUGINS="docker exec ${CTL##*:} rabbitmq-plugins" 9 | CTL="docker exec ${CTL##*:} rabbitmqctl";; 10 | esac 11 | 12 | $PLUGINS enable rabbitmq_management 13 | 14 | sleep 3 15 | 16 | # guest:guest has full access to / 17 | 18 | $CTL add_vhost / 19 | $CTL add_user guest guest 20 | $CTL set_permissions -p / guest ".*" ".*" ".*" 21 | $CTL set_topic_permissions -p / guest amq.topic ".*" ".*" 22 | 23 | $CTL add_vhost vh1 24 | $CTL set_permissions -p vh1 guest ".*" ".*" ".*" 25 | 26 | $CTL add_vhost vh2 27 | $CTL set_permissions -p vh2 guest ".*" ".*" ".*" 28 | 29 | # Reduce retention policy for faster publishing of stats 30 | $CTL eval 'supervisor2:terminate_child(rabbit_mgmt_sup_sup, rabbit_mgmt_sup), application:set_env(rabbitmq_management, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_sup_sup:start_child().' 31 | $CTL eval 'supervisor2:terminate_child(rabbit_mgmt_agent_sup_sup, rabbit_mgmt_agent_sup), application:set_env(rabbitmq_management_agent, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_agent_sup_sup:start_child().' 32 | 33 | # Enable shovel plugin 34 | $PLUGINS enable rabbitmq_shovel 35 | $PLUGINS enable rabbitmq_shovel_management 36 | $PLUGINS enable rabbitmq_federation 37 | $PLUGINS enable rabbitmq_federation_management 38 | 39 | # Enable mqtt plugin 40 | $PLUGINS enable rabbitmq_mqtt 41 | 42 | # So that virtual host descriptions are available 43 | $CTL enable_feature_flag all 44 | 45 | true 46 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ConnectionDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | @SuppressWarnings("unused") 22 | public class ConnectionDetails { 23 | private String name; 24 | @JsonProperty("peer_host") 25 | private String peerHost; 26 | @JsonProperty("peer_port") 27 | private int peerPort; 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getPeerHost() { 38 | return peerHost; 39 | } 40 | 41 | public void setPeerHost(String peerHost) { 42 | this.peerHost = peerHost; 43 | } 44 | 45 | public int getPeerPort() { 46 | return peerPort; 47 | } 48 | 49 | public void setPeerPort(int peerPort) { 50 | this.peerPort = peerPort; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return "ConnectionDetails{" + 56 | "name='" + name + '\'' + 57 | ", peerHost='" + peerHost + '\'' + 58 | ", peerPort=" + peerPort + 59 | '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/http/client/HttpParametersEncodingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import java.net.URI; 21 | import java.net.URISyntaxException; 22 | import java.net.URLEncoder; 23 | import java.nio.charset.StandardCharsets; 24 | import org.apache.http.client.utils.URIBuilder; 25 | import org.junit.jupiter.api.Test; 26 | 27 | public class HttpParametersEncodingTest { 28 | 29 | String queryParameterValue = "^outbound-ack|msg-.+$"; 30 | String expectedEncodedValue = "%5Eoutbound-ack%7Cmsg-.%2B%24"; 31 | 32 | @Test 33 | void uriEncodeOfSpecialCharactersWithApacheURIBuilder() throws URISyntaxException { 34 | URI uri = 35 | new URIBuilder().setPath("/exchanges").addParameter("name", queryParameterValue).build(); 36 | assertThat(uri.toASCIIString()).isEqualTo("/exchanges?name=" + expectedEncodedValue); 37 | } 38 | 39 | @Test 40 | void uriEncodeOfSpecialCharactersWithJdkUrlEncoder() { 41 | assertThat(URLEncoder.encode(queryParameterValue, StandardCharsets.UTF_8)) 42 | .isEqualTo(expectedEncodedValue); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/VhostLimits.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | /** 20 | * Virtual host limit (max queues and connections). 21 | * 22 | * @since 3.7.0 23 | */ 24 | public class VhostLimits { 25 | 26 | private final String vhost; 27 | 28 | private final int maxQueues; 29 | 30 | private final int maxConnections; 31 | 32 | public VhostLimits(String vhost, int maxQueues, int maxConnections) { 33 | this.vhost = vhost; 34 | this.maxQueues = maxQueues; 35 | this.maxConnections = maxConnections; 36 | } 37 | 38 | public String getVhost() { 39 | return vhost; 40 | } 41 | 42 | public int getMaxQueues() { 43 | return maxQueues; 44 | } 45 | 46 | public int getMaxConnections() { 47 | return maxConnections; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "VhostLimit{" + 53 | "vhost='" + vhost + '\'' + 54 | ", maxQueues=" + maxQueues + 55 | ", maxConnections=" + maxConnections + 56 | '}'; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/HttpResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | import java.util.Collections; 20 | import java.util.Map; 21 | 22 | /** 23 | * Representation of an HTTP response. 24 | * 25 | * @since 2.1.0 26 | */ 27 | public class HttpResponse { 28 | 29 | private final int status; 30 | 31 | private final String reason; 32 | 33 | private final Map headers; 34 | 35 | public HttpResponse(int status, String reason, Map headers) { 36 | this.status = status; 37 | this.reason = reason; 38 | this.headers = Collections.unmodifiableMap(headers); 39 | } 40 | 41 | public int getStatus() { 42 | return status; 43 | } 44 | 45 | public String getReason() { 46 | return reason; 47 | } 48 | 49 | public Map getHeaders() { 50 | return headers; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return "HttpResponse{" + 56 | "status=" + status + 57 | ", reason='" + reason + '\'' + 58 | ", headers=" + headers + 59 | '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/CurrentUserDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | @SuppressWarnings("unused") 25 | public class CurrentUserDetails { 26 | private String name; 27 | private List tags; 28 | 29 | public CurrentUserDetails(String name, List tags) { 30 | this.name = name; 31 | this.tags = tags; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public List getTags() { 43 | return tags; 44 | } 45 | 46 | @JsonProperty("tags") 47 | public void setTags(List tags) { 48 | this.tags = tags; 49 | } 50 | 51 | @JsonProperty("tags") 52 | public void setTags(String tags) { 53 | this.tags = Arrays.asList(tags.split(",")); 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "CurrentUserDetails{" + 59 | "name='" + name + '\'' + 60 | ", tags='" + tags + '\'' + 61 | '}'; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/DeleteQueueParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.LinkedHashMap; 20 | import java.util.Map; 21 | 22 | public class DeleteQueueParameters { 23 | private final boolean ifEmpty; 24 | private final boolean ifUnused; 25 | 26 | public DeleteQueueParameters(boolean ifEmpty, boolean ifUnused) { 27 | this.ifEmpty = ifEmpty; 28 | this.ifUnused = ifUnused; 29 | } 30 | 31 | public boolean isIfEmpty() { 32 | return ifEmpty; 33 | } 34 | 35 | public boolean isIfUnused() { 36 | return ifUnused; 37 | } 38 | 39 | public Map getAsQueryParams() { 40 | Map params = new LinkedHashMap<>(); 41 | if (ifEmpty) { 42 | params.put("if-empty", Boolean.TRUE.toString()); 43 | } 44 | if (ifUnused) { 45 | params.put("if-unused", Boolean.TRUE.toString()); 46 | } 47 | return params; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "QueueDeleteInfo{" + 53 | "ifEmpty=" + ifEmpty + 54 | ", ifUnused=" + ifUnused + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/TopicPermissions.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | /** 4 | * Represents topic permissions of a user in a vhost for a given topic exchange. 5 | * 6 | * @since 3.0.0 7 | */ 8 | public class TopicPermissions { 9 | 10 | private String user; 11 | private String vhost; 12 | private String exchange; 13 | private String read; 14 | private String write; 15 | 16 | public TopicPermissions() { 17 | 18 | } 19 | 20 | public TopicPermissions(String exchange, String read, String write) { 21 | this.exchange = exchange; 22 | this.read = read; 23 | this.write = write; 24 | } 25 | 26 | public String getUser() { 27 | return user; 28 | } 29 | 30 | public void setUser(String user) { 31 | this.user = user; 32 | } 33 | 34 | public String getVhost() { 35 | return vhost; 36 | } 37 | 38 | public void setVhost(String vhost) { 39 | this.vhost = vhost; 40 | } 41 | 42 | public String getExchange() { 43 | return exchange; 44 | } 45 | 46 | public void setExchange(String exchange) { 47 | this.exchange = exchange; 48 | } 49 | 50 | public String getRead() { 51 | return read; 52 | } 53 | 54 | public void setRead(String read) { 55 | this.read = read; 56 | } 57 | 58 | public String getWrite() { 59 | return write; 60 | } 61 | 62 | public void setWrite(String write) { 63 | this.write = write; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return "TopicPermissions{" + 69 | "user='" + user + '\'' + 70 | ", vhost='" + vhost + '\'' + 71 | ", exchange='" + exchange + '\'' + 72 | ", read='" + read + '\'' + 73 | ", write='" + write + '\'' + 74 | '}'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/GetAckMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client; 17 | 18 | /** 19 | * Acknowledgment mode when getting messages with the HTTP API. 20 | *

21 | * This determines whether the messages will be removed from the queue or not. 22 | * 23 | * @see Client#get(String, String, int, GetAckMode, GetEncoding, int) 24 | * @see ReactorNettyClient#get(String, String, int, GetAckMode, GetEncoding, int) 25 | * @since 3.4.0 26 | */ 27 | public enum GetAckMode { 28 | 29 | /** 30 | * basic.get with acknowledgment enabled, 31 | * but never acknowledges, so the message(s) will 32 | * be requeued when the internal AMQP connection is closed. 33 | */ 34 | NACK_REQUEUE_TRUE("ack_requeue_true"), 35 | 36 | /** 37 | * Reject the messages, request requeuing. 38 | */ 39 | REJECT_REQUEUE_TRUE("reject_requeue_true"), 40 | 41 | /** 42 | * Acknowledge the message, removing it from the queue. 43 | */ 44 | ACK_REQUEUE_FALSE("ack_requeue_false"), 45 | 46 | /** 47 | * Reject the message without requeuing. 48 | */ 49 | REJECT_REQUEUE_FALSE("reject_requeue_false"); 50 | 51 | final String ackMode; 52 | 53 | GetAckMode(String ackMode) { 54 | this.ackMode = ackMode; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/NetworkListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | @SuppressWarnings("unused") 22 | public class NetworkListener { 23 | @JsonProperty("ip_address") 24 | private String ipAddress; 25 | private String node; 26 | private String protocol; 27 | private int port; 28 | 29 | public String getIpAddress() { 30 | return ipAddress; 31 | } 32 | 33 | public void setIpAddress(String ipAddress) { 34 | this.ipAddress = ipAddress; 35 | } 36 | 37 | public String getNode() { 38 | return node; 39 | } 40 | 41 | public void setNode(String node) { 42 | this.node = node; 43 | } 44 | 45 | public String getProtocol() { 46 | return protocol; 47 | } 48 | 49 | public void setProtocol(String protocol) { 50 | this.protocol = protocol; 51 | } 52 | 53 | public int getPort() { 54 | return port; 55 | } 56 | 57 | public void setPort(int port) { 58 | this.port = port; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "NetworkListener{" + 64 | "ipAddress='" + ipAddress + '\'' + 65 | ", node='" + node + '\'' + 66 | ", protocol='" + protocol + '\'' + 67 | ", port=" + port + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/AppTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq; 17 | 18 | import static com.rabbitmq.http.client.JdkHttpClientHttpLayer.authorization; 19 | 20 | import com.rabbitmq.http.client.Client; 21 | import com.rabbitmq.http.client.ClientParameters; 22 | import com.rabbitmq.http.client.HttpLayer.HttpLayerFactory; 23 | import com.rabbitmq.http.client.JdkHttpClientHttpLayer; 24 | import java.time.Duration; 25 | import org.junit.jupiter.api.Test; 26 | 27 | public class AppTest { 28 | 29 | @Test 30 | void createUseClient() throws Exception { 31 | HttpLayerFactory httpLayerFactory = 32 | JdkHttpClientHttpLayer.configure() 33 | .clientBuilderConsumer( 34 | clientBuilder -> clientBuilder.connectTimeout(Duration.ofSeconds(10))) 35 | .requestBuilderConsumer( 36 | requestBuilder -> 37 | requestBuilder 38 | .timeout(Duration.ofSeconds(10)) 39 | .setHeader("Authorization", authorization("guest", "guest"))) 40 | .create(); 41 | 42 | Client c = 43 | new Client( 44 | new ClientParameters() 45 | .url("http://127.0.0.1:15672/api/") 46 | .username("guest") 47 | .password("guest") 48 | .httpLayerFactory(httpLayerFactory)); 49 | 50 | c.getOverview(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/PluginContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class PluginContext { 21 | private String node; 22 | private String description; 23 | private String path; 24 | private int port; 25 | private boolean ssl; 26 | 27 | public String getNode() { 28 | return node; 29 | } 30 | 31 | public void setNode(String node) { 32 | this.node = node; 33 | } 34 | 35 | public String getDescription() { 36 | return description; 37 | } 38 | 39 | public void setDescription(String description) { 40 | this.description = description; 41 | } 42 | 43 | public String getPath() { 44 | return path; 45 | } 46 | 47 | public void setPath(String path) { 48 | this.path = path; 49 | } 50 | 51 | public int getPort() { 52 | return port; 53 | } 54 | 55 | public void setPort(int port) { 56 | this.port = port; 57 | } 58 | 59 | public boolean isSsl() { 60 | return ssl; 61 | } 62 | 63 | public void setSsl(boolean ssl) { 64 | this.ssl = ssl; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return "PluginContext{" + 70 | "node='" + node + '\'' + 71 | ", description='" + description + '\'' + 72 | ", path='" + path + '\'' + 73 | ", port=" + port + 74 | '}'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/RuntimeParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | @JsonInclude(JsonInclude.Include.NON_NULL) 22 | public class RuntimeParameter { 23 | private String name; 24 | private String vhost; 25 | private String component; 26 | private T value; 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getVhost() { 37 | return vhost; 38 | } 39 | 40 | public void setVhost(String vhost) { 41 | this.vhost = vhost; 42 | } 43 | 44 | public String getComponent() { 45 | return component; 46 | } 47 | 48 | public void setComponent(String component) { 49 | this.component = component; 50 | } 51 | 52 | public T getValue() { 53 | return value; 54 | } 55 | 56 | public void setValue(T value) { 57 | this.value = value; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "RuntimeParameter{" + 63 | "name='" + name + '\'' + 64 | ", vhost='" + vhost + '\'' + 65 | ", component='" + component + '\'' + 66 | ", value=" + value + 67 | '}'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ExchangeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | public class ExchangeType { 22 | private String name; 23 | private String description; 24 | @JsonProperty("internal_purpose") 25 | private String internalPurpose; 26 | private boolean enabled; 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getDescription() { 37 | return description; 38 | } 39 | 40 | public void setDescription(String description) { 41 | this.description = description; 42 | } 43 | 44 | public String getInternalPurpose() { 45 | return internalPurpose; 46 | } 47 | 48 | public void setInternalPurpose(String internalPurpose) { 49 | this.internalPurpose = internalPurpose; 50 | } 51 | 52 | public boolean isEnabled() { 53 | return enabled; 54 | } 55 | 56 | public void setEnabled(boolean enabled) { 57 | this.enabled = enabled; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "ExchangeType{" + 63 | "name='" + name + '\'' + 64 | ", description='" + description + '\'' + 65 | ", internalPurpose='" + internalPurpose + '\'' + 66 | ", enabled=" + enabled + 67 | '}'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/RateDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | public class RateDetails { 25 | private final double average; 26 | private final double averageRate; 27 | private final double rate; 28 | private final List samples; 29 | 30 | public RateDetails(double rate) { 31 | this(0, 0, rate, Collections.emptyList()); 32 | } 33 | 34 | public RateDetails( 35 | @JsonProperty("avg") double average, 36 | @JsonProperty("avg_rate") double averageRate, 37 | @JsonProperty("rate") double rate, 38 | @JsonProperty("samples") List samples 39 | ) { 40 | this.average = average; 41 | this.averageRate = averageRate; 42 | this.rate = rate; 43 | this.samples = samples; 44 | } 45 | 46 | public double getAverage() { 47 | return average; 48 | } 49 | 50 | public double getAverageRate() { 51 | return averageRate; 52 | } 53 | 54 | public double getRate() { 55 | return rate; 56 | } 57 | 58 | public List getSamples() { 59 | return samples; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "RateDetails{" + 65 | "average=" + average + 66 | ", averageRate=" + averageRate + 67 | ", rate=" + rate + 68 | ", samples=" + samples + 69 | '}'; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ObjectTotals.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class ObjectTotals { 21 | private long connections; 22 | private long channels; 23 | private long exchanges; 24 | private long queues; 25 | private long consumers; 26 | 27 | public long getConnections() { 28 | return connections; 29 | } 30 | 31 | public void setConnections(long connections) { 32 | this.connections = connections; 33 | } 34 | 35 | public long getChannels() { 36 | return channels; 37 | } 38 | 39 | public void setChannels(long channels) { 40 | this.channels = channels; 41 | } 42 | 43 | public long getExchanges() { 44 | return exchanges; 45 | } 46 | 47 | public void setExchanges(long exchanges) { 48 | this.exchanges = exchanges; 49 | } 50 | 51 | public long getQueues() { 52 | return queues; 53 | } 54 | 55 | public void setQueues(long queues) { 56 | this.queues = queues; 57 | } 58 | 59 | public long getConsumers() { 60 | return consumers; 61 | } 62 | 63 | public void setConsumers(long consumers) { 64 | this.consumers = consumers; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return "ObjectTotals{" + 70 | "connections=" + connections + 71 | ", channels=" + channels + 72 | ", exchanges=" + exchanges + 73 | ", queues=" + queues + 74 | ", consumers=" + consumers + 75 | '}'; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/PolicyInfo.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | import java.util.Map; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | public class PolicyInfo { 8 | private String name; 9 | private String vhost; 10 | private String pattern; 11 | private Map definition; 12 | private int priority; 13 | @JsonProperty("apply-to") 14 | private String applyTo; 15 | 16 | public PolicyInfo() { 17 | } 18 | 19 | public PolicyInfo(String pattern, int priority, String applyTo, Map definition) { 20 | this.pattern = pattern; 21 | this.priority = priority; 22 | this.applyTo = applyTo; 23 | this.definition = definition; 24 | } 25 | 26 | public String getVhost() { 27 | return vhost; 28 | } 29 | 30 | public void setVhost(String vhost) { 31 | this.vhost = vhost; 32 | } 33 | 34 | public String getPattern() { 35 | return pattern; 36 | } 37 | 38 | public void setPattern(String pattern) { 39 | this.pattern = pattern; 40 | } 41 | 42 | public Map getDefinition() { 43 | return definition; 44 | } 45 | 46 | public void setDefinition(Map definition) { 47 | this.definition = definition; 48 | } 49 | 50 | public int getPriority() { 51 | return priority; 52 | } 53 | 54 | public void setPriority(int priority) { 55 | this.priority = priority; 56 | } 57 | 58 | public String getApplyTo() { 59 | return applyTo; 60 | } 61 | 62 | public void setApplyTo(String applyTo) { 63 | this.applyTo = applyTo; 64 | } 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | public void setName(String name) { 71 | this.name = name; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "PolicyInfo{" + 77 | "name='" + name + '\'' + 78 | ", vhost='" + vhost + '\'' + 79 | ", pattern='" + pattern + '\'' + 80 | ", definition=" + definition + 81 | ", priority=" + priority + 82 | ", applyTo='" + applyTo + '\'' + 83 | '}'; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/OutboundMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Collections; 20 | import java.util.Map; 21 | 22 | /** 23 | * Representation for an outbound message. 24 | * 25 | * @see com.rabbitmq.http.client.Client#publish(String, String, String, OutboundMessage) 26 | * @see com.rabbitmq.http.client.ReactorNettyClient#publish(String, String, String, OutboundMessage) 27 | * @since 3.4.0 28 | */ 29 | public class OutboundMessage { 30 | 31 | private static final String PAYLOAD_UTF8 = "string"; 32 | private static final String PAYLOAD_BASE64 = "base64"; 33 | 34 | private String payload; 35 | private Map properties = Collections.emptyMap(); 36 | private String payloadEncoding = PAYLOAD_UTF8; 37 | 38 | public OutboundMessage payload(String payload) { 39 | this.payload = payload; 40 | return this; 41 | } 42 | 43 | public OutboundMessage properties(Map properties) { 44 | this.properties = properties; 45 | return this; 46 | } 47 | 48 | public OutboundMessage utf8Encoded() { 49 | this.payloadEncoding = PAYLOAD_UTF8; 50 | return this; 51 | } 52 | 53 | public OutboundMessage base64Encoded() { 54 | this.payloadEncoding = PAYLOAD_BASE64; 55 | return this; 56 | } 57 | 58 | public String getPayload() { 59 | return payload; 60 | } 61 | 62 | public Map getProperties() { 63 | return properties; 64 | } 65 | 66 | public String getPayloadEncoding() { 67 | return payloadEncoding; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/http/client/domain/PageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client.domain; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 20 | import static org.junit.jupiter.api.Assertions.assertNotNull; 21 | import static org.junit.jupiter.api.Assertions.assertThrows; 22 | import static org.junit.jupiter.api.Assertions.assertTrue; 23 | 24 | import java.util.Arrays; 25 | import java.util.List; 26 | import org.junit.jupiter.api.Test; 27 | 28 | public class PageTest { 29 | 30 | @Test 31 | void itemsAsList() { 32 | String[] items = new String[] {"a", "b", "c"}; 33 | Page page = new Page<>(items); 34 | List itemsAsList = page.getItemsAsList(); 35 | assertNotNull(itemsAsList); 36 | assertThat(itemsAsList).hasSize(3); 37 | assertTrue(Arrays.equals(items, itemsAsList.toArray())); 38 | } 39 | 40 | @Test 41 | void itemsAsListWithNullArrayReturnsEmptyList() { 42 | Page page = new Page<>(null); 43 | List itemsAsList = assertDoesNotThrow(() -> page.getItemsAsList()); 44 | assertNotNull(itemsAsList); 45 | assertThat(itemsAsList).isEmpty(); 46 | } 47 | 48 | @Test 49 | void itemsAsListReturnsUnmodifiableList() { 50 | String[] items = new String[] {"a", "b", "c"}; 51 | Page page = new Page<>(items); 52 | List itemsAsList = page.getItemsAsList(); 53 | assertThrows(UnsupportedOperationException.class, () -> itemsAsList.add("d")); 54 | 55 | page = new Page<>(null); 56 | List nullItemsAsList = page.getItemsAsList(); 57 | assertThrows(UnsupportedOperationException.class, () -> nullItemsAsList.add("a")); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/Page.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Arrays; 20 | import java.util.Collections; 21 | import java.util.List; 22 | 23 | import com.fasterxml.jackson.annotation.JsonProperty; 24 | 25 | public class Page { 26 | 27 | private T[] items; 28 | 29 | @JsonProperty("filtered_count") 30 | private int filteredCount; 31 | 32 | @JsonProperty("item_count") 33 | private int itemCount; 34 | 35 | private int page; 36 | 37 | @JsonProperty("page_count") 38 | private int pageCount; 39 | 40 | @JsonProperty("page_size") 41 | private int pageSize; 42 | 43 | @JsonProperty("total_count") 44 | private int totalCount; 45 | 46 | public Page() {} 47 | 48 | public Page(T[] items) { 49 | int totalItems = items != null ? items.length : 0; 50 | this.items = items; 51 | itemCount = totalItems; 52 | totalCount = totalItems; 53 | pageCount = 1; 54 | page = 1; 55 | pageSize = totalItems; 56 | filteredCount = totalItems; 57 | } 58 | 59 | public T[] getItems() { 60 | return items; 61 | } 62 | 63 | public void setItems(T[] items) { 64 | this.items = items; 65 | } 66 | 67 | public List getItemsAsList() { 68 | return items != null ? Arrays.asList(items) : Collections.emptyList(); 69 | } 70 | 71 | public int getFilteredCount() { 72 | return filteredCount; 73 | } 74 | 75 | public int getItemCount() { 76 | return itemCount; 77 | } 78 | 79 | public int getPage() { 80 | return page; 81 | } 82 | 83 | public int getPageCount() { 84 | return pageCount; 85 | } 86 | 87 | public int getPageSize() { 88 | return pageSize; 89 | } 90 | 91 | public int getTotalCount() { 92 | return totalCount; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/AckMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Arrays; 20 | 21 | import com.fasterxml.jackson.annotation.JsonCreator; 22 | import com.fasterxml.jackson.annotation.JsonValue; 23 | 24 | public enum AckMode { 25 | /** 26 | * Consumes in manual acknowledgement mode. 27 | * Messages are acknowledged to the upstream broker after they have been confirmed downstream. 28 | *

29 | * This is the safest option that offers lowest throughput. 30 | * 31 | * @see Confirms 32 | */ 33 | ON_CONFIRM("on-confirm"), 34 | 35 | /** 36 | * Consumes in manual acknowledgement mode. 37 | * Messages are acknowledged to the upstream broker after they have been published downstream 38 | * without waiting for publisher confirms. In other words, this uses fire-and-forget publishing. 39 | *

40 | * This is a moderately safe safe option that does not handle downstream node failures. 41 | * 42 | * @see Confirms 43 | */ 44 | ON_PUBLISH("on-publish"), 45 | 46 | /** 47 | * Consumes in automatic acknowledgement mode. 48 | *

49 | * Unsafe, offers best throughput. 50 | * 51 | * @see Confirms 52 | */ 53 | AUTOMATIC("no-ack"); 54 | 55 | private final String value; 56 | 57 | AckMode(String value) { 58 | this.value = value; 59 | } 60 | 61 | @JsonCreator 62 | static AckMode fromValue(String value) { 63 | return Arrays.stream(AckMode.values()).filter(e -> e.value.equals(value)).findFirst().get(); 64 | } 65 | 66 | @JsonValue 67 | public String toValue() { 68 | return value; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/UserInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | public class UserInfo { 25 | private String name; 26 | @JsonProperty("password_hash") 27 | private String passwordHash; 28 | @JsonProperty("hashing_algorithm") 29 | private String hashingAlgorithm; 30 | private List tags; 31 | 32 | public UserInfo(String name, String passwordHash, String hashingAlgorithm, List tags) { 33 | this.name = name; 34 | this.passwordHash = passwordHash; 35 | this.hashingAlgorithm = hashingAlgorithm; 36 | this.tags = tags; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public void setName(String name) { 44 | this.name = name; 45 | } 46 | 47 | public String getHashingAlgorithm() { 48 | return hashingAlgorithm; 49 | } 50 | 51 | public void setHashingAlgorithm(String hashingAlgorithm) { 52 | this.hashingAlgorithm = hashingAlgorithm; 53 | } 54 | 55 | public String getPasswordHash() { 56 | return passwordHash; 57 | } 58 | 59 | public void setPasswordHash(String passwordHash) { 60 | this.passwordHash = passwordHash; 61 | } 62 | 63 | public List getTags() { 64 | return tags; 65 | } 66 | 67 | @JsonProperty("tags") 68 | public void setTags(List tags) { 69 | this.tags = tags; 70 | } 71 | 72 | @JsonProperty("tags") 73 | public void setTags(String tags) { 74 | this.tags = Arrays.asList(tags.split(",")); 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "UserInfo{" + 80 | "name='" + name + '\'' + 81 | ", passwordHash='" + passwordHash + '\'' + 82 | ", tags=" + tags + 83 | '}'; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ChannelDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | @SuppressWarnings("unused") 20 | public class ChannelDetails { 21 | private String connectionName; 22 | private String name; 23 | private String node; 24 | private int number; 25 | private String peerHost; 26 | private int peerPort; 27 | private String user; 28 | 29 | public String getConnectionName() { 30 | return connectionName; 31 | } 32 | 33 | public void setConnectionName(String connectionName) { 34 | this.connectionName = connectionName; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public String getNode() { 46 | return node; 47 | } 48 | 49 | public void setNode(String node) { 50 | this.node = node; 51 | } 52 | 53 | public int getNumber() { 54 | return number; 55 | } 56 | 57 | public void setNumber(int number) { 58 | this.number = number; 59 | } 60 | 61 | public String getPeerHost() { 62 | return peerHost; 63 | } 64 | 65 | public void setPeerHost(String peerHost) { 66 | this.peerHost = peerHost; 67 | } 68 | 69 | public int getPeerPort() { 70 | return peerPort; 71 | } 72 | 73 | public void setPeerPort(int peerPort) { 74 | this.peerPort = peerPort; 75 | } 76 | 77 | public String getUser() { 78 | return user; 79 | } 80 | 81 | public void setUser(String user) { 82 | this.user = user; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "ChannelDetails{" + 88 | "connectionName='" + connectionName + '\'' + 89 | ", name='" + name + '\'' + 90 | ", node='" + node + '\'' + 91 | ", number=" + number + 92 | ", peerHost='" + peerHost + '\'' + 93 | ", peerPort=" + peerPort + 94 | ", user='" + user + '\'' + 95 | '}'; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ShovelInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | // { 22 | // "value": { 23 | // "src-uri": "", 24 | // "src-exchange": "", 25 | // "src-queue": "", 26 | // "dest-uri": "", 27 | // "dest-exchange": "", 28 | // "dest-queue": "", 29 | // "reconnect-delay": 0, 30 | // "add-forward-headers": true, 31 | // "publish-properties": { 32 | // } 33 | // }, 34 | // "vhost": "", 35 | // "component": "shovel", 36 | // "name": "" 37 | // } 38 | 39 | public class ShovelInfo { 40 | 41 | private String name; 42 | @JsonProperty("vhost") 43 | private String virtualHost; 44 | private String component; 45 | @JsonProperty("value") 46 | private ShovelDetails details; 47 | 48 | public ShovelInfo() { 49 | } 50 | 51 | public ShovelInfo(String name, ShovelDetails details) { 52 | this.name = name; 53 | this.details = details; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | 64 | public String getVirtualHost() { 65 | return virtualHost; 66 | } 67 | 68 | public void setVirtualHost(String virtualHost) { 69 | this.virtualHost = virtualHost; 70 | } 71 | 72 | public String getComponent() { 73 | return component; 74 | } 75 | 76 | public void setComponent(String component) { 77 | this.component = component; 78 | } 79 | 80 | public ShovelDetails getDetails() { 81 | return details; 82 | } 83 | 84 | public void setDetails(ShovelDetails details) { 85 | this.details = details; 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "ShovelInfo{" + "name='" + name + "\', " + "virtualHost='" + virtualHost + "\', " + "component='" + component + '\'' + ", details=" + details 91 | + '}'; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/UserPermissions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | /** 20 | * Represents permissions of a user in a vhost. 21 | */ 22 | public class UserPermissions { 23 | private String user; 24 | private String vhost; 25 | private String read; 26 | private String write; 27 | private String configure; 28 | 29 | public UserPermissions() {} 30 | public UserPermissions(String read, String write, String configure) { 31 | this.read = read; 32 | this.write = write; 33 | this.configure = configure; 34 | } 35 | 36 | public String getUser() { 37 | return user; 38 | } 39 | 40 | public void setUser(String user) { 41 | this.user = user; 42 | } 43 | 44 | public String getVhost() { 45 | return vhost; 46 | } 47 | 48 | public void setVhost(String vhost) { 49 | this.vhost = vhost; 50 | } 51 | 52 | public String getRead() { 53 | return read; 54 | } 55 | 56 | public void setRead(String read) { 57 | this.read = read; 58 | } 59 | 60 | public String getWrite() { 61 | return write; 62 | } 63 | 64 | public void setWrite(String write) { 65 | this.write = write; 66 | } 67 | 68 | public String getConfigure() { 69 | return configure; 70 | } 71 | 72 | public void setConfigure(String configure) { 73 | this.configure = configure; 74 | } 75 | 76 | public static UserPermissions FULL = fullPermissions(); 77 | 78 | private static UserPermissions fullPermissions() { 79 | UserPermissions p = new UserPermissions(); 80 | p.setConfigure(".*"); 81 | p.setRead(".*"); 82 | p.setWrite(".*"); 83 | return p; 84 | } 85 | 86 | @Override 87 | public String toString() { 88 | return "UserPermissions{" + 89 | "user='" + user + '\'' + 90 | ", vhost='" + vhost + '\'' + 91 | ", read='" + read + '\'' + 92 | ", write='" + write + '\'' + 93 | ", configure='" + configure + '\'' + 94 | '}'; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/PercentEncoder.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.CharBuffer; 5 | import java.nio.charset.StandardCharsets; 6 | import java.util.BitSet; 7 | 8 | final class PercentEncoder { 9 | 10 | // based on Apache HttpComponents PercentCodec 11 | 12 | private PercentEncoder() {} 13 | 14 | static final BitSet SUB_DELIMS = new BitSet(256); 15 | static final BitSet UNRESERVED = new BitSet(256); 16 | static final BitSet PCHAR = new BitSet(256); 17 | static final BitSet QUERY_PARAM = new BitSet(256); 18 | private static final int RADIX = 16; 19 | 20 | static { 21 | SUB_DELIMS.set('!'); 22 | SUB_DELIMS.set('$'); 23 | SUB_DELIMS.set('&'); 24 | SUB_DELIMS.set('\''); 25 | SUB_DELIMS.set('('); 26 | SUB_DELIMS.set(')'); 27 | SUB_DELIMS.set('*'); 28 | SUB_DELIMS.set('+'); 29 | SUB_DELIMS.set(','); 30 | SUB_DELIMS.set(';'); 31 | SUB_DELIMS.set('='); 32 | 33 | for (int i = 'a'; i <= 'z'; i++) { 34 | UNRESERVED.set(i); 35 | } 36 | for (int i = 'A'; i <= 'Z'; i++) { 37 | UNRESERVED.set(i); 38 | } 39 | // numeric characters 40 | for (int i = '0'; i <= '9'; i++) { 41 | UNRESERVED.set(i); 42 | } 43 | UNRESERVED.set('-'); 44 | UNRESERVED.set('.'); 45 | UNRESERVED.set('_'); 46 | UNRESERVED.set('~'); 47 | PCHAR.or(UNRESERVED); 48 | PCHAR.or(SUB_DELIMS); 49 | PCHAR.set(':'); 50 | PCHAR.set('@'); 51 | 52 | QUERY_PARAM.or(PCHAR); 53 | QUERY_PARAM.set('/'); 54 | QUERY_PARAM.set('?'); 55 | QUERY_PARAM.clear('='); 56 | QUERY_PARAM.clear('&'); 57 | } 58 | 59 | static String encodePathSegment(String segment) { 60 | return encode(segment, PCHAR); 61 | } 62 | 63 | static String encodeParameter(String value) { 64 | return encode(value, QUERY_PARAM); 65 | } 66 | 67 | private static String encode(String value, BitSet safeCharacters) { 68 | if (value == null) { 69 | return null; 70 | } 71 | StringBuilder buf = new StringBuilder(); 72 | final CharBuffer cb = CharBuffer.wrap(value); 73 | final ByteBuffer bb = StandardCharsets.UTF_8.encode(cb); 74 | while (bb.hasRemaining()) { 75 | final int b = bb.get() & 0xff; 76 | if (safeCharacters.get(b)) { 77 | buf.append((char) b); 78 | } else { 79 | buf.append("%"); 80 | final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); 81 | final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); 82 | buf.append(hex1); 83 | buf.append(hex2); 84 | } 85 | } 86 | return buf.toString(); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/InboundMessage.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.http.client.domain; 2 | 3 | import java.util.Map; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | /** 8 | * POJO for messages consumed from the HTTP API. 9 | * 10 | * @since 3.4.0 11 | */ 12 | public class InboundMessage { 13 | 14 | @JsonProperty("payload_bytes") 15 | private int payloadBytes; 16 | 17 | private boolean redelivered; 18 | 19 | @JsonProperty("routing_key") 20 | private String routingKey; 21 | 22 | @JsonProperty("message_count") 23 | private int messageCount; 24 | 25 | private Map properties; 26 | 27 | private String payload; 28 | 29 | @JsonProperty("payload_encoding") 30 | private String payloadEncoding; 31 | 32 | public int getPayloadBytes() { 33 | return payloadBytes; 34 | } 35 | 36 | public void setPayloadBytes(int payloadBytes) { 37 | this.payloadBytes = payloadBytes; 38 | } 39 | 40 | public boolean isRedelivered() { 41 | return redelivered; 42 | } 43 | 44 | public void setRedelivered(boolean redelivered) { 45 | this.redelivered = redelivered; 46 | } 47 | 48 | public String getRoutingKey() { 49 | return routingKey; 50 | } 51 | 52 | public void setRoutingKey(String routingKey) { 53 | this.routingKey = routingKey; 54 | } 55 | 56 | public int getMessageCount() { 57 | return messageCount; 58 | } 59 | 60 | public void setMessageCount(int messageCount) { 61 | this.messageCount = messageCount; 62 | } 63 | 64 | public Map getProperties() { 65 | return properties; 66 | } 67 | 68 | public void setProperties(Map properties) { 69 | this.properties = properties; 70 | } 71 | 72 | public String getPayload() { 73 | return payload; 74 | } 75 | 76 | public void setPayload(String payload) { 77 | this.payload = payload; 78 | } 79 | 80 | public String getPayloadEncoding() { 81 | return payloadEncoding; 82 | } 83 | 84 | public void setPayloadEncoding(String payloadEncoding) { 85 | this.payloadEncoding = payloadEncoding; 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "InboundMessage{" + 91 | "payloadBytes=" + payloadBytes + 92 | ", redelivered=" + redelivered + 93 | ", routingKey='" + routingKey + '\'' + 94 | ", messageCount=" + messageCount + 95 | ", properties=" + properties + 96 | ", payload='" + payload + '\'' + 97 | ", payloadEncoding='" + payloadEncoding + '\'' + 98 | '}'; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/http/client/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client; 17 | 18 | abstract class TestUtils { 19 | 20 | private TestUtils() {} 21 | 22 | /** 23 | * https://stackoverflow.com/questions/6701948/efficient-way-to-compare-version-strings-in-java 24 | */ 25 | static Integer compareVersions(String str1, String str2) { 26 | String[] vals1 = str1.split("\\."); 27 | String[] vals2 = str2.split("\\."); 28 | int i = 0; 29 | // set index to first non-equal ordinal or length of shortest version string 30 | while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { 31 | i++; 32 | } 33 | // compare first non-equal ordinal number 34 | if (i < vals1.length && i < vals2.length) { 35 | if (vals1[i].indexOf('-') != -1) { 36 | vals1[i] = vals1[i].substring(0, vals1[i].indexOf('-')); 37 | } 38 | if (vals2[i].indexOf('-') != -1) { 39 | vals2[i] = vals2[i].substring(0, vals2[i].indexOf('-')); 40 | } 41 | int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])); 42 | return Integer.signum(diff); 43 | } 44 | // the strings are equal or one string is a substring of the other 45 | // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4" 46 | else { 47 | return Integer.signum(vals1.length - vals2.length); 48 | } 49 | } 50 | 51 | static boolean isVersion36orLater(String currentVersion) { 52 | return checkVersionOrLater(currentVersion, "3.6.0"); 53 | } 54 | 55 | static boolean isVersion37orLater(String currentVersion) { 56 | return checkVersionOrLater(currentVersion, "3.7.0"); 57 | } 58 | 59 | static boolean isVersion38orLater(String currentVersion) { 60 | return checkVersionOrLater(currentVersion, "3.8.0"); 61 | } 62 | 63 | static boolean isVersion310orLater(String currentVersion) { 64 | return checkVersionOrLater(currentVersion, "3.10.0"); 65 | } 66 | 67 | private static boolean checkVersionOrLater(String currentVersion, String expectedVersion) { 68 | String v = currentVersion.replaceAll("\\+.*$", ""); 69 | try { 70 | return v.equals("0.0.0") || compareVersions(v, expectedVersion) >= 0; 71 | } catch (Exception e) { 72 | return false; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/HttpLayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | import java.net.URI; 20 | import java.util.Map; 21 | 22 | /** 23 | * HTTP layer abstraction for {@link Client}. 24 | * 25 | *

This is considered a SPI and is susceptible to change at any time. 26 | * 27 | *

Use the {@link JdkHttpClientHttpLayer#configure()} to configure and create the default implementation. 28 | * 29 | * @since 4.0.0 30 | */ 31 | public interface HttpLayer { 32 | 33 | /** 34 | * GET operation when the expected class does not use generics. 35 | * 36 | * @param uri 37 | * @param responseClass 38 | * @param 39 | * @return 40 | */ 41 | T get(URI uri, Class responseClass); 42 | 43 | /** 44 | * Get operation when the expected class uses generics, like List<T> or 45 | * Page<T>. 46 | * 47 | * @param uri 48 | * @param typeReference 49 | * @param 50 | * @return 51 | */ 52 | T get(URI uri, ParameterizedTypeReference typeReference); 53 | 54 | /** 55 | * POST operation. 56 | * 57 | *

Response class is optional. 58 | * 59 | * @param uri 60 | * @param requestBody 61 | * @param responseClass 62 | * @param 63 | * @return 64 | */ 65 | T post(URI uri, Object requestBody, Class responseClass); 66 | 67 | /** 68 | * PUT operation. 69 | * 70 | * @param uri 71 | * @param requestBody 72 | */ 73 | void put(URI uri, Object requestBody); 74 | 75 | /** 76 | * DELETE operation. 77 | * 78 | * @param uri 79 | * @param headers 80 | */ 81 | void delete(URI uri, Map headers); 82 | 83 | /** 84 | * Contract to create the {@link HttpLayer}. 85 | * 86 | *

The {@link HttpLayer} usually requires credentials (username, password) that are available 87 | * once the {@link ClientParameters} instance is created. This explains the need for a factory 88 | * mechanism. 89 | * 90 | * @since 4.0.0 91 | */ 92 | @FunctionalInterface 93 | interface HttpLayerFactory { 94 | 95 | HttpLayer create(ClientParameters parameters); 96 | 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ExchangeMessageStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | public class ExchangeMessageStats { 22 | @JsonProperty("publish_in") 23 | private long publishIn; 24 | @JsonProperty("publish_in_details") 25 | private RateDetails publishInDetails; 26 | @JsonProperty("publish_out") 27 | private long publishOut; 28 | @JsonProperty("publish_out_details") 29 | private RateDetails publishOutDetails; 30 | 31 | @JsonProperty("confirm") 32 | private long confirm; 33 | @JsonProperty("confirm_details") 34 | private RateDetails confirmDetails; 35 | 36 | public long getPublishIn() { 37 | return publishIn; 38 | } 39 | 40 | public void setPublishIn(long publishIn) { 41 | this.publishIn = publishIn; 42 | } 43 | 44 | public RateDetails getPublishInDetails() { 45 | return publishInDetails; 46 | } 47 | 48 | public void setPublishInDetails(RateDetails publishInDetails) { 49 | this.publishInDetails = publishInDetails; 50 | } 51 | 52 | public long getPublishOut() { 53 | return publishOut; 54 | } 55 | 56 | public void setPublishOut(long publishOut) { 57 | this.publishOut = publishOut; 58 | } 59 | 60 | public RateDetails getPublishOutDetails() { 61 | return publishOutDetails; 62 | } 63 | 64 | public void setPublishOutDetails(RateDetails publishOutDetails) { 65 | this.publishOutDetails = publishOutDetails; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "ExchangeMessageStats{" + 71 | "publishIn=" + publishIn + 72 | ", publishInDetails=" + publishInDetails + 73 | ", publishOut=" + publishOut + 74 | ", publishOutDetails=" + publishOutDetails + 75 | ", confirm=" + confirm + 76 | ", confirmDetails=" + confirmDetails + 77 | '}'; 78 | } 79 | 80 | public long getConfirm() { 81 | return confirm; 82 | } 83 | 84 | public void setConfirm(long confirm) { 85 | this.confirm = confirm; 86 | } 87 | 88 | public RateDetails getConfirmDetails() { 89 | return confirmDetails; 90 | } 91 | 92 | public void setConfirmDetails(RateDetails confirmDetails) { 93 | this.confirmDetails = confirmDetails; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ClientProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Map; 20 | 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | @SuppressWarnings("unused") 24 | public class ClientProperties { 25 | private Map capabilities; 26 | private String product; 27 | private String platform; 28 | private String version; 29 | private String information; 30 | private String copyright; 31 | @JsonProperty("connection_name") 32 | private String connectionName; 33 | 34 | public Map getCapabilities() { 35 | return capabilities; 36 | } 37 | 38 | public void setCapabilities(Map capabilities) { 39 | this.capabilities = capabilities; 40 | } 41 | 42 | public String getProduct() { 43 | return product; 44 | } 45 | 46 | public void setProduct(String product) { 47 | this.product = product; 48 | } 49 | 50 | public String getPlatform() { 51 | return platform; 52 | } 53 | 54 | public void setPlatform(String platform) { 55 | this.platform = platform; 56 | } 57 | 58 | public String getVersion() { 59 | return version; 60 | } 61 | 62 | public void setVersion(String version) { 63 | this.version = version; 64 | } 65 | 66 | public String getInformation() { 67 | return information; 68 | } 69 | 70 | public void setInformation(String information) { 71 | this.information = information; 72 | } 73 | 74 | public String getCopyright() { 75 | return copyright; 76 | } 77 | 78 | public void setCopyright(String copyright) { 79 | this.copyright = copyright; 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | return "ClientProperties{" + 85 | "capabilities=" + capabilities + 86 | ", product='" + product + '\'' + 87 | ", platform='" + platform + '\'' + 88 | ", version='" + version + '\'' + 89 | ", connectionName='" + connectionName + '\'' + 90 | ", information='" + information + '\'' + 91 | ", copyright='" + copyright + '\'' + '}'; 92 | } 93 | 94 | public String getConnectionName() { 95 | return connectionName; 96 | } 97 | 98 | public void setConnectionName(String connectionName) { 99 | this.connectionName = connectionName; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/ReactorNettyClientOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | import java.util.function.BiConsumer; 20 | import java.util.function.Supplier; 21 | 22 | import com.fasterxml.jackson.databind.ObjectMapper; 23 | 24 | import io.netty.buffer.ByteBuf; 25 | import reactor.core.publisher.Mono; 26 | import reactor.netty.http.client.HttpClient; 27 | 28 | /** 29 | * Options for {@link ReactorNettyClient}. 30 | * An instance of this class can be passed in to {@link ReactorNettyClient} 31 | * constructor for settings like Jackson JSON object mapper, authentication, 32 | * TLS, error handling. 33 | * 34 | * @see ReactorNettyClient 35 | * @since 2.1.0 36 | */ 37 | public class ReactorNettyClientOptions { 38 | 39 | private Supplier client; 40 | 41 | private Supplier objectMapper; 42 | 43 | private Mono token; 44 | 45 | private BiConsumer onResponseCallback; 46 | 47 | private Supplier byteBufSupplier; 48 | 49 | public Supplier objectMapper() { 50 | return objectMapper; 51 | } 52 | 53 | public ReactorNettyClientOptions objectMapper(Supplier objectMapper) { 54 | this.objectMapper = objectMapper; 55 | return this; 56 | } 57 | 58 | public Mono token() { 59 | return token; 60 | } 61 | 62 | public ReactorNettyClientOptions token(Mono token) { 63 | this.token = token; 64 | return this; 65 | } 66 | 67 | public ReactorNettyClientOptions onResponseCallback( 68 | BiConsumer onResponseCallback) { 69 | this.onResponseCallback = onResponseCallback; 70 | return this; 71 | } 72 | 73 | public BiConsumer onResponseCallback() { 74 | return onResponseCallback; 75 | } 76 | 77 | public Supplier client() { 78 | return client; 79 | } 80 | 81 | public ReactorNettyClientOptions client(Supplier client) { 82 | this.client = client; 83 | return this; 84 | } 85 | 86 | public ReactorNettyClientOptions byteBufSupplier(Supplier byteBufSupplier) { 87 | this.byteBufSupplier = byteBufSupplier; 88 | return this; 89 | } 90 | 91 | public Supplier byteBufSupplier() { 92 | return this.byteBufSupplier; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ShovelDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | //{"src-uri": "amqp://", "src-queue": "my-queue", 22 | // "dest-uri": "amqp://remote-server", "dest-queue": "another-queue"} 23 | 24 | public class ShovelDefinition { 25 | 26 | @JsonProperty("src-exchange") 27 | private String sourceExchange; 28 | @JsonProperty("src-exchange-key") 29 | private String sourceExchangeKey; 30 | @JsonProperty("src-queue") 31 | private String sourceQueue; 32 | 33 | @JsonProperty("dest-exchange") 34 | private String destinationExchange; 35 | @JsonProperty("dest-exchange-key") 36 | private String destinationExchangeKey; 37 | @JsonProperty("dest-queue") 38 | private String destinationQueue; 39 | 40 | public ShovelDefinition() { 41 | } 42 | 43 | public String getSourceExchange() { 44 | return sourceExchange; 45 | } 46 | 47 | public void setSourceExchange(String sourceExchange) { 48 | this.sourceExchange = sourceExchange; 49 | } 50 | 51 | public String getSourceExchangeKey() { 52 | return sourceExchangeKey; 53 | } 54 | 55 | public void setSourceExchangeKey(String sourceExchangeKey) { 56 | this.sourceExchangeKey = sourceExchangeKey; 57 | } 58 | 59 | public String getSourceQueue() { 60 | return sourceQueue; 61 | } 62 | 63 | public void setSourceQueue(String sourceQueue) { 64 | this.sourceQueue = sourceQueue; 65 | } 66 | 67 | public String getDestinationExchange() { 68 | return destinationExchange; 69 | } 70 | 71 | public void setDestinationExchange(String destExchange) { 72 | this.destinationExchange = destExchange; 73 | } 74 | 75 | public String getDestinationExchangeKey() { 76 | return destinationExchangeKey; 77 | } 78 | 79 | public void setDestinationExchangeKey(String destExchangeKey) { 80 | this.destinationExchangeKey = destExchangeKey; 81 | } 82 | 83 | public String getDestinationQueue() { 84 | return destinationQueue; 85 | } 86 | 87 | public void setDestinationQueue(String destQueue) { 88 | this.destinationQueue = destQueue; 89 | } 90 | 91 | @Override 92 | public String toString() { 93 | return "ShovelDetails{" + "sourceExchange=" + sourceExchange + "sourceExchangeKey=" + sourceExchangeKey + ", sourceQueue=" + sourceQueue 94 | + ", destinationExchange='" + destinationExchange + ", destinationExchangeKey='" + destinationExchangeKey + '\'' 95 | + ", destinationQueue='" + destinationQueue + '}'; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/QueueTotals.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | @SuppressWarnings("unused") 22 | public class QueueTotals { 23 | private long messages; 24 | @JsonProperty("messages_details") 25 | private RateDetails messagesDetails; 26 | @JsonProperty("messages_ready") 27 | private long messagesReady; 28 | @JsonProperty("messages_ready_details") 29 | private RateDetails messagesReadyDetails; 30 | @JsonProperty("messages_unacknowledged") 31 | private long messagesUnacknowledged; 32 | @JsonProperty("messages_unacknowledged_details") 33 | private RateDetails messagesUnacknowledgedDetails; 34 | 35 | public long getMessages() { 36 | return messages; 37 | } 38 | 39 | public void setMessages(long messages) { 40 | this.messages = messages; 41 | } 42 | 43 | public RateDetails getMessagesDetails() { 44 | return messagesDetails; 45 | } 46 | 47 | public void setMessagesDetails(RateDetails messagesDetails) { 48 | this.messagesDetails = messagesDetails; 49 | } 50 | 51 | public long getMessagesReady() { 52 | return messagesReady; 53 | } 54 | 55 | public void setMessagesReady(long messagesReady) { 56 | this.messagesReady = messagesReady; 57 | } 58 | 59 | public RateDetails getMessagesReadyDetails() { 60 | return messagesReadyDetails; 61 | } 62 | 63 | public void setMessagesReadyDetails(RateDetails messagesReadyDetails) { 64 | this.messagesReadyDetails = messagesReadyDetails; 65 | } 66 | 67 | public long getMessagesUnacknowledged() { 68 | return messagesUnacknowledged; 69 | } 70 | 71 | public void setMessagesUnacknowledged(long messagesUnacknowledged) { 72 | this.messagesUnacknowledged = messagesUnacknowledged; 73 | } 74 | 75 | public RateDetails getMessagesUnacknowledgedDetails() { 76 | return messagesUnacknowledgedDetails; 77 | } 78 | 79 | public void setMessagesUnacknowledgedDetails(RateDetails messagesUnacknowledgedDetails) { 80 | this.messagesUnacknowledgedDetails = messagesUnacknowledgedDetails; 81 | } 82 | 83 | @Override 84 | public String toString() { 85 | return "QueueTotals{" + 86 | "messages=" + messages + 87 | ", messagesDetails=" + messagesDetails + 88 | ", messagesReady=" + messagesReady + 89 | ", messagesReadyDetails=" + messagesReadyDetails + 90 | ", messagesUnacknowledged=" + messagesUnacknowledged + 91 | ", messagesUnacknowledgedDetails=" + messagesUnacknowledgedDetails + 92 | '}'; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/BindingInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Map; 20 | 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | @SuppressWarnings("unused") 24 | public class BindingInfo { 25 | private String vhost; 26 | private String source; 27 | private String destination; 28 | @JsonProperty("destination_type") 29 | private DestinationType destinationType; 30 | @JsonProperty("routing_key") 31 | private String routingKey; 32 | private Map arguments; 33 | @JsonProperty("properties_key") 34 | private String propertiesKey; 35 | 36 | public String getVhost() { 37 | return vhost; 38 | } 39 | 40 | public void setVhost(String vhost) { 41 | this.vhost = vhost; 42 | } 43 | 44 | public String getSource() { 45 | return source; 46 | } 47 | 48 | public void setSource(String source) { 49 | this.source = source; 50 | } 51 | 52 | public String getDestination() { 53 | return destination; 54 | } 55 | 56 | public void setDestination(String destination) { 57 | this.destination = destination; 58 | } 59 | 60 | public void setDestinationType(DestinationType destinationType){ 61 | this.destinationType = destinationType; 62 | } 63 | 64 | public void setDestinationType(String destinationType) { 65 | if(destinationType != null) { 66 | this.destinationType = DestinationType.valueOf(destinationType.toUpperCase()); 67 | } 68 | } 69 | 70 | public DestinationType getDestinationType(){ 71 | return destinationType; 72 | } 73 | 74 | 75 | public String getRoutingKey() { 76 | return routingKey; 77 | } 78 | 79 | public void setRoutingKey(String routingKey) { 80 | this.routingKey = routingKey; 81 | } 82 | 83 | public Map getArguments() { 84 | return arguments; 85 | } 86 | 87 | public void setArguments(Map arguments) { 88 | this.arguments = arguments; 89 | } 90 | 91 | public String getPropertiesKey() { 92 | return propertiesKey; 93 | } 94 | 95 | public void setPropertiesKey(String propertiesKey) { 96 | this.propertiesKey = propertiesKey; 97 | } 98 | 99 | @Override 100 | public String toString() { 101 | return "BindingInfo{" + 102 | "vhost='" + vhost + '\'' + 103 | ", source='" + source + '\'' + 104 | ", destination='" + destination + '\'' + 105 | ", destinationType='" + destinationType + '\'' + 106 | ", routingKey='" + routingKey + '\'' + 107 | ", arguments=" + arguments + 108 | ", propertiesKey='" + propertiesKey + '\'' + 109 | '}'; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/ParameterizedTypeReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | import java.lang.reflect.ParameterizedType; 20 | import java.lang.reflect.Type; 21 | 22 | /** 23 | * To capture and pass a generic {@link Type}. 24 | * 25 | *

From the Spring 27 | * Framework. 28 | * 29 | * @param 30 | * @since 4.0.0 31 | */ 32 | public abstract class ParameterizedTypeReference { 33 | 34 | private final Type type; 35 | 36 | protected ParameterizedTypeReference() { 37 | Class parameterizedTypeReferenceSubclass = 38 | findParameterizedTypeReferenceSubclass(getClass()); 39 | Type type = parameterizedTypeReferenceSubclass.getGenericSuperclass(); 40 | if (!(type instanceof ParameterizedType)) { 41 | throw new IllegalArgumentException("Type must be a parameterized type"); 42 | } 43 | ParameterizedType parameterizedType = (ParameterizedType) type; 44 | Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); 45 | if (actualTypeArguments.length != 1) { 46 | throw new IllegalArgumentException("Number of type arguments must be 1"); 47 | } 48 | this.type = actualTypeArguments[0]; 49 | } 50 | 51 | private ParameterizedTypeReference(Type type) { 52 | this.type = type; 53 | } 54 | 55 | /** 56 | * Build a {@code ParameterizedTypeReference} wrapping the given type. 57 | * 58 | * @param type a generic type (possibly obtained via reflection, e.g. from {@link 59 | * java.lang.reflect.Method#getGenericReturnType()}) 60 | * @return a corresponding reference which may be passed into {@code 61 | * ParameterizedTypeReference}-accepting methods 62 | * @since 4.3.12 63 | */ 64 | public static ParameterizedTypeReference forType(Type type) { 65 | return new ParameterizedTypeReference(type) {}; 66 | } 67 | 68 | private static Class findParameterizedTypeReferenceSubclass(Class child) { 69 | Class parent = child.getSuperclass(); 70 | if (Object.class == parent) { 71 | throw new IllegalStateException("Expected ParameterizedTypeReference superclass"); 72 | } else if (ParameterizedTypeReference.class == parent) { 73 | return child; 74 | } else { 75 | return findParameterizedTypeReferenceSubclass(parent); 76 | } 77 | } 78 | 79 | public Type getType() { 80 | return this.type; 81 | } 82 | 83 | @Override 84 | public boolean equals(Object other) { 85 | return (this == other 86 | || (other instanceof ParameterizedTypeReference 87 | && this.type.equals(((ParameterizedTypeReference) other).type))); 88 | } 89 | 90 | @Override 91 | public int hashCode() { 92 | return this.type.hashCode(); 93 | } 94 | 95 | @Override 96 | public String toString() { 97 | return "ParameterizedTypeReference<" + this.type + ">"; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ShovelStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | // { 22 | // "node": "", 23 | // "timestamp": "", 24 | // "name": "", 25 | // "vhost": "", 26 | // "type": "", 27 | // "state": "", 28 | // "reason": "" 29 | //}, 30 | //{ 31 | // "node": "", 32 | // "timestamp": "", 33 | // "name": "", 34 | // "vhost": "", 35 | // "type": "", 36 | // "state": "", 37 | // "definition": { 38 | // "src-queue": "", 39 | // "dest-exchange": "" 40 | // }, 41 | // "src_uri": "", 42 | // "dest_uri": "" 43 | //} 44 | 45 | public class ShovelStatus { 46 | 47 | private String node; 48 | private String name; 49 | @JsonProperty("vhost") 50 | private String virtualHost; 51 | private String type; 52 | private String state; 53 | private ShovelDefinition definition; 54 | @JsonProperty("src_uri") 55 | private String sourceURI; 56 | @JsonProperty("dest_uri") 57 | private String destinationURI; 58 | private String reason; 59 | 60 | public ShovelStatus() { 61 | } 62 | 63 | public String getNode() { 64 | return node; 65 | } 66 | 67 | public void setNode(String node) { 68 | this.node = node; 69 | } 70 | 71 | public String getName() { 72 | return name; 73 | } 74 | 75 | public void setName(String name) { 76 | this.name = name; 77 | } 78 | 79 | public String getVirtualHost() { 80 | return virtualHost; 81 | } 82 | 83 | public void setVirtualHost(String virtualHost) { 84 | this.virtualHost = virtualHost; 85 | } 86 | 87 | public String getType() { 88 | return type; 89 | } 90 | 91 | public void setType(String type) { 92 | this.type = type; 93 | } 94 | 95 | public String getState() { 96 | return state; 97 | } 98 | 99 | public void setState(String state) { 100 | this.state = state; 101 | } 102 | 103 | public ShovelDefinition getDefinition() { 104 | return definition; 105 | } 106 | 107 | public void setDefinition(ShovelDefinition definition) { 108 | this.definition = definition; 109 | } 110 | 111 | public String getSourceURI() { 112 | return sourceURI; 113 | } 114 | 115 | public void setSourceURI(String sourceURI) { 116 | this.sourceURI = sourceURI; 117 | } 118 | 119 | public String getDestinationURI() { 120 | return destinationURI; 121 | } 122 | 123 | public void setDestinationURI(String destinationURI) { 124 | this.destinationURI = destinationURI; 125 | } 126 | 127 | public String getReason() { 128 | return reason; 129 | } 130 | 131 | public void setReason(String reason) { 132 | this.reason = reason; 133 | } 134 | 135 | @Override 136 | public String toString() { 137 | return "ShovelStatus{" + "node='" + node + "\', " + "name='" + name + "\', " + "virtualHost='" + virtualHost + "\', " + "type='" + type + '\'' 138 | + ", state=" + state + '\'' + ", definition=" + definition + '\'' + ", sourceURI=" + sourceURI + '\'' + ", destinationURI=" + destinationURI 139 | + '\'' + ", reason=" + reason + '}'; 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ExchangeInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | @SuppressWarnings("unused") 25 | public class ExchangeInfo { 26 | private String name; 27 | private String vhost; 28 | private String type; 29 | private boolean durable; 30 | @JsonProperty("auto_delete") 31 | private boolean autoDelete; 32 | private boolean internal; 33 | private Map arguments; 34 | 35 | @JsonProperty("message_stats") 36 | private ExchangeMessageStats messageStats; 37 | 38 | public ExchangeInfo(){} 39 | public ExchangeInfo(String type, boolean durable, boolean autoDelete) { 40 | this(type, durable, autoDelete, false, new HashMap()); 41 | } 42 | public ExchangeInfo(String type, boolean durable, boolean autoDelete, boolean internal, Map arguments) { 43 | this.type = type; 44 | this.durable = durable; 45 | this.autoDelete = autoDelete; 46 | this.internal = internal; 47 | this.arguments = arguments; 48 | } 49 | 50 | public String getName() { 51 | return name; 52 | } 53 | 54 | public void setName(String name) { 55 | this.name = name; 56 | } 57 | 58 | public String getVhost() { 59 | return vhost; 60 | } 61 | 62 | public void setVhost(String vhost) { 63 | this.vhost = vhost; 64 | } 65 | 66 | public String getType() { 67 | return type; 68 | } 69 | 70 | public void setType(String type) { 71 | this.type = type; 72 | } 73 | 74 | public boolean isDurable() { 75 | return durable; 76 | } 77 | 78 | public void setDurable(boolean durable) { 79 | this.durable = durable; 80 | } 81 | 82 | public boolean isAutoDelete() { 83 | return autoDelete; 84 | } 85 | 86 | public void setAutoDelete(boolean autoDelete) { 87 | this.autoDelete = autoDelete; 88 | } 89 | 90 | public boolean isInternal() { 91 | return internal; 92 | } 93 | 94 | public void setInternal(boolean internal) { 95 | this.internal = internal; 96 | } 97 | 98 | public Map getArguments() { 99 | return arguments; 100 | } 101 | 102 | public void setArguments(Map arguments) { 103 | this.arguments = arguments; 104 | } 105 | 106 | public ExchangeMessageStats getMessageStats() { 107 | return messageStats; 108 | } 109 | 110 | public void setMessageStats(ExchangeMessageStats messageStats) { 111 | this.messageStats = messageStats; 112 | } 113 | 114 | @Override 115 | public String toString() { 116 | return "ExchangeInfo{" + 117 | "name='" + name + '\'' + 118 | ", vhost='" + vhost + '\'' + 119 | ", type='" + type + '\'' + 120 | ", durable=" + durable + 121 | ", autoDelete=" + autoDelete + 122 | ", internal=" + internal + 123 | ", arguments=" + arguments + 124 | ", messageStats=" + messageStats + 125 | '}'; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ConsumerDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Map; 20 | 21 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | @SuppressWarnings("unused") 25 | @JsonIgnoreProperties(ignoreUnknown=true) 26 | public class ConsumerDetails { 27 | @JsonProperty("consumer_tag") 28 | private String consumerTag; 29 | @JsonProperty("prefetch_count") 30 | private int prefetchCount; 31 | @JsonProperty("channel_details") 32 | private ChannelDetails channelDetails; 33 | private boolean exclusive; 34 | private Map arguments; 35 | @JsonProperty("queue") 36 | private QueueDetails queueDetails; 37 | @JsonProperty("active") 38 | private boolean active = true; 39 | @JsonProperty("activity_status") 40 | private String activityStatus; 41 | @JsonProperty("ack_required") 42 | private boolean ackRequired; 43 | @JsonProperty("consumer_timeout") 44 | private int consumerTimeout; 45 | 46 | public String getConsumerTag() { 47 | return consumerTag; 48 | } 49 | 50 | public void setConsumerTag(String consumerTag) { 51 | this.consumerTag = consumerTag; 52 | } 53 | 54 | public int getPrefetchCount() { 55 | return prefetchCount; 56 | } 57 | 58 | public void setPrefetchCount(int prefetchCount) { 59 | this.prefetchCount = prefetchCount; 60 | } 61 | 62 | public ChannelDetails getChannelDetails() { 63 | return channelDetails; 64 | } 65 | 66 | public void setChannelDetails(ChannelDetails channelDetails) { 67 | this.channelDetails = channelDetails; 68 | } 69 | 70 | public boolean isExclusive() { 71 | return exclusive; 72 | } 73 | 74 | public void setExclusive(boolean exclusive) { 75 | this.exclusive = exclusive; 76 | } 77 | 78 | public Map getArguments() { 79 | return arguments; 80 | } 81 | 82 | public void setArguments(Map arguments) { 83 | this.arguments = arguments; 84 | } 85 | 86 | public QueueDetails getQueueDetails() { 87 | return queueDetails; 88 | } 89 | 90 | public void setQueueDetails(QueueDetails queueDetails) { 91 | this.queueDetails = queueDetails; 92 | } 93 | 94 | public boolean isActive() { 95 | return active; 96 | } 97 | 98 | public void setActive(boolean active) { 99 | this.active = active; 100 | } 101 | 102 | public String getActivityStatus() { 103 | return activityStatus; 104 | } 105 | 106 | public void setActivityStatus(String activityStatus) { 107 | this.activityStatus = activityStatus; 108 | } 109 | 110 | public boolean isAckRequired() { 111 | return ackRequired; 112 | } 113 | 114 | public void setAckRequired(boolean ackRequired) { 115 | this.ackRequired = ackRequired; 116 | } 117 | 118 | public int getConsumerTimeout() { 119 | return consumerTimeout; 120 | } 121 | 122 | public void setConsumerTimeout(int consumerTimeout) { 123 | this.consumerTimeout = consumerTimeout; 124 | } 125 | 126 | @Override 127 | public String toString() { 128 | return "ConsumerDetails{" + 129 | "consumerTag='" + consumerTag + '\'' + 130 | ", prefetchCount=" + prefetchCount + 131 | ", channelDetails=" + channelDetails + 132 | ", exclusive=" + exclusive + 133 | ", arguments=" + arguments + 134 | ", queueDetails=" + queueDetails + 135 | ", active='" + active + 136 | ", activityStatus='" + activityStatus + '\'' + 137 | ", ackRequired='" + ackRequired + 138 | ", consumerTimeout='" + consumerTimeout + 139 | '}'; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/DetailsParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.time.Duration; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | import java.util.Map.Entry; 23 | import java.util.stream.Collectors; 24 | 25 | /** 26 | * A class to gather parameters on _details objects. 27 | * 28 | *

Parameters can be set to get extra information on how count fields have changed (messages sent 29 | * and received, queue lengths). 30 | * 31 | *

A {@link DetailsParameters} instance can create a {@link QueryParameters} instance with its 32 | * own parameters applied on it, see {@link #queryParameters()}. This way {@link DetailsParameters} 33 | * can be "injected" in methods like {@link 34 | * com.rabbitmq.http.client.Client#getQueues(DetailsParameters)}. 35 | * 36 | * @since 4.1.0 37 | * @see com.rabbitmq.http.client.Client#getQueues(DetailsParameters) 38 | * @see com.rabbitmq.http.client.Client#getQueues(QueryParameters) 39 | * @see com.rabbitmq.http.client.Client#getQueue(String, String, DetailsParameters) 40 | * @see com.rabbitmq.http.client.ReactorNettyClient#getQueues(String, DetailsParameters) 41 | * @see com.rabbitmq.http.client.ReactorNettyClient#getQueue(String, String, DetailsParameters) 42 | */ 43 | public class DetailsParameters { 44 | 45 | private final Map parameters = new HashMap<>(); 46 | private QueryParameters queryParameters; 47 | 48 | private static void checkGreaterThanZero(int value, String field) { 49 | if (value <= 0) { 50 | throw new IllegalArgumentException(String.format("'%s' must be greater than 0", field)); 51 | } 52 | } 53 | 54 | private static void checkGreaterThanZero(Duration value, String field) { 55 | if (value == null) { 56 | throw new IllegalArgumentException(String.format("'%s' cannot be null", field)); 57 | } 58 | if (value.toSeconds() <= 0) { 59 | throw new IllegalArgumentException(String.format("'%s' must be greater than 0", field)); 60 | } 61 | } 62 | 63 | public DetailsParameters messageRates(int ageSeconds, int incrementSeconds) { 64 | checkGreaterThanZero(ageSeconds, "age"); 65 | checkGreaterThanZero(incrementSeconds, "increment"); 66 | this.parameters.put("msg_rates_age", String.valueOf(ageSeconds)); 67 | this.parameters.put("msg_rates_incr", String.valueOf(incrementSeconds)); 68 | return this; 69 | } 70 | 71 | public DetailsParameters messageRates(Duration age, Duration increment) { 72 | checkGreaterThanZero(age, "age"); 73 | checkGreaterThanZero(increment, "increment"); 74 | return this.messageRates((int) age.toSeconds(), (int) increment.toSeconds()); 75 | } 76 | 77 | public DetailsParameters lengths(int ageSeconds, int incrementSeconds) { 78 | checkGreaterThanZero(ageSeconds, "age"); 79 | checkGreaterThanZero(incrementSeconds, "increment"); 80 | this.parameters.put("lengths_age", String.valueOf(ageSeconds)); 81 | this.parameters.put("lengths_incr", String.valueOf(incrementSeconds)); 82 | return this; 83 | } 84 | 85 | public DetailsParameters lengths(Duration age, Duration increment) { 86 | checkGreaterThanZero(age, "age"); 87 | checkGreaterThanZero(increment, "increment"); 88 | return this.lengths((int) age.toSeconds(), (int) increment.toSeconds()); 89 | } 90 | 91 | public Map parameters() { 92 | return this.parameters.entrySet().stream() 93 | .collect(Collectors.toMap(Entry::getKey, e -> e.getValue().toString())); 94 | } 95 | 96 | public QueryParameters queryParameters() { 97 | if (this.queryParameters == null) { 98 | this.queryParameters = new QueryParameters(this.parameters); 99 | } 100 | return this.queryParameters; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/ClientParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | import static com.rabbitmq.http.client.Utils.notNull; 20 | 21 | import java.net.MalformedURLException; 22 | import java.net.URI; 23 | import java.net.URISyntaxException; 24 | import java.net.URL; 25 | 26 | import com.rabbitmq.http.client.HttpLayer.HttpLayerFactory; 27 | 28 | /** 29 | * Parameters to create an instance of {@link Client}. 30 | * 31 | * @since 3.6.0 32 | */ 33 | public class ClientParameters { 34 | 35 | private URL url; 36 | private String username; 37 | private String password; 38 | private HttpLayerFactory httpLayerFactory; 39 | 40 | /** 41 | * Set the URL to use. 42 | *

43 | * It is not expected that the URL contains any user info. 44 | * Use {@link #url(String)} user info must be extracted 45 | * from the URL and assigned to username and password. 46 | * 47 | * @param url the URL 48 | * @return this client parameters instance 49 | */ 50 | public ClientParameters url(URL url) { 51 | this.url = url; 52 | return this; 53 | } 54 | 55 | /** 56 | * Set the URL to use. 57 | *

58 | * The URL can contain user info. If so, they are automatically 59 | * assigned to the username and password properties of this instance. 60 | * 61 | * @param url the URL 62 | * @return this client parameters instance 63 | * @throws MalformedURLException for a badly formed URL. 64 | */ 65 | public ClientParameters url(String url) throws MalformedURLException { 66 | try { 67 | this.url = new URI(url).toURL(); 68 | } catch (URISyntaxException e) { 69 | throw new IllegalArgumentException("URL is malformed"); 70 | } 71 | if (this.url.getUserInfo() != null) { 72 | // URL contains credentials, setting the appropriate parameters 73 | try { 74 | this.url = new URI(Utils.urlWithoutCredentials(url)).toURL(); 75 | } catch (URISyntaxException e) { 76 | throw new IllegalArgumentException("URL is malformed"); 77 | } 78 | String[] usernamePassword = Utils.extractUsernamePassword(url); 79 | this.username = usernamePassword[0]; 80 | this.password = usernamePassword[1]; 81 | } 82 | return this; 83 | } 84 | 85 | /** 86 | * Set the username to use when authenticating. 87 | * 88 | * @param username the username 89 | * @return this client parameters instance 90 | */ 91 | public ClientParameters username(String username) { 92 | this.username = username; 93 | return this; 94 | } 95 | 96 | /** 97 | * Set the password to use when authenticating. 98 | * 99 | * @param password the password 100 | * @return this client parameters instance 101 | */ 102 | public ClientParameters password(String password) { 103 | this.password = password; 104 | return this; 105 | } 106 | 107 | public URL getUrl() { 108 | return url; 109 | } 110 | 111 | public String getUsername() { 112 | return username; 113 | } 114 | 115 | public String getPassword() { 116 | return password; 117 | } 118 | 119 | public HttpLayerFactory getHttpLayerFactory() { 120 | return httpLayerFactory; 121 | } 122 | 123 | /** 124 | * Set the {@link HttpLayerFactory} to use. 125 | * 126 | * @param httpLayerFactory 127 | * @return this client parameters instance 128 | * @see JdkHttpClientHttpLayer#configure() 129 | */ 130 | public ClientParameters httpLayerFactory(HttpLayerFactory httpLayerFactory) { 131 | this.httpLayerFactory = httpLayerFactory; 132 | return this; 133 | } 134 | 135 | void validate() { 136 | notNull(url, "URL is required; it must not be null"); 137 | notNull(username, "username is required; it must not be null"); 138 | notNull(password, "password is required; it must not be null"); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/Definitions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client.domain; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | @JsonIgnoreProperties(ignoreUnknown = true) 25 | public class Definitions { 26 | 27 | @JsonProperty("rabbit_version") 28 | private String serverVersion; 29 | 30 | private List vhosts = new ArrayList(); 31 | 32 | private List users = new ArrayList(); 33 | 34 | private List permissions = new ArrayList(); 35 | 36 | @JsonProperty("topic_permissions") 37 | private List topicPermissions = new ArrayList<>(); 38 | 39 | private List> parameters = new ArrayList<>(); 40 | 41 | @JsonProperty("global_parameters") 42 | private List> globalParameters = new ArrayList<>(); 43 | 44 | private List queues = new ArrayList(); 45 | 46 | private List exchanges = new ArrayList(); 47 | 48 | private List bindings = new ArrayList(); 49 | 50 | public String getServerVersion() { 51 | return serverVersion; 52 | } 53 | 54 | public void setServerVersion(String serverVersion) { 55 | this.serverVersion = serverVersion; 56 | } 57 | 58 | public List getVhosts() { 59 | return vhosts; 60 | } 61 | 62 | public void setVhosts(List vhosts) { 63 | this.vhosts = vhosts; 64 | } 65 | 66 | public List getUsers() { 67 | return users; 68 | } 69 | 70 | public void setUsers(List users) { 71 | this.users = users; 72 | } 73 | 74 | public List getPermissions() { 75 | return permissions; 76 | } 77 | 78 | public void setPermissions(List permissions) { 79 | this.permissions = permissions; 80 | } 81 | 82 | public List getQueues() { 83 | return queues; 84 | } 85 | 86 | public void setQueues(List queues) { 87 | this.queues = queues; 88 | } 89 | 90 | public List getExchanges() { 91 | return exchanges; 92 | } 93 | 94 | public void setExchanges(List exchanges) { 95 | this.exchanges = exchanges; 96 | } 97 | 98 | public List getBindings() { 99 | return bindings; 100 | } 101 | 102 | public void setBindings(List bindings) { 103 | this.bindings = bindings; 104 | } 105 | 106 | public void setTopicPermissions(List topicPermissions) { 107 | this.topicPermissions = topicPermissions; 108 | } 109 | 110 | public List getTopicPermissions() { 111 | return topicPermissions; 112 | } 113 | 114 | public void setParameters(List> parameters) { 115 | this.parameters = parameters; 116 | } 117 | 118 | public List> getParameters() { 119 | return parameters; 120 | } 121 | 122 | public void setGlobalParameters(List> globalParameters) { 123 | this.globalParameters = globalParameters; 124 | } 125 | 126 | public List> getGlobalParameters() { 127 | return globalParameters; 128 | } 129 | 130 | @Override 131 | public String toString() { 132 | return "Definitions{" + 133 | "serverVersion='" + serverVersion + '\'' + 134 | ", vhosts=" + vhosts + 135 | ", users=" + users + 136 | ", permissions=" + permissions + 137 | ", topicPermissions=" + topicPermissions + 138 | ", queues=" + queues + 139 | ", exchanges=" + exchanges + 140 | ", bindings=" + bindings + 141 | '}'; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/QueryParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Collection; 20 | import java.util.HashMap; 21 | import java.util.HashSet; 22 | import java.util.LinkedHashMap; 23 | import java.util.Map; 24 | import java.util.Map.Entry; 25 | import java.util.Set; 26 | import java.util.function.BiFunction; 27 | 28 | public class QueryParameters { 29 | 30 | private final Map parameters; 31 | private final Pagination pagination = new Pagination(); 32 | private final Columns columns = new Columns(); 33 | 34 | public QueryParameters() { 35 | this(new HashMap<>()); 36 | } 37 | 38 | QueryParameters(Map parameters) { 39 | this.parameters = parameters; 40 | } 41 | 42 | public Pagination pagination() { 43 | return pagination; 44 | } 45 | 46 | public QueryParameters name(String name) { 47 | name(name, false); 48 | return this; 49 | } 50 | 51 | public QueryParameters name(String name, boolean usesRegex) { 52 | parameters.put("name", name); 53 | parameters.put("use_regex", usesRegex); 54 | this.pagination.setFirstPageIfNotSet(); 55 | return this; 56 | } 57 | 58 | public Columns columns() { 59 | return columns; 60 | } 61 | 62 | public QueryParameters clear() { 63 | parameters.clear(); 64 | return this; 65 | } 66 | 67 | public boolean isEmpty() { 68 | return parameters.isEmpty(); 69 | } 70 | 71 | public Map parameters() { 72 | return parameters.entrySet().stream().reduce(new LinkedHashMap<>(), 73 | (BiFunction, Entry, Map>) (acc, entry) -> { 74 | String name = entry.getKey(); 75 | Object value = entry.getValue(); 76 | @SuppressWarnings("unchecked") 77 | String valueAsString = 78 | value instanceof Collection 79 | ? String.join(",", (Iterable) value) 80 | : String.valueOf(value); 81 | acc.put(name, valueAsString); 82 | return acc; 83 | }, (map1, map2) -> { 84 | map1.putAll(map2); 85 | return map1; 86 | } 87 | ); 88 | } 89 | 90 | QueryParameters parameter(String field, Object value) { 91 | this.parameters.put(field, value); 92 | return this; 93 | } 94 | 95 | public class Columns { 96 | public Columns add(String name) { 97 | @SuppressWarnings("unchecked") 98 | Set columns = (Set) parameters.get("columns"); 99 | if (columns == null) { 100 | columns = new HashSet<>(); 101 | parameters.put("columns", columns); 102 | } 103 | columns.add(name); 104 | return this; 105 | } 106 | 107 | public Columns sort(String name) { 108 | parameters.put("sort", name); 109 | return this; 110 | } 111 | 112 | public Columns sortReverse(boolean sortReverse) { 113 | parameters.put("sort_reverse", sortReverse); 114 | return this; 115 | } 116 | 117 | public Columns clear() { 118 | parameters.remove("columns"); 119 | parameters.remove("sort"); 120 | parameters.remove("sort_reverse"); 121 | return this; 122 | } 123 | 124 | public QueryParameters query() { 125 | return QueryParameters.this; 126 | } 127 | 128 | public boolean hasAny() { 129 | return parameters.containsKey("columns") 130 | || parameters.containsKey("sort") 131 | || parameters.containsKey("sort_reverse"); 132 | } 133 | 134 | } 135 | 136 | public class Pagination { 137 | 138 | public Pagination pageSize(int pageSize) { 139 | parameters.put("page_size", pageSize); 140 | setFirstPageIfNotSet(); 141 | return this; 142 | } 143 | 144 | private void setFirstPageIfNotSet() { 145 | parameters.putIfAbsent("page", 1); 146 | } 147 | 148 | public Pagination nextPage(Page page) { 149 | parameters.put("page", page.getPage() + 1); 150 | return this; 151 | } 152 | 153 | public Pagination clear() { 154 | parameters.remove("name"); 155 | parameters.remove("use_regex"); 156 | parameters.remove("page_size"); 157 | parameters.remove("page"); 158 | return this; 159 | } 160 | 161 | public QueryParameters query() { 162 | return QueryParameters.this; 163 | } 164 | 165 | public boolean hasAny() { 166 | return parameters.containsKey("name") 167 | || parameters.containsKey("page_size") 168 | || parameters.containsKey("page"); 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/http/client/UtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.rabbitmq.http.client; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | 22 | import com.rabbitmq.http.client.domain.QueryParameters; 23 | import java.net.URI; 24 | import java.nio.charset.StandardCharsets; 25 | import java.util.Map; 26 | import java.util.stream.Collectors; 27 | import org.apache.http.NameValuePair; 28 | import org.apache.http.client.utils.URLEncodedUtils; 29 | import org.junit.jupiter.api.BeforeEach; 30 | import org.junit.jupiter.api.Test; 31 | 32 | class UtilsTest { 33 | 34 | URI rootURI = URI.create("http://localhost:80/api/"); 35 | Utils.URIBuilder builder; 36 | 37 | @BeforeEach 38 | void setUp() { 39 | builder = new Utils.URIBuilder(rootURI); 40 | } 41 | 42 | @Test 43 | void uriWithOnePath() { 44 | assertEquals(rootURI.resolve("one"), builder.withEncodedPath("./one").get()); 45 | assertEquals(rootURI.resolve("one"), builder.withEncodedPath("one").get()); 46 | } 47 | 48 | @Test 49 | void uriWithTwoPathComponents() { 50 | assertEquals( 51 | rootURI.resolve("one/two%2F"), builder.withEncodedPath("one").withPath("two/").get()); 52 | assertEquals( 53 | rootURI.resolve("connections/some-name/channels"), 54 | builder 55 | .withEncodedPath("./connections") 56 | .withPath("some-name") 57 | .withEncodedPath("channels") 58 | .get()); 59 | assertEquals( 60 | rootURI.resolve("exchanges/one/two"), 61 | builder.withEncodedPath("./exchanges").withPath("one").withPath("two").get()); 62 | } 63 | 64 | @Test 65 | void queryUriWithOnePath() { 66 | assertEquals( 67 | rootURI.resolve("one"), 68 | builder.withEncodedPath("one").withQueryParameters(emptyQueryParameters()).get()); 69 | } 70 | 71 | @Test 72 | void queryUriWithQueryParameterAndOnePath() { 73 | QueryParameters expectedQueryParams = 74 | new QueryParameters().name("some-name").columns().add("name").query(); 75 | URI u = builder.withEncodedPath("one").withQueryParameters(expectedQueryParams).get(); 76 | 77 | Map actualQueryParams = 78 | URLEncodedUtils.parse(u, StandardCharsets.UTF_8).stream() 79 | .collect(Collectors.toMap(NameValuePair::getName, NameValuePair::getValue)); 80 | for (Map.Entry q : expectedQueryParams.parameters().entrySet()) { 81 | assertEquals(actualQueryParams.get(q.getKey()), q.getValue()); 82 | } 83 | } 84 | 85 | @Test 86 | void queryUriWithMapOfParameterAndOnePath() { 87 | QueryParameters expectedQueryParams = 88 | new QueryParameters().name("some-name").columns().add("name").query(); 89 | 90 | URI u = 91 | builder.withEncodedPath("one").withQueryParameters(expectedQueryParams.parameters()).get(); 92 | 93 | Map actualQueryParams = 94 | URLEncodedUtils.parse(u, StandardCharsets.UTF_8).stream() 95 | .collect(Collectors.toMap(NameValuePair::getName, NameValuePair::getValue)); 96 | for (Map.Entry q : expectedQueryParams.parameters().entrySet()) { 97 | assertEquals(actualQueryParams.get(q.getKey()), q.getValue()); 98 | } 99 | } 100 | 101 | @Test 102 | void extractUsernamePasswordNoDecodingNeeded() { 103 | // when: "username and password are extracted from http://mylogin:mypassword@localhost:15672" 104 | String[] usernamePassword = 105 | Utils.extractUsernamePassword("http://mylogin:mypassword@localhost:15672"); 106 | 107 | // then: "username and password are extracted properly" 108 | assertThat(usernamePassword).hasSize(2).containsExactly("mylogin", "mypassword"); 109 | } 110 | 111 | @Test 112 | void extractUsernamePasswordNoUserInfoInUrl() { 113 | // when: "there is no user info in the URL" 114 | // then: "an exception is thrown" 115 | assertThatThrownBy( 116 | () -> { 117 | Utils.extractUsernamePassword("http://localhost:15672"); 118 | }) 119 | .isInstanceOf(IllegalArgumentException.class); 120 | } 121 | 122 | @Test 123 | void extractUsernamePasswordDecodingNeeded() { 124 | // when: "username and password are extracted from 125 | // https://test+user:test%40password@myrabbithost/api/" 126 | String[] usernamePassword = 127 | Utils.extractUsernamePassword("https://test+user:test%40password@myrabbithost/api/"); 128 | 129 | // then: "username and password are extracted and decoded properly" 130 | assertThat(usernamePassword).hasSize(2).containsExactly("test user", "test@password"); 131 | } 132 | 133 | @Test 134 | void urlWithoutCredentialsNotEncoded() { 135 | // when: "credentials do not need encoding in the URL" 136 | String urlWithoutCredentials = 137 | Utils.urlWithoutCredentials("http://mylogin:mypassword@localhost:15672"); 138 | 139 | // then: "credentials are properly removed from the URL" 140 | assertThat(urlWithoutCredentials).isEqualTo("http://localhost:15672"); 141 | } 142 | 143 | @Test 144 | void urlWithoutCredentialsNeedToBeEncoded() { 145 | // when: "credentials need encoding in the URL" 146 | String urlWithoutCredentials = 147 | Utils.urlWithoutCredentials("https://test+user:test%40password@myrabbithost/api/"); 148 | 149 | // then: "credentials are properly removed from the URL" 150 | assertThat(urlWithoutCredentials).isEqualTo("https://myrabbithost/api/"); 151 | } 152 | 153 | private QueryParameters emptyQueryParameters() { 154 | return new QueryParameters(); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/VhostInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import com.fasterxml.jackson.annotation.JsonFormat; 24 | import com.fasterxml.jackson.annotation.JsonIgnore; 25 | import com.fasterxml.jackson.annotation.JsonProperty; 26 | 27 | @SuppressWarnings("unused") 28 | public class VhostInfo { 29 | private String name; 30 | private boolean tracing; 31 | private String description; 32 | 33 | @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) 34 | private List tags; 35 | @JsonProperty("cluster_state") 36 | private Map clusterState; 37 | @JsonProperty("message_stats") 38 | private MessageStats messageStats; 39 | private long messages; 40 | @JsonProperty("messages_details") 41 | private RateDetails messagesDetails; 42 | @JsonProperty("messages_ready") 43 | private long messagesReady; 44 | @JsonProperty("messages_ready_details") 45 | private RateDetails messagesReadyDetails; 46 | @JsonProperty("messages_unacknowledged") 47 | private long messagesUnacknowledged; 48 | @JsonProperty("messages_unacknowledged_details") 49 | private RateDetails messagesUnacknowledgedDetails; 50 | 51 | @JsonProperty("recv_oct") 52 | private long octetsReceived; 53 | @JsonProperty("recv_oct_details") 54 | private RateDetails octetsReceivedDetails; 55 | @JsonProperty("send_oct") 56 | private long octetsSent; 57 | @JsonProperty("send_oct_details") 58 | private RateDetails octetsSentDetails; 59 | 60 | @Override 61 | public String toString() { 62 | return "VhostInfo{" + 63 | "name='" + name + '\'' + 64 | ", description=" + description + 65 | ", tags=" + tags + 66 | ", tracing=" + tracing + 67 | ", clusterState=" + clusterState + 68 | ", messageStats=" + messageStats + 69 | ", messages=" + messages + 70 | ", messagesDetails=" + messagesDetails + 71 | ", messagesReady=" + messagesReady + 72 | ", messagesReadyDetails=" + messagesReadyDetails + 73 | ", messagesUnacknowledged=" + messagesUnacknowledged + 74 | ", messagesUnacknowledgedDetails=" + messagesUnacknowledgedDetails + 75 | ", octetsReceived=" + octetsReceived + 76 | ", octetsReceivedDetails=" + octetsReceivedDetails + 77 | ", octetsSent=" + octetsSent + 78 | ", octetsSentDetails=" + octetsSentDetails + 79 | '}'; 80 | } 81 | 82 | public String getName() { 83 | return name; 84 | } 85 | 86 | public void setName(String name) { 87 | this.name = name; 88 | } 89 | 90 | public boolean isTracing() { 91 | return tracing; 92 | } 93 | 94 | public void setTracing(boolean tracing) { 95 | this.tracing = tracing; 96 | } 97 | 98 | public Map getClusterState() { 99 | return clusterState; 100 | } 101 | 102 | public void setClusterState(Map clusterState) { 103 | this.clusterState = clusterState; 104 | } 105 | 106 | public String getDescription() { 107 | return description; 108 | } 109 | 110 | public void setDescription(String description) { 111 | this.description = description; 112 | } 113 | 114 | public List getTags() { 115 | return tags; 116 | } 117 | 118 | @JsonProperty("tags") 119 | public void setTags(List tags) { 120 | this.tags = tags; 121 | } 122 | 123 | @JsonIgnore 124 | public void setTags(String tags) { 125 | this.tags = Arrays.asList(tags.split(",")); 126 | } 127 | 128 | public MessageStats getMessageStats() { 129 | return messageStats; 130 | } 131 | 132 | public void setMessageStats(MessageStats messageStats) { 133 | this.messageStats = messageStats; 134 | } 135 | 136 | public long getMessages() { 137 | return messages; 138 | } 139 | 140 | public void setMessages(long messages) { 141 | this.messages = messages; 142 | } 143 | 144 | public RateDetails getMessagesDetails() { 145 | return messagesDetails; 146 | } 147 | 148 | public void setMessagesDetails(RateDetails messagesDetails) { 149 | this.messagesDetails = messagesDetails; 150 | } 151 | 152 | public long getMessagesReady() { 153 | return messagesReady; 154 | } 155 | 156 | public void setMessagesReady(long messagesReady) { 157 | this.messagesReady = messagesReady; 158 | } 159 | 160 | public RateDetails getMessagesReadyDetails() { 161 | return messagesReadyDetails; 162 | } 163 | 164 | public void setMessagesReadyDetails(RateDetails messagesReadyDetails) { 165 | this.messagesReadyDetails = messagesReadyDetails; 166 | } 167 | 168 | public long getMessagesUnacknowledged() { 169 | return messagesUnacknowledged; 170 | } 171 | 172 | public void setMessagesUnacknowledged(long messagesUnacknowledged) { 173 | this.messagesUnacknowledged = messagesUnacknowledged; 174 | } 175 | 176 | public RateDetails getMessagesUnacknowledgedDetails() { 177 | return messagesUnacknowledgedDetails; 178 | } 179 | 180 | public void setMessagesUnacknowledgedDetails(RateDetails messagesUnacknowledgedDetails) { 181 | this.messagesUnacknowledgedDetails = messagesUnacknowledgedDetails; 182 | } 183 | 184 | public long getOctetsReceived() { 185 | return octetsReceived; 186 | } 187 | 188 | public void setOctetsReceived(long octetsReceived) { 189 | this.octetsReceived = octetsReceived; 190 | } 191 | 192 | public RateDetails getOctetsReceivedDetails() { 193 | return octetsReceivedDetails; 194 | } 195 | 196 | public void setOctetsReceivedDetails(RateDetails octetsReceivedDetails) { 197 | this.octetsReceivedDetails = octetsReceivedDetails; 198 | } 199 | 200 | public long getOctetsSent() { 201 | return octetsSent; 202 | } 203 | 204 | public void setOctetsSent(long octetsSent) { 205 | this.octetsSent = octetsSent; 206 | } 207 | 208 | public RateDetails getOctetsSentDetails() { 209 | return octetsSentDetails; 210 | } 211 | 212 | public void setOctetsSentDetails(RateDetails octetsSentDetails) { 213 | this.octetsSentDetails = octetsSentDetails; 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/OverviewResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.List; 20 | 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | @SuppressWarnings("unused") 24 | public class OverviewResponse { 25 | 26 | // 27 | // Fields 28 | // 29 | 30 | private String node; 31 | @JsonProperty("cluster_name") 32 | private String clusterName; 33 | @JsonProperty("management_version") 34 | private String managementPluginVersion; 35 | @JsonProperty("rabbitmq_version") 36 | private String serverVersion; 37 | @JsonProperty("erlang_version") 38 | private String erlangVersion; 39 | @JsonProperty("erlang_full_version") 40 | private String fullErlangVersion; 41 | @JsonProperty("statistics_level") 42 | private String statisticsLevel; 43 | @JsonProperty("statistics_db_node") 44 | private String statisticsDbNode; 45 | @JsonProperty("exchange_types") 46 | private List exchangeTypes; 47 | @JsonProperty("message_stats") 48 | private MessageStats messageStats; 49 | @JsonProperty("queue_totals") 50 | private QueueTotals queueTotals; 51 | @JsonProperty("object_totals") 52 | private ObjectTotals objectTotals; 53 | @JsonProperty("rates_mode") 54 | private String ratesMode; 55 | @JsonProperty("listeners") 56 | private List listeners; 57 | @JsonProperty("contexts") 58 | private List contexts; 59 | @JsonProperty("statistics_db_event_queue") 60 | private long statisticsDBEventQueueLength; 61 | 62 | // 63 | // API 64 | // 65 | 66 | 67 | public String getManagementPluginVersion() { 68 | return managementPluginVersion; 69 | } 70 | 71 | public void setManagementPluginVersion(String managementPluginVersion) { 72 | this.managementPluginVersion = managementPluginVersion; 73 | } 74 | 75 | /** 76 | * 77 | * @return the server version 78 | * @deprecated use {@link #getServerVersion()} instead. 79 | */ 80 | @Deprecated 81 | public String getRabbitMQVersion() { 82 | return serverVersion; 83 | } 84 | 85 | /** 86 | * 87 | * @param rabbitMQVersion the server version 88 | * @deprecated use {@link #setServerVersion(String)} instead. 89 | */ 90 | @Deprecated 91 | public void setRabbitMQVersion(String rabbitMQVersion) { 92 | this.serverVersion = rabbitMQVersion; 93 | } 94 | 95 | public String getServerVersion() { 96 | return serverVersion; 97 | } 98 | 99 | public void setServerVersion(String serverVersion) { 100 | this.serverVersion = serverVersion; 101 | } 102 | 103 | public String getErlangVersion() { 104 | return erlangVersion; 105 | } 106 | 107 | public void setErlangVersion(String erlangVersion) { 108 | this.erlangVersion = erlangVersion; 109 | } 110 | 111 | public String getFullErlangVersion() { 112 | return fullErlangVersion; 113 | } 114 | 115 | public void setFullErlangVersion(String fullErlangVersion) { 116 | this.fullErlangVersion = fullErlangVersion; 117 | } 118 | 119 | public String getNode() { 120 | return node; 121 | } 122 | 123 | public void setNode(String node) { 124 | this.node = node; 125 | } 126 | 127 | public String getStatisticsLevel() { 128 | return statisticsLevel; 129 | } 130 | 131 | public void setStatisticsLevel(String statisticsLevel) { 132 | this.statisticsLevel = statisticsLevel; 133 | } 134 | 135 | public String getStatisticsDbNode() { 136 | return statisticsDbNode; 137 | } 138 | 139 | public void setStatisticsDbNode(String statisticsDbNode) { 140 | this.statisticsDbNode = statisticsDbNode; 141 | } 142 | 143 | public String getClusterName() { 144 | return clusterName; 145 | } 146 | 147 | public void setClusterName(String clusterName) { 148 | this.clusterName = clusterName; 149 | } 150 | 151 | public List getExchangeTypes() { 152 | return exchangeTypes; 153 | } 154 | 155 | public void setExchangeTypes(List exchangeTypes) { 156 | this.exchangeTypes = exchangeTypes; 157 | } 158 | 159 | public QueueTotals getQueueTotals() { 160 | return queueTotals; 161 | } 162 | 163 | public void setQueueTotals(QueueTotals queueTotals) { 164 | this.queueTotals = queueTotals; 165 | } 166 | 167 | public ObjectTotals getObjectTotals() { 168 | return objectTotals; 169 | } 170 | 171 | public void setObjectTotals(ObjectTotals objectTotals) { 172 | this.objectTotals = objectTotals; 173 | } 174 | 175 | public List getListeners() { 176 | return listeners; 177 | } 178 | 179 | public void setListeners(List listeners) { 180 | this.listeners = listeners; 181 | } 182 | 183 | public MessageStats getMessageStats() { 184 | return messageStats; 185 | } 186 | 187 | public void setMessageStats(MessageStats messageStats) { 188 | this.messageStats = messageStats; 189 | } 190 | 191 | public List getContexts() { 192 | return contexts; 193 | } 194 | 195 | public void setContexts(List contexts) { 196 | this.contexts = contexts; 197 | } 198 | 199 | public String getRatesMode() { 200 | return ratesMode; 201 | } 202 | 203 | public void setRatesMode(String ratesMode) { 204 | this.ratesMode = ratesMode; 205 | } 206 | 207 | @Override 208 | public String toString() { 209 | return "OverviewResponse{" + 210 | "node='" + node + '\'' + 211 | ", clusterName='" + clusterName + '\'' + 212 | ", managementPluginVersion='" + managementPluginVersion + '\'' + 213 | ", serverVersion='" + serverVersion + '\'' + 214 | ", erlangVersion='" + erlangVersion + '\'' + 215 | ", fullErlangVersion='" + fullErlangVersion + '\'' + 216 | ", statisticsLevel='" + statisticsLevel + '\'' + 217 | ", statisticsDbNode='" + statisticsDbNode + '\'' + 218 | ", exchangeTypes=" + exchangeTypes + 219 | ", messageStats=" + messageStats + 220 | ", queueTotals=" + queueTotals + 221 | ", objectTotals=" + objectTotals + 222 | ", ratesMode='" + ratesMode + '\'' + 223 | ", listeners=" + listeners + 224 | ", contexts=" + contexts + 225 | ", statisticsDBEventQueueLength=" + statisticsDBEventQueueLength + 226 | '}'; 227 | } 228 | 229 | public long getStatisticsDBEventQueueLength() { 230 | return statisticsDBEventQueueLength; 231 | } 232 | 233 | public void setStatisticsDBEventQueueLength(long statisticsDBEventQueueLength) { 234 | this.statisticsDBEventQueueLength = statisticsDBEventQueueLength; 235 | } 236 | 237 | } 238 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ChannelInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import java.util.List; 20 | 21 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | @SuppressWarnings("unused") 25 | // TODO 26 | @JsonIgnoreProperties({"publishes", "deliveries"}) 27 | public class ChannelInfo { 28 | private String vhost; 29 | private String user; 30 | private int number; 31 | private String name; 32 | private String node; 33 | private String state; 34 | 35 | @JsonProperty("global_prefetch_count") 36 | private int globalPrefetchCount; 37 | @JsonProperty("prefetch_count") 38 | private int prefetchCount; 39 | @JsonProperty("acks_uncommitted") 40 | private int acksUncommitted; 41 | @JsonProperty("messages_uncommitted") 42 | private int messagesUncommitted; 43 | @JsonProperty("messages_unconfirmed") 44 | private int messagesUnconfirmed; 45 | @JsonProperty("messages_unacknowledged") 46 | private int messagesUnacknowledged; 47 | 48 | @JsonProperty("consumer_count") 49 | private int consumerCount; 50 | @JsonProperty("confirm") 51 | private boolean publisherConfirms; 52 | private boolean transactional; 53 | 54 | @JsonProperty("idle_since") 55 | private String idleSince; 56 | @JsonProperty("connection_details") 57 | private ConnectionDetails connectionDetails; 58 | @JsonProperty("message_stats") 59 | private MessageStats messageStats; 60 | 61 | @JsonProperty("consumer_details") 62 | private List consumerDetails; 63 | 64 | @JsonProperty("client_flow_blocked") 65 | private boolean clientFlowBlocked; 66 | 67 | public String getVhost() { 68 | return vhost; 69 | } 70 | 71 | public void setVhost(String vhost) { 72 | this.vhost = vhost; 73 | } 74 | 75 | public String getUser() { 76 | return user; 77 | } 78 | 79 | public void setUser(String user) { 80 | this.user = user; 81 | } 82 | 83 | public int getNumber() { 84 | return number; 85 | } 86 | 87 | public void setNumber(int number) { 88 | this.number = number; 89 | } 90 | 91 | public String getName() { 92 | return name; 93 | } 94 | 95 | public void setName(String name) { 96 | this.name = name; 97 | } 98 | 99 | public String getNode() { 100 | return node; 101 | } 102 | 103 | public void setNode(String node) { 104 | this.node = node; 105 | } 106 | 107 | public String getState() { 108 | return state; 109 | } 110 | 111 | public void setState(String state) { 112 | this.state = state; 113 | } 114 | 115 | public int getGlobalPrefetchCount() { 116 | return globalPrefetchCount; 117 | } 118 | 119 | public void setGlobalPrefetchCount(int globalPrefetchCount) { 120 | this.globalPrefetchCount = globalPrefetchCount; 121 | } 122 | 123 | public int getPrefetchCount() { 124 | return prefetchCount; 125 | } 126 | 127 | public void setPrefetchCount(int prefetchCount) { 128 | this.prefetchCount = prefetchCount; 129 | } 130 | 131 | public int getAcksUncommitted() { 132 | return acksUncommitted; 133 | } 134 | 135 | public void setAcksUncommitted(int acksUncommitted) { 136 | this.acksUncommitted = acksUncommitted; 137 | } 138 | 139 | public int getMessagesUncommitted() { 140 | return messagesUncommitted; 141 | } 142 | 143 | public void setMessagesUncommitted(int messagesUncommitted) { 144 | this.messagesUncommitted = messagesUncommitted; 145 | } 146 | 147 | public int getMessagesUnconfirmed() { 148 | return messagesUnconfirmed; 149 | } 150 | 151 | public void setMessagesUnconfirmed(int messagesUnconfirmed) { 152 | this.messagesUnconfirmed = messagesUnconfirmed; 153 | } 154 | 155 | public int getMessagesUnacknowledged() { 156 | return messagesUnacknowledged; 157 | } 158 | 159 | public void setMessagesUnacknowledged(int messagesUnacknowledged) { 160 | this.messagesUnacknowledged = messagesUnacknowledged; 161 | } 162 | 163 | public int getConsumerCount() { 164 | return consumerCount; 165 | } 166 | 167 | public void setConsumerCount(int consumerCount) { 168 | this.consumerCount = consumerCount; 169 | } 170 | 171 | public boolean usesPublisherConfirms() { 172 | return publisherConfirms; 173 | } 174 | 175 | public void setPublisherConfirms(boolean publisherConfirms) { 176 | this.publisherConfirms = publisherConfirms; 177 | } 178 | 179 | public boolean isTransactional() { 180 | return transactional; 181 | } 182 | 183 | public void setTransactional(boolean transactional) { 184 | this.transactional = transactional; 185 | } 186 | 187 | public String getIdleSince() { 188 | return idleSince; 189 | } 190 | 191 | public void setIdleSince(String idleSince) { 192 | this.idleSince = idleSince; 193 | } 194 | 195 | public ConnectionDetails getConnectionDetails() { 196 | return connectionDetails; 197 | } 198 | 199 | public void setConnectionDetails(ConnectionDetails connectionDetails) { 200 | this.connectionDetails = connectionDetails; 201 | } 202 | 203 | public boolean isClientFlowBlocked() { 204 | return clientFlowBlocked; 205 | } 206 | 207 | public void setClientFlowBlocked(boolean clientFlowBlocked) { 208 | this.clientFlowBlocked = clientFlowBlocked; 209 | } 210 | 211 | public MessageStats getMessageStats() { 212 | return messageStats; 213 | } 214 | 215 | public void setMessageStats(MessageStats messageStats) { 216 | this.messageStats = messageStats; 217 | } 218 | 219 | public List getConsumerDetails() { 220 | return consumerDetails; 221 | } 222 | 223 | public void setConsumerDetails(List consumerDetails) { 224 | this.consumerDetails = consumerDetails; 225 | } 226 | 227 | @Override 228 | public String toString() { 229 | return "ChannelInfo{" + 230 | "vhost='" + vhost + '\'' + 231 | ", user='" + user + '\'' + 232 | ", number=" + number + 233 | ", name='" + name + '\'' + 234 | ", node='" + node + '\'' + 235 | ", state='" + state + '\'' + 236 | ", globalPrefetchCount=" + globalPrefetchCount + 237 | ", prefetchCount=" + prefetchCount + 238 | ", acksUncommitted=" + acksUncommitted + 239 | ", messagesUncommitted=" + messagesUncommitted + 240 | ", messagesUnconfirmed=" + messagesUnconfirmed + 241 | ", messagesUnacknowledged=" + messagesUnacknowledged + 242 | ", consumerCount=" + consumerCount + 243 | ", publisherConfirms=" + publisherConfirms + 244 | ", transactional=" + transactional + 245 | ", idleSince='" + idleSince + '\'' + 246 | ", connectionDetails=" + connectionDetails + 247 | ", messageStats=" + messageStats + 248 | ", consumerDetails=" + consumerDetails + 249 | ", clientFlowBlocked=" + clientFlowBlocked + 250 | '}'; 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/MessageStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | @SuppressWarnings("unused") 22 | public class MessageStats { 23 | @JsonProperty("publish") 24 | private long basicPublish; 25 | @JsonProperty("publish_details") 26 | private RateDetails basicPublishDetails; 27 | @JsonProperty("confirm") 28 | private long publisherConfirm; 29 | @JsonProperty("confirm_details") 30 | private RateDetails publisherConfirmDetails; 31 | @JsonProperty("return_unroutable") 32 | private long basicReturn; 33 | @JsonProperty("return_unroutable_details") 34 | private RateDetails basicReturnDetails; 35 | @JsonProperty("deliver") 36 | private long basicDeliver; 37 | @JsonProperty("deliver_get") 38 | private long basicGet; 39 | @JsonProperty("deliver_get_details") 40 | private RateDetails basicGetDetails; 41 | @JsonProperty("deliver_details") 42 | private RateDetails basicDeliverDetails; 43 | @JsonProperty("deliver_no_ack") 44 | private long basicDeliverNoAck; 45 | @JsonProperty("deliver_no_ack_details") 46 | private RateDetails basicDeliverNoAckDetails; 47 | @JsonProperty("redeliver") 48 | private long redeliver; 49 | 50 | public long getRedeliver() { 51 | return redeliver; 52 | } 53 | 54 | public void setRedeliver(long redeliver) { 55 | this.redeliver = redeliver; 56 | } 57 | 58 | public RateDetails getRedeliverDetails() { 59 | return redeliverDetails; 60 | } 61 | 62 | public void setRedeliverDetails(RateDetails redeliverDetails) { 63 | this.redeliverDetails = redeliverDetails; 64 | } 65 | 66 | @JsonProperty("redeliver_details") 67 | private RateDetails redeliverDetails; 68 | @JsonProperty("get_no_ack") 69 | private long basicGetNoAck; 70 | @JsonProperty("get_no_ack_details") 71 | private RateDetails basicGetNoAckDetails; 72 | @JsonProperty("ack") 73 | private long ack; 74 | @JsonProperty("ack_details") 75 | private RateDetails ackDetails; 76 | @JsonProperty("get") 77 | private long getCounter; 78 | @JsonProperty("get_details") 79 | private RateDetails getDetails; 80 | 81 | public long getBasicPublish() { 82 | return basicPublish; 83 | } 84 | 85 | public void setBasicPublish(long basicPublish) { 86 | this.basicPublish = basicPublish; 87 | } 88 | 89 | public RateDetails getBasicPublishDetails() { 90 | return basicPublishDetails; 91 | } 92 | 93 | public void setBasicPublishDetails(RateDetails basicPublishDetails) { 94 | this.basicPublishDetails = basicPublishDetails; 95 | } 96 | 97 | public long getPublisherConfirm() { 98 | return publisherConfirm; 99 | } 100 | 101 | public void setPublisherConfirm(long publisherConfirm) { 102 | this.publisherConfirm = publisherConfirm; 103 | } 104 | 105 | public RateDetails getPublisherConfirmDetails() { 106 | return publisherConfirmDetails; 107 | } 108 | 109 | public void setPublisherConfirmDetails(RateDetails publisherConfirmDetails) { 110 | this.publisherConfirmDetails = publisherConfirmDetails; 111 | } 112 | 113 | public long getBasicReturn() { 114 | return basicReturn; 115 | } 116 | 117 | public void setBasicReturn(long basicReturn) { 118 | this.basicReturn = basicReturn; 119 | } 120 | 121 | public RateDetails getBasicReturnDetails() { 122 | return basicReturnDetails; 123 | } 124 | 125 | public void setBasicReturnDetails(RateDetails basicReturnDetails) { 126 | this.basicReturnDetails = basicReturnDetails; 127 | } 128 | 129 | public long getBasicDeliver() { 130 | return basicDeliver; 131 | } 132 | 133 | public void setBasicDeliver(long basicDeliver) { 134 | this.basicDeliver = basicDeliver; 135 | } 136 | 137 | public long getBasicGet() { 138 | return basicGet; 139 | } 140 | 141 | public void setBasicGet(long basicGet) { 142 | this.basicGet = basicGet; 143 | } 144 | 145 | public RateDetails getBasicGetDetails() { 146 | return basicGetDetails; 147 | } 148 | 149 | public void setBasicGetDetails(RateDetails basicGetDetails) { 150 | this.basicGetDetails = basicGetDetails; 151 | } 152 | 153 | public RateDetails getBasicDeliverDetails() { 154 | return basicDeliverDetails; 155 | } 156 | 157 | public void setBasicDeliverDetails(RateDetails basicDeliverDetails) { 158 | this.basicDeliverDetails = basicDeliverDetails; 159 | } 160 | 161 | public long getBasicDeliverNoAck() { 162 | return basicDeliverNoAck; 163 | } 164 | 165 | public void setBasicDeliverNoAck(long basicDeliverNoAck) { 166 | this.basicDeliverNoAck = basicDeliverNoAck; 167 | } 168 | 169 | public RateDetails getBasicDeliverNoAckDetails() { 170 | return basicDeliverNoAckDetails; 171 | } 172 | 173 | public void setBasicDeliverNoAckDetails(RateDetails basicDeliverNoAckDetails) { 174 | this.basicDeliverNoAckDetails = basicDeliverNoAckDetails; 175 | } 176 | 177 | public long getBasicGetNoAck() { 178 | return basicGetNoAck; 179 | } 180 | 181 | public void setBasicGetNoAck(long basicGetNoAck) { 182 | this.basicGetNoAck = basicGetNoAck; 183 | } 184 | 185 | public RateDetails getBasicGetNoAckDetails() { 186 | return basicGetNoAckDetails; 187 | } 188 | 189 | public void setBasicGetNoAckDetails(RateDetails basicGetNoAckDetails) { 190 | this.basicGetNoAckDetails = basicGetNoAckDetails; 191 | } 192 | 193 | public long getAck() { 194 | return ack; 195 | } 196 | 197 | public void setAck(long ack) { 198 | this.ack = ack; 199 | } 200 | 201 | public RateDetails getAckDetails() { 202 | return ackDetails; 203 | } 204 | 205 | public void setAckDetails(RateDetails ackDetails) { 206 | this.ackDetails = ackDetails; 207 | } 208 | 209 | public long getGetCounter() { 210 | return getCounter; 211 | } 212 | 213 | public void setGetCounter(long getCounter) { 214 | this.getCounter = getCounter; 215 | } 216 | 217 | public RateDetails getGetDetails() { 218 | return getDetails; 219 | } 220 | 221 | public void setGetDetails(RateDetails getDetails) { 222 | this.getDetails = getDetails; 223 | } 224 | 225 | @Override 226 | public String toString() { 227 | return "MessageStats{" + 228 | "basicPublish=" + basicPublish + 229 | ", basicPublishDetails=" + basicPublishDetails + 230 | ", publisherConfirm=" + publisherConfirm + 231 | ", publisherConfirmDetails=" + publisherConfirmDetails + 232 | ", basicReturn=" + basicReturn + 233 | ", basicReturnDetails=" + basicReturnDetails + 234 | ", basicDeliver=" + basicDeliver + 235 | ", basicGet=" + basicGet + 236 | ", basicGetDetails=" + basicGetDetails + 237 | ", basicDeliverDetails=" + basicDeliverDetails + 238 | ", basicDeliverNoAck=" + basicDeliverNoAck + 239 | ", basicDeliverNoAckDetails=" + basicDeliverNoAckDetails + 240 | ", basicGetNoAck=" + basicGetNoAck + 241 | ", basicGetNoAckDetails=" + basicGetNoAckDetails + 242 | ", ack=" + ack + 243 | ", ackDetails=" + ackDetails + 244 | ", getCounter=" + getCounter + 245 | ", getDetails=" + getDetails + 246 | '}'; 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client; 18 | 19 | import java.net.MalformedURLException; 20 | import java.net.URI; 21 | import java.net.URISyntaxException; 22 | import java.net.URL; 23 | import java.net.URLDecoder; 24 | import java.nio.charset.StandardCharsets; 25 | import java.util.Base64; 26 | import java.util.Collections; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | import com.rabbitmq.http.client.domain.OutboundMessage; 31 | import com.rabbitmq.http.client.domain.QueryParameters; 32 | 33 | /** 34 | * 35 | */ 36 | final class Utils { 37 | 38 | private Utils() { } 39 | 40 | static void notNull(Object object, String message) { 41 | if (object == null) { 42 | throw new IllegalArgumentException(message); 43 | } 44 | } 45 | 46 | static Map bodyForPublish(String routingKey, OutboundMessage outboundMessage) { 47 | if (routingKey == null) { 48 | throw new IllegalArgumentException("routing key cannot be null"); 49 | } 50 | if (outboundMessage == null) { 51 | throw new IllegalArgumentException("message cannot be null"); 52 | } 53 | if (outboundMessage.getPayload() == null) { 54 | throw new IllegalArgumentException("message payload cannot be null"); 55 | } 56 | Map body = new HashMap(); 57 | body.put("routing_key", routingKey); 58 | body.put("properties", outboundMessage.getProperties() == null ? Collections.EMPTY_MAP : outboundMessage.getProperties()); 59 | body.put("payload", outboundMessage.getPayload()); 60 | body.put("payload_encoding", outboundMessage.getPayloadEncoding()); 61 | return body; 62 | } 63 | 64 | static Map bodyForGet(int count, GetAckMode ackMode, GetEncoding encoding, int truncate) { 65 | if (count <= 0) { 66 | throw new IllegalArgumentException("count must be greater than 0"); 67 | } 68 | if (ackMode == null) { 69 | throw new IllegalArgumentException("acknowledgment mode cannot be null"); 70 | } 71 | if (encoding == null) { 72 | throw new IllegalArgumentException("encoding cannot be null"); 73 | } 74 | Map body = new HashMap<>(); 75 | body.put("count", count); 76 | body.put("ackmode", ackMode.ackMode); 77 | body.put("encoding", encoding.encoding); 78 | if (truncate >= 0) { 79 | body.put("truncate", truncate); 80 | } 81 | return body; 82 | } 83 | 84 | static String[] extractUsernamePassword(String url) { 85 | String userInfo = null; 86 | try { 87 | userInfo = new URI(url).toURL().getUserInfo(); 88 | } catch (MalformedURLException | URISyntaxException e) { 89 | throw new IllegalArgumentException("Malformed URL", e); 90 | } 91 | if (userInfo == null) { 92 | throw new IllegalArgumentException("Could not extract password from URL. " + 93 | "URL should be like 'https://guest:guest@localhost:15672/api/'"); 94 | } 95 | String[] usernamePassword = userInfo.split(":"); 96 | if (usernamePassword.length != 2) { 97 | throw new IllegalArgumentException("Could not extract password from URL. " + 98 | "URL should be like 'https://guest:guest@localhost:15672/api/'"); 99 | } 100 | 101 | return new String[]{ 102 | decode(usernamePassword[0]), decode(usernamePassword[1]) 103 | }; 104 | } 105 | 106 | static URI rootUri(URL url) throws URISyntaxException { 107 | if (url.toString().endsWith("/")) { 108 | return url.toURI(); 109 | } else { 110 | return new URI(url + "/"); 111 | } 112 | } 113 | 114 | static String decode(String potentiallyEncodedString) { 115 | if (potentiallyEncodedString != null && !potentiallyEncodedString.isEmpty()) { 116 | return URLDecoder.decode(potentiallyEncodedString, StandardCharsets.UTF_8); 117 | } else { 118 | return potentiallyEncodedString; 119 | } 120 | } 121 | 122 | static String urlWithoutCredentials(String url) { 123 | URL url1 = null; 124 | try { 125 | url1 = new URI(url).toURL(); 126 | } catch (MalformedURLException | URISyntaxException e) { 127 | throw new IllegalArgumentException("URL is malformed"); 128 | } 129 | return url.replace(url1.getUserInfo() + "@", ""); 130 | } 131 | 132 | static class URIBuilder { 133 | URI rootURI; 134 | StringBuilder sb = new StringBuilder(); 135 | QueryParameters queryParameters; 136 | Map mapOfParameters; 137 | 138 | public URIBuilder(URI rootURI) { 139 | this.rootURI = rootURI; 140 | } 141 | 142 | URIBuilder withEncodedPath(String path) { 143 | if (sb.length() > 0 && sb.charAt(sb.length()-1) != '/') sb.append("/"); 144 | sb.append(path); 145 | return this; 146 | } 147 | URIBuilder withPath(String path) { 148 | if (sb.length() > 0 && sb.charAt(sb.length()-1) != '/') sb.append("/"); 149 | sb.append(PercentEncoder.encodePathSegment(path)); 150 | return this; 151 | } 152 | URIBuilder withQueryParameters(QueryParameters queryParameters) { 153 | this.queryParameters = queryParameters; 154 | return this; 155 | } 156 | URIBuilder withQueryParameters(Map mapOfParameters) { 157 | this.mapOfParameters = mapOfParameters; 158 | return this; 159 | } 160 | URI get() { 161 | try { 162 | if ((queryParameters != null && !queryParameters.isEmpty()) || mapOfParameters != null 163 | && !mapOfParameters.isEmpty()) sb.append("?"); 164 | 165 | if (queryParameters != null && !queryParameters.isEmpty()) { 166 | for (Map.Entry param : queryParameters.parameters().entrySet()) { 167 | sb.append(param.getKey()).append("=").append(PercentEncoder.encodeParameter(param.getValue())).append("&"); 168 | } 169 | sb.deleteCharAt(sb.length() - 1); // eliminate last & 170 | } 171 | if (mapOfParameters != null && !mapOfParameters.isEmpty()) { 172 | for (Map.Entry param : mapOfParameters.entrySet()) { 173 | sb.append(param.getKey()).append("=").append(PercentEncoder.encodeParameter(param.getValue())).append("&"); 174 | } 175 | sb.deleteCharAt(sb.length() - 1); // eliminate last & 176 | } 177 | return rootURI.resolve(sb.toString()); 178 | }finally { 179 | sb.setLength(0); 180 | } 181 | } 182 | 183 | public URIBuilder withPathSeparator() { 184 | sb.append("/"); 185 | return this; 186 | } 187 | } 188 | 189 | static String base64(String in) { 190 | return Base64.getEncoder().encodeToString(in.getBytes(StandardCharsets.UTF_8)); 191 | } 192 | 193 | } 194 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.2.0 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 157 | SET WRAPPER_SHA_256_SUM="" 158 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 159 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 160 | ) 161 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 162 | powershell -Command "&{"^ 163 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 164 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 165 | " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 166 | " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 167 | " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 168 | " exit 1;"^ 169 | "}"^ 170 | "}" 171 | if ERRORLEVEL 1 goto error 172 | ) 173 | 174 | @REM Provide a "standardized" way to retrieve the CLI args that will 175 | @REM work with both Windows and non-Windows executions. 176 | set MAVEN_CMD_LINE_ARGS=%* 177 | 178 | %MAVEN_JAVA_EXE% ^ 179 | %JVM_CONFIG_MAVEN_PROPS% ^ 180 | %MAVEN_OPTS% ^ 181 | %MAVEN_DEBUG_OPTS% ^ 182 | -classpath %WRAPPER_JAR% ^ 183 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 184 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 185 | if ERRORLEVEL 1 goto error 186 | goto end 187 | 188 | :error 189 | set ERROR_CODE=1 190 | 191 | :end 192 | @endlocal & set ERROR_CODE=%ERROR_CODE% 193 | 194 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 195 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 196 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 197 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 198 | :skipRcPost 199 | 200 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 201 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 202 | 203 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 204 | 205 | cmd /C exit /B %ERROR_CODE% 206 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/http/client/domain/ShovelDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.rabbitmq.http.client.domain; 18 | 19 | import static com.fasterxml.jackson.annotation.JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY; 20 | import static com.fasterxml.jackson.annotation.JsonFormat.Feature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED; 21 | 22 | import java.util.Arrays; 23 | import java.util.Collections; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | import com.fasterxml.jackson.annotation.JsonFormat; 28 | import com.fasterxml.jackson.annotation.JsonProperty; 29 | 30 | // {"src-uri": "amqp://", "src-queue": "my-queue", 31 | // "dest-uri": "amqp://remote-server", "dest-queue": "another-queue"} 32 | 33 | public class ShovelDetails { 34 | 35 | @JsonProperty("src-uri") 36 | @JsonFormat(with = {ACCEPT_SINGLE_VALUE_AS_ARRAY, WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED}) 37 | private List sourceURIs; 38 | @JsonProperty("src-exchange") 39 | private String sourceExchange; 40 | @JsonProperty("src-exchange-key") 41 | private String sourceExchangeKey; 42 | @JsonProperty("src-queue") 43 | private String sourceQueue; 44 | @JsonProperty("src-prefetch-count") 45 | private Long sourcePrefetchCount; 46 | @JsonProperty("src-delete-after") 47 | private String sourceDeleteAfter; 48 | 49 | @JsonProperty("dest-uri") 50 | @JsonFormat(with = {ACCEPT_SINGLE_VALUE_AS_ARRAY, WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED}) 51 | private List destinationURIs; 52 | @JsonProperty("dest-exchange") 53 | private String destinationExchange; 54 | @JsonProperty("dest-exchange-key") 55 | private String destinationExchangeKey; 56 | @JsonProperty("dest-queue") 57 | private String destinationQueue; 58 | @JsonProperty("dest-add-timestamp-header") 59 | private Boolean destinationAddTimestampHeader; 60 | 61 | @JsonProperty("reconnect-delay") 62 | private long reconnectDelay; 63 | @JsonProperty("add-forward-headers") 64 | private boolean addForwardHeaders; 65 | 66 | @JsonProperty("ack-mode") 67 | private String ackMode; 68 | 69 | @JsonProperty("publish-properties") 70 | private Map publishProperties; 71 | 72 | public ShovelDetails() { 73 | } 74 | 75 | public ShovelDetails(String sourceURI, String destURI, long reconnectDelay, boolean addForwardHeaders, Map publishProperties) { 76 | this(Collections.singletonList(sourceURI), Collections.singletonList(destURI), reconnectDelay, addForwardHeaders, publishProperties); 77 | } 78 | 79 | public ShovelDetails(List sourceURIs, List destURIs, long reconnectDelay, boolean addForwardHeaders, Map publishProperties) { 80 | checkURIsArgument("sourceURIs", sourceURIs); 81 | checkURIsArgument("destURIs", destURIs); 82 | 83 | this.sourceURIs = Collections.unmodifiableList(sourceURIs); 84 | this.destinationURIs = Collections.unmodifiableList(destURIs); 85 | this.reconnectDelay = reconnectDelay; 86 | this.addForwardHeaders = addForwardHeaders; 87 | this.publishProperties = publishProperties; 88 | } 89 | 90 | public List getSourceURIs() { 91 | return sourceURIs; 92 | } 93 | 94 | public void setSourceURIs(List sourceURIs) { 95 | checkURIsArgument("sourceURIs", sourceURIs); 96 | this.sourceURIs = Collections.unmodifiableList(sourceURIs); 97 | } 98 | 99 | public String getSourceExchange() { 100 | return sourceExchange; 101 | } 102 | 103 | public void setSourceExchange(String sourceExchange) { 104 | this.sourceExchange = sourceExchange; 105 | } 106 | 107 | public String getSourceExchangeKey() { 108 | return sourceExchangeKey; 109 | } 110 | 111 | public void setSourceExchangeKey(String sourceExchangeKey) { 112 | this.sourceExchangeKey = sourceExchangeKey; 113 | } 114 | 115 | public String getSourceQueue() { 116 | return sourceQueue; 117 | } 118 | 119 | public void setSourceQueue(String sourceQueue) { 120 | this.sourceQueue = sourceQueue; 121 | } 122 | 123 | public List getDestinationURIs() { 124 | return destinationURIs; 125 | } 126 | 127 | public void setDestinationURIs(List destURIs) { 128 | checkURIsArgument("destURIs", destURIs); 129 | this.destinationURIs = Collections.unmodifiableList(destURIs); 130 | } 131 | 132 | public String getDestinationExchange() { 133 | return destinationExchange; 134 | } 135 | 136 | public void setDestinationExchange(String destExchange) { 137 | this.destinationExchange = destExchange; 138 | } 139 | 140 | public String getDestinationExchangeKey() { 141 | return destinationExchangeKey; 142 | } 143 | 144 | public void setDestinationExchangeKey(String destExchangeKey) { 145 | this.destinationExchangeKey = destExchangeKey; 146 | } 147 | 148 | 149 | public String getDestinationQueue() { 150 | return destinationQueue; 151 | } 152 | 153 | public void setDestinationQueue(String destQueue) { 154 | this.destinationQueue = destQueue; 155 | } 156 | 157 | public long getReconnectDelay() { 158 | return reconnectDelay; 159 | } 160 | 161 | public void setReconnectDelay(long reconnectDelay) { 162 | this.reconnectDelay = reconnectDelay; 163 | } 164 | 165 | public boolean isAddForwardHeaders() { 166 | return addForwardHeaders; 167 | } 168 | 169 | public void setAddForwardHeaders(boolean addForwardHeaders) { 170 | this.addForwardHeaders = addForwardHeaders; 171 | } 172 | 173 | public String getAckMode() { 174 | return ackMode; 175 | } 176 | 177 | public void setAckMode(String ackMode) { 178 | this.ackMode = ackMode; 179 | } 180 | 181 | public Map getPublishProperties() { 182 | return publishProperties; 183 | } 184 | 185 | public void setPublishProperties(Map publishProperties) { 186 | this.publishProperties = publishProperties; 187 | } 188 | 189 | public Long getSourcePrefetchCount() { 190 | return sourcePrefetchCount; 191 | } 192 | 193 | public void setSourcePrefetchCount(Long sourcePrefetchCount) { 194 | this.sourcePrefetchCount = sourcePrefetchCount; 195 | } 196 | 197 | public String getSourceDeleteAfter() { 198 | return sourceDeleteAfter; 199 | } 200 | 201 | public void setSourceDeleteAfter(String sourceDeleteAfter) { 202 | this.sourceDeleteAfter = sourceDeleteAfter; 203 | } 204 | 205 | public Boolean isDestinationAddTimestampHeader() { 206 | return destinationAddTimestampHeader; 207 | } 208 | 209 | public void setDestinationAddTimestampHeader(Boolean destinationAddTimestampHeader) { 210 | this.destinationAddTimestampHeader = destinationAddTimestampHeader; 211 | } 212 | 213 | @Override 214 | public String toString() { 215 | return "ShovelDetails{" + 216 | "sourceURIs='" + URIsToString(sourceURIs) + '\'' + 217 | ", sourceExchange='" + sourceExchange + '\'' + 218 | ", sourceExchangeKey='" + sourceExchangeKey + '\'' + 219 | ", sourceQueue='" + sourceQueue + '\'' + 220 | ", sourcePrefetchCount='" + sourcePrefetchCount + '\'' + 221 | ", sourceDeleteAfter='" + sourceDeleteAfter + '\'' + 222 | ", destinationURIs='" + URIsToString(destinationURIs) + '\'' + 223 | ", destinationExchange='" + destinationExchange + '\'' + 224 | ", destinationExchangeKey='" + destinationExchangeKey + '\'' + 225 | ", destinationQueue='" + destinationQueue + '\'' + 226 | ", destinationAddTimestampHeader=" + destinationAddTimestampHeader + 227 | ", reconnectDelay=" + reconnectDelay + 228 | ", addForwardHeaders=" + addForwardHeaders + 229 | ", ackMode='" + ackMode + '\'' + 230 | ", publishProperties=" + publishProperties + 231 | '}'; 232 | } 233 | 234 | private static void checkURIsArgument(String argumentName, List argument) { 235 | if (argument == null || argument.isEmpty()) { 236 | throw new IllegalArgumentException(argumentName + " argument must contains at least one URI"); 237 | } 238 | } 239 | 240 | private static String URIsToString(List uris) { 241 | if (uris.size() == 1) { 242 | // for back compatibility 243 | return uris.get(0); 244 | } 245 | return Arrays.toString(uris.toArray()); 246 | } 247 | } 248 | --------------------------------------------------------------------------------