├── .git-blame-ignore-revs ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── publish-snapshot.yml │ ├── release.yml │ ├── test-native-image.yml │ ├── test-rabbitmq-alphas.yml │ ├── test-supported-java-versions-5.x.yml │ ├── test-supported-java-versions-main.yml │ └── test.yml ├── .gitignore ├── .mvn ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── LICENSE-APACHE2 ├── LICENSE-GPL2 ├── LICENSE-MPL-RabbitMQ ├── Makefile ├── README.adoc ├── RUNNING_TESTS.md ├── ci ├── _start-cluster.sh ├── cluster │ ├── configuration │ │ └── rabbitmq.conf │ └── docker-compose.yml ├── release-java-client.sh ├── start-broker.sh └── start-cluster.sh ├── codegen.py ├── deploy-javadoc.sh ├── doc └── channels │ ├── channels.pdf │ ├── channels.tex │ ├── whiteboard.JPG │ ├── worktransition.graffle │ ├── worktransition.pdf │ └── zed-cm.sty ├── generate-observation-documentation.sh ├── mvnw ├── mvnw.cmd ├── pom.xml ├── release-versions.txt └── src ├── main ├── java │ └── com │ │ └── rabbitmq │ │ ├── client │ │ ├── Address.java │ │ ├── AddressResolver.java │ │ ├── AlreadyClosedException.java │ │ ├── AuthenticationFailureException.java │ │ ├── BasicProperties.java │ │ ├── BlockedCallback.java │ │ ├── BlockedListener.java │ │ ├── BuiltinExchangeType.java │ │ ├── CancelCallback.java │ │ ├── Channel.java │ │ ├── ChannelContinuationTimeoutException.java │ │ ├── Command.java │ │ ├── ConfirmCallback.java │ │ ├── ConfirmListener.java │ │ ├── Connection.java │ │ ├── ConnectionFactory.java │ │ ├── ConnectionFactoryConfigurator.java │ │ ├── Consumer.java │ │ ├── ConsumerCancelledException.java │ │ ├── ConsumerShutdownSignalCallback.java │ │ ├── ContentHeader.java │ │ ├── DefaultConsumer.java │ │ ├── DefaultSaslConfig.java │ │ ├── DefaultSocketChannelConfigurator.java │ │ ├── DefaultSocketConfigurator.java │ │ ├── DeliverCallback.java │ │ ├── Delivery.java │ │ ├── DnsRecordIpAddressResolver.java │ │ ├── DnsSrvRecordAddressResolver.java │ │ ├── Envelope.java │ │ ├── ExceptionHandler.java │ │ ├── GetResponse.java │ │ ├── JDKSaslConfig.java │ │ ├── ListAddressResolver.java │ │ ├── LongString.java │ │ ├── MalformedFrameException.java │ │ ├── MapRpcServer.java │ │ ├── MessageProperties.java │ │ ├── Method.java │ │ ├── MetricsCollector.java │ │ ├── MissedHeartbeatException.java │ │ ├── NoOpMetricsCollector.java │ │ ├── PossibleAuthenticationFailureException.java │ │ ├── ProtocolVersionMismatchException.java │ │ ├── Recoverable.java │ │ ├── RecoverableChannel.java │ │ ├── RecoverableConnection.java │ │ ├── RecoveryDelayHandler.java │ │ ├── RecoveryListener.java │ │ ├── ResolvedInetAddress.java │ │ ├── Return.java │ │ ├── ReturnCallback.java │ │ ├── ReturnListener.java │ │ ├── RpcClient.java │ │ ├── RpcClientParams.java │ │ ├── RpcServer.java │ │ ├── SaslConfig.java │ │ ├── SaslMechanism.java │ │ ├── ShutdownListener.java │ │ ├── ShutdownNotifier.java │ │ ├── ShutdownSignalException.java │ │ ├── SocketChannelConfigurator.java │ │ ├── SocketChannelConfigurators.java │ │ ├── SocketConfigurator.java │ │ ├── SocketConfigurators.java │ │ ├── SslContextFactory.java │ │ ├── SslEngineConfigurator.java │ │ ├── SslEngineConfigurators.java │ │ ├── StringRpcServer.java │ │ ├── TopologyRecoveryException.java │ │ ├── TrafficListener.java │ │ ├── TrustEverythingTrustManager.java │ │ ├── UnblockedCallback.java │ │ ├── UnexpectedFrameError.java │ │ ├── UnexpectedMethodError.java │ │ ├── UnknownClassOrMethodId.java │ │ ├── UnroutableRpcRequestException.java │ │ ├── impl │ │ │ ├── AMQBasicProperties.java │ │ │ ├── AMQChannel.java │ │ │ ├── AMQCommand.java │ │ │ ├── AMQConnection.java │ │ │ ├── AMQContentHeader.java │ │ │ ├── AbstractFrameHandlerFactory.java │ │ │ ├── AbstractMetricsCollector.java │ │ │ ├── AnonymousMechanism.java │ │ │ ├── CRDemoMechanism.java │ │ │ ├── ChannelManager.java │ │ │ ├── ChannelN.java │ │ │ ├── ClientVersion.java │ │ │ ├── CommandAssembler.java │ │ │ ├── CompletableFutureRpcWrapper.java │ │ │ ├── ConnectionParams.java │ │ │ ├── ConsumerDispatcher.java │ │ │ ├── ConsumerWorkService.java │ │ │ ├── ContentHeaderPropertyReader.java │ │ │ ├── ContentHeaderPropertyWriter.java │ │ │ ├── CredentialsProvider.java │ │ │ ├── CredentialsRefreshService.java │ │ │ ├── DefaultCredentialsProvider.java │ │ │ ├── DefaultCredentialsRefreshService.java │ │ │ ├── DefaultExceptionHandler.java │ │ │ ├── Environment.java │ │ │ ├── ErrorOnWriteListener.java │ │ │ ├── ExternalMechanism.java │ │ │ ├── ForgivingExceptionHandler.java │ │ │ ├── Frame.java │ │ │ ├── FrameHandler.java │ │ │ ├── FrameHandlerFactory.java │ │ │ ├── HeartbeatSender.java │ │ │ ├── LogTrafficListener.java │ │ │ ├── LongStringHelper.java │ │ │ ├── Method.java │ │ │ ├── MethodArgumentReader.java │ │ │ ├── MethodArgumentWriter.java │ │ │ ├── MicrometerMetricsCollector.java │ │ │ ├── NetworkConnection.java │ │ │ ├── OAuth2ClientCredentialsGrantCredentialsProvider.java │ │ │ ├── OAuthTokenManagementException.java │ │ │ ├── OpenTelemetryMetricsCollector.java │ │ │ ├── PlainMechanism.java │ │ │ ├── RefreshProtectedCredentialsProvider.java │ │ │ ├── RpcContinuationRpcWrapper.java │ │ │ ├── RpcWrapper.java │ │ │ ├── SetQueue.java │ │ │ ├── ShutdownNotifierComponent.java │ │ │ ├── SocketFrameHandler.java │ │ │ ├── SocketFrameHandlerFactory.java │ │ │ ├── StandardMetricsCollector.java │ │ │ ├── StrictExceptionHandler.java │ │ │ ├── TlsUtils.java │ │ │ ├── TruncatedInputStream.java │ │ │ ├── UnknownChannelException.java │ │ │ ├── UpdateSecretExtension.java │ │ │ ├── Utils.java │ │ │ ├── ValueReader.java │ │ │ ├── ValueWriter.java │ │ │ ├── VariableLinkedBlockingQueue.java │ │ │ ├── Version.java │ │ │ ├── WorkPool.java │ │ │ ├── WorkPoolFullException.java │ │ │ ├── nio │ │ │ │ ├── BlockingQueueNioQueue.java │ │ │ │ ├── ByteBufferFactory.java │ │ │ │ ├── ByteBufferOutputStream.java │ │ │ │ ├── DefaultByteBufferFactory.java │ │ │ │ ├── FrameBuilder.java │ │ │ │ ├── FrameWriteRequest.java │ │ │ │ ├── HeaderWriteRequest.java │ │ │ │ ├── NioContext.java │ │ │ │ ├── NioHelper.java │ │ │ │ ├── NioLoop.java │ │ │ │ ├── NioLoopContext.java │ │ │ │ ├── NioParams.java │ │ │ │ ├── NioQueue.java │ │ │ │ ├── SelectorHolder.java │ │ │ │ ├── SocketChannelFrameHandler.java │ │ │ │ ├── SocketChannelFrameHandlerFactory.java │ │ │ │ ├── SocketChannelFrameHandlerState.java │ │ │ │ ├── SocketChannelRegistration.java │ │ │ │ ├── SslEngineByteBufferOutputStream.java │ │ │ │ ├── SslEngineFrameBuilder.java │ │ │ │ ├── SslEngineHelper.java │ │ │ │ ├── WriteRequest.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── recovery │ │ │ │ ├── AutorecoveringChannel.java │ │ │ │ ├── AutorecoveringConnection.java │ │ │ │ ├── BackoffPolicy.java │ │ │ │ ├── ConsumerRecoveryListener.java │ │ │ │ ├── DefaultRetryHandler.java │ │ │ │ ├── QueueRecoveryListener.java │ │ │ │ ├── RecordedBinding.java │ │ │ │ ├── RecordedConsumer.java │ │ │ │ ├── RecordedEntity.java │ │ │ │ ├── RecordedExchange.java │ │ │ │ ├── RecordedExchangeBinding.java │ │ │ │ ├── RecordedNamedEntity.java │ │ │ │ ├── RecordedQueue.java │ │ │ │ ├── RecordedQueueBinding.java │ │ │ │ ├── RecoveredQueueNameSupplier.java │ │ │ │ ├── RecoveryAwareAMQConnection.java │ │ │ │ ├── RecoveryAwareAMQConnectionFactory.java │ │ │ │ ├── RecoveryAwareChannelManager.java │ │ │ │ ├── RecoveryAwareChannelN.java │ │ │ │ ├── RecoveryCanBeginListener.java │ │ │ │ ├── RetryContext.java │ │ │ │ ├── RetryHandler.java │ │ │ │ ├── RetryResult.java │ │ │ │ ├── TopologyRecoveryFilter.java │ │ │ │ ├── TopologyRecoveryRetryHandlerBuilder.java │ │ │ │ ├── TopologyRecoveryRetryLogic.java │ │ │ │ ├── Utils.java │ │ │ │ └── package-info.java │ │ ├── observation │ │ │ ├── NoOpObservationCollector.java │ │ │ ├── ObservationCollector.java │ │ │ └── micrometer │ │ │ │ ├── DefaultDeliverObservationConvention.java │ │ │ │ ├── DefaultProcessObservationConvention.java │ │ │ │ ├── DefaultPublishObservationConvention.java │ │ │ │ ├── DefaultReceiveObservationConvention.java │ │ │ │ ├── DeliverContext.java │ │ │ │ ├── DeliverObservationConvention.java │ │ │ │ ├── MicrometerObservationCollector.java │ │ │ │ ├── MicrometerObservationCollectorBuilder.java │ │ │ │ ├── PublishContext.java │ │ │ │ ├── PublishObservationConvention.java │ │ │ │ └── RabbitMqObservationDocumentation.java │ │ └── package-info.java │ │ ├── tools │ │ ├── json │ │ │ ├── JSONUtil.java │ │ │ └── package-info.java │ │ ├── jsonrpc │ │ │ ├── JacksonJsonRpcMapper.java │ │ │ ├── JsonRpcClient.java │ │ │ ├── JsonRpcException.java │ │ │ ├── JsonRpcMapper.java │ │ │ ├── JsonRpcMappingException.java │ │ │ ├── JsonRpcServer.java │ │ │ ├── ParameterDescription.java │ │ │ ├── ProcedureDescription.java │ │ │ ├── ServiceDescription.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ └── utility │ │ ├── BlockingCell.java │ │ ├── BlockingValueOrException.java │ │ ├── IntAllocator.java │ │ ├── SensibleClone.java │ │ ├── Utility.java │ │ ├── ValueOrException.java │ │ └── package-info.java ├── resources │ ├── META-INF │ │ └── native-image │ │ │ └── com.rabbitmq │ │ │ └── amqp-client │ │ │ └── native-image.properties │ ├── rabbitmq-amqp-client.properties │ └── version.properties └── scripts │ └── generate_amqp_sources.groovy └── test ├── java ├── SanityCheck.java └── com │ └── rabbitmq │ ├── client │ ├── AbstractJsonRpcTest.java │ ├── AmqpClientTestExtension.java │ ├── JacksonJsonRpcTest.java │ ├── QueueingConsumer.java │ ├── impl │ │ ├── AMQConnectionRefreshCredentialsTest.java │ │ ├── DefaultCredentialsRefreshServiceTest.java │ │ ├── OAuth2ClientCredentialsGrantCredentialsProviderTest.java │ │ ├── RefreshProtectedCredentialsProviderTest.java │ │ ├── ValueWriterTest.java │ │ ├── WorkPoolTests.java │ │ └── recovery │ │ │ └── AutorecoveringChannelTest.java │ └── test │ │ ├── AMQBuilderApiTest.java │ │ ├── AMQChannelTest.java │ │ ├── AMQConnectionTest.java │ │ ├── AddressTest.java │ │ ├── AmqpUriTest.java │ │ ├── BlockedConnectionTest.java │ │ ├── BlockingCellTest.java │ │ ├── BrokenFramesTest.java │ │ ├── BrokerTestCase.java │ │ ├── Bug20004Test.java │ │ ├── ChannelAsyncCompletableFutureTest.java │ │ ├── ChannelNTest.java │ │ ├── ChannelNumberAllocationTests.java │ │ ├── ChannelRpcTimeoutIntegrationTest.java │ │ ├── ClientTestSuite.java │ │ ├── ClientVersionTest.java │ │ ├── ClonePropertiesTest.java │ │ ├── CloseInMainLoop.java │ │ ├── ConfirmBase.java │ │ ├── ConnectionFactoryTest.java │ │ ├── ConnectionTest.java │ │ ├── DefaultRetryHandlerTest.java │ │ ├── DnsRecordIpAddressResolverTests.java │ │ ├── DnsSrvRecordAddressResolverTest.java │ │ ├── FrameBuilderTest.java │ │ ├── FrameTest.java │ │ ├── GeneratedClassesTest.java │ │ ├── JavaNioTest.java │ │ ├── LambdaCallbackTest.java │ │ ├── LongStringTest.java │ │ ├── MaxInboundMessageSizeTest.java │ │ ├── MetricsCollectorTest.java │ │ ├── MicrometerMetricsCollectorTest.java │ │ ├── MultiThreadedChannel.java │ │ ├── NioDeadlockOnConnectionClosing.java │ │ ├── NoAutoRecoveryWhenTcpWindowIsFullTest.java │ │ ├── PropertyFileInitialisationTest.java │ │ ├── QueueingConsumerTests.java │ │ ├── RecoveryAwareAMQConnectionFactoryTest.java │ │ ├── RecoveryDelayHandlerTest.java │ │ ├── RefreshCredentialsTest.java │ │ ├── RequiredPropertiesSuite.java │ │ ├── RpcTest.java │ │ ├── RpcTopologyRecordingTest.java │ │ ├── SharedThreadPoolTest.java │ │ ├── SslContextFactoryTest.java │ │ ├── StrictExceptionHandlerTest.java │ │ ├── TableTest.java │ │ ├── TestUtils.java │ │ ├── TestUtilsTest.java │ │ ├── TlsUtilsTest.java │ │ ├── TrafficListenerTest.java │ │ ├── TruncatedInputStreamTest.java │ │ ├── ValueOrExceptionTest.java │ │ ├── functional │ │ ├── AbstractRejectTest.java │ │ ├── AlternateExchange.java │ │ ├── BasicConsume.java │ │ ├── BasicGet.java │ │ ├── BindingLifecycle.java │ │ ├── BindingLifecycleBase.java │ │ ├── CcRoutes.java │ │ ├── ClusteredTestBase.java │ │ ├── Confirm.java │ │ ├── ConnectionOpen.java │ │ ├── ConnectionRecovery.java │ │ ├── ConsumerCancelNotification.java │ │ ├── ConsumerCount.java │ │ ├── ConsumerPriorities.java │ │ ├── DeadLetterExchange.java │ │ ├── DefaultExchange.java │ │ ├── DirectReplyTo.java │ │ ├── DoubleDeletion.java │ │ ├── DurableOnTransient.java │ │ ├── ExceptionHandling.java │ │ ├── ExceptionMessages.java │ │ ├── ExchangeDeclare.java │ │ ├── ExchangeDeleteIfUnused.java │ │ ├── ExchangeDeletePredeclared.java │ │ ├── ExchangeEquivalenceBase.java │ │ ├── ExchangeExchangeBindings.java │ │ ├── ExchangeExchangeBindingsAutoDelete.java │ │ ├── FrameMax.java │ │ ├── FunctionalTestSuite.java │ │ ├── HeadersExchangeValidation.java │ │ ├── Heartbeat.java │ │ ├── InternalExchange.java │ │ ├── InvalidAcks.java │ │ ├── InvalidAcksBase.java │ │ ├── InvalidAcksTx.java │ │ ├── MessageCount.java │ │ ├── Metrics.java │ │ ├── MicrometerObservationCollectorMetrics.java │ │ ├── Nack.java │ │ ├── NoRequeueOnCancel.java │ │ ├── Nowait.java │ │ ├── PerConsumerPrefetch.java │ │ ├── PerMessageTTL.java │ │ ├── PerQueueTTL.java │ │ ├── PerQueueVsPerMessageTTL.java │ │ ├── Policies.java │ │ ├── QosTests.java │ │ ├── QueueExclusivity.java │ │ ├── QueueLease.java │ │ ├── QueueLifecycle.java │ │ ├── QueueSizeLimit.java │ │ ├── Recover.java │ │ ├── Reject.java │ │ ├── RequeueOnChannelClose.java │ │ ├── RequeueOnClose.java │ │ ├── RequeueOnConnectionClose.java │ │ ├── Routing.java │ │ ├── SaslMechanisms.java │ │ ├── TTLHandling.java │ │ ├── Tables.java │ │ ├── TopologyRecoveryFiltering.java │ │ ├── TopologyRecoveryRetry.java │ │ ├── Transactions.java │ │ ├── UnbindAutoDeleteExchange.java │ │ ├── UnexpectedFrames.java │ │ └── UserIDHeader.java │ │ ├── server │ │ ├── AlternateExchangeEquivalence.java │ │ ├── BlockedConnection.java │ │ ├── Bug19219Test.java │ │ ├── ChannelLimitNegotiation.java │ │ ├── DeadLetterExchangeDurable.java │ │ ├── DurableBindingLifecycle.java │ │ ├── EffectVisibilityCrossNodeTest.java │ │ ├── ExclusiveQueueDurability.java │ │ ├── Firehose.java │ │ ├── HaTestSuite.java │ │ ├── LastHaTestSuite.java │ │ ├── LoopbackUsers.java │ │ ├── MemoryAlarms.java │ │ ├── MessageRecovery.java │ │ ├── Permissions.java │ │ ├── PersistenceGuarantees.java │ │ ├── PriorityQueues.java │ │ ├── ServerTestSuite.java │ │ ├── Shutdown.java │ │ ├── TopicPermissions.java │ │ └── XDeathHeaderGrowth.java │ │ └── ssl │ │ ├── BadVerifiedConnection.java │ │ ├── ConnectionFactoryDefaultTlsVersion.java │ │ ├── HostnameVerification.java │ │ ├── NioTlsUnverifiedConnection.java │ │ ├── SslTestSuite.java │ │ ├── TlsConnectionLogging.java │ │ ├── TlsTestUtils.java │ │ ├── UnverifiedConnection.java │ │ └── VerifiedConnection.java │ ├── tools │ └── Host.java │ └── utility │ └── IntAllocatorTests.java └── resources ├── META-INF └── services │ └── org.junit.jupiter.api.extension.Extension ├── junit-platform.properties ├── logback-test.xml └── property-file-initialisation ├── configuration.properties └── tls ├── keystore.p12 └── truststore.jks /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Bump (c) year to 2025 2 | 24d78382a0c195904f054413f208e9e1aa92bc11 3 | be27b603f804d24a293013298b84307227f263b6 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for using RabbitMQ and for taking the time to report an 2 | issue. 3 | 4 | ## Does This Belong to GitHub or RabbitMQ Mailing List? 5 | 6 | *Important:* please first read the `CONTRIBUTING.md` document in the 7 | root of this repository. It will help you determine whether your 8 | feedback should be directed to the RabbitMQ mailing list [1] instead. 9 | 10 | ## Please Help Maintainers and Contributors Help You 11 | 12 | In order for the RabbitMQ team to investigate your issue, please provide 13 | **as much as possible** of the following details: 14 | 15 | * RabbitMQ version 16 | * Erlang version 17 | * RabbitMQ server and client application log files 18 | * A runnable code sample, terminal transcript or detailed set of 19 | instructions that can be used to reproduce the issue 20 | * RabbitMQ plugin information via `rabbitmq-plugins list` 21 | * Client library version (for all libraries used) 22 | * Operating system, version, and patch level 23 | 24 | Running the `rabbitmq-collect-env` [2] script can provide most of the 25 | information needed. Please make the archive available via a third-party 26 | service and note that **the script does not attempt to scrub any 27 | sensitive data**. 28 | 29 | If your issue involves RabbitMQ management UI or HTTP API, please also provide 30 | the following: 31 | 32 | * Browser and its version 33 | * What management UI page was used (if applicable) 34 | * How the HTTP API requests performed can be reproduced with `curl` 35 | * Operating system on which you are running your browser, and its version 36 | * Errors reported in the JavaScript console (if any) 37 | 38 | This information **greatly speeds up issue investigation** (or makes it 39 | possible to investigate it at all). Please help project maintainers and 40 | contributors to help you by providing it! 41 | 42 | 1. https://groups.google.com/forum/#!forum/rabbitmq-users 43 | 2. https://github.com/rabbitmq/support-tools/blob/master/scripts/rabbitmq-collect-env 44 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Proposed Changes 2 | 3 | Please describe the big picture of your changes here to communicate to the 4 | RabbitMQ team why we should accept this pull request. If it fixes a bug or 5 | resolves a feature request, be sure to link to that issue. 6 | 7 | A pull request that doesn't explain **why** the change was made has a much 8 | lower chance of being accepted. 9 | 10 | If English isn't your first language, don't worry about it and try to 11 | communicate the problem you are trying to solve to the best of your abilities. 12 | As long as we can understand the intent, it's all good. 13 | 14 | ## Types of Changes 15 | 16 | What types of changes does your code introduce to this project? 17 | _Put an `x` in the boxes that apply_ 18 | 19 | - [ ] Bugfix (non-breaking change which fixes issue #NNNN) 20 | - [ ] New feature (non-breaking change which adds functionality) 21 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 22 | - [ ] Documentation (correction or otherwise) 23 | - [ ] Cosmetics (whitespace, appearance) 24 | 25 | ## Checklist 26 | 27 | _Put an `x` in the boxes that apply. You can also fill these out after creating 28 | the PR. If you're unsure about any of them, don't hesitate to ask on the 29 | mailing list. We're here to help! This is simply a reminder of what we are 30 | going to look for before merging your code._ 31 | 32 | - [ ] I have read the `CONTRIBUTING.md` document 33 | - [ ] I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq) 34 | - [ ] All tests pass locally with my changes 35 | - [ ] I have added tests that prove my fix is effective or that my feature works 36 | - [ ] I have added necessary documentation (if appropriate) 37 | - [ ] Any dependent changes have been merged and published in related repositories 38 | 39 | ## Further Comments 40 | 41 | If this is a relatively large or complex change, kick off the discussion by 42 | explaining why you chose the solution you did and what alternatives you 43 | considered, etc. 44 | -------------------------------------------------------------------------------- /.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 | target-branch: "main" 11 | ignore: 12 | - dependency-name: "org.eclipse.jetty:jetty-servlet" 13 | versions: [ "[10.0,)" ] 14 | - dependency-name: "org.slf4j:slf4j-api" 15 | versions: [ "[2.0,)" ] 16 | - dependency-name: "ch.qos.logback:logback-classic" 17 | versions: [ "[1.3,)" ] 18 | - dependency-name: "org.apache.felix:maven-bundle-plugin" 19 | versions: [ "[6.0,)" ] 20 | - package-ecosystem: "maven" 21 | directory: "/" 22 | schedule: 23 | interval: "daily" 24 | open-pull-requests-limit: 20 25 | target-branch: "5.x.x-stable" 26 | ignore: 27 | - dependency-name: "org.eclipse.jetty:jetty-servlet" 28 | versions: ["[10.0,)"] 29 | - dependency-name: "org.slf4j:slf4j-api" 30 | versions: [ "[2.0,)" ] 31 | - dependency-name: "ch.qos.logback:logback-classic" 32 | versions: [ "[1.3,)" ] 33 | - dependency-name: "org.apache.felix:maven-bundle-plugin" 34 | versions: [ "[6.0,)" ] 35 | - package-ecosystem: "github-actions" 36 | directory: "/" 37 | schedule: 38 | interval: "daily" 39 | target-branch: "main" 40 | - package-ecosystem: "github-actions" 41 | directory: "/" 42 | schedule: 43 | interval: "daily" 44 | target-branch: "5.x.x-stable" 45 | -------------------------------------------------------------------------------- /.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@v4 11 | - name: Set up Python 12 | uses: actions/setup-python@v5 13 | with: 14 | python-version: '3.x' 15 | - name: Set up JDK 16 | uses: actions/setup-java@v4 17 | with: 18 | distribution: 'zulu' 19 | java-version: '21' 20 | cache: 'maven' 21 | server-id: central 22 | server-username: MAVEN_USERNAME 23 | server-password: MAVEN_PASSWORD 24 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 25 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 26 | - name: Get dependencies 27 | run: make deps 28 | - name: Publish snapshot 29 | run: ./mvnw clean deploy -Psnapshots -DskipITs -DskipTests --no-transfer-progress 30 | env: 31 | MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 32 | MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }} 33 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 34 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release AMQP Java Client 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-24.04 9 | 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: Set up Python 13 | uses: actions/setup-python@v5 14 | with: 15 | python-version: '3.x' 16 | - name: Set up JDK 17 | uses: actions/setup-java@v4 18 | with: 19 | distribution: 'temurin' 20 | java-version: '8' 21 | cache: 'maven' 22 | server-id: central 23 | server-username: MAVEN_USERNAME 24 | server-password: MAVEN_PASSWORD 25 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 26 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 27 | - name: Get dependencies 28 | run: make deps 29 | - name: Release AMQP Java Client 30 | run: | 31 | git config user.name "rabbitmq-ci" 32 | git config user.email "rabbitmq-ci@users.noreply.github.com" 33 | ci/release-java-client.sh 34 | env: 35 | MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 36 | MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }} 37 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .sw? 3 | .*.sw? 4 | *.beam 5 | *.class 6 | *.dat 7 | *.dump 8 | *.iml 9 | *.ipr 10 | *.iws 11 | .DS_Store 12 | \#~ 13 | /.idea/ 14 | /deps/ 15 | /target/ 16 | /.classpath 17 | /.project 18 | /.settings 19 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Dmaven.wagon.http.retryHandler.count=10 2 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This package, the RabbitMQ Java client library, is triple-licensed under 2 | the Mozilla Public License 2.0 ("MPL"), the GNU General Public License 3 | version 2 ("GPL") and the Apache License version 2 ("ASL"). For the MPL, 4 | please see LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. 5 | For the ASL, please see LICENSE-APACHE2. 6 | 7 | This means that you may choose one of these licenses when including or 8 | using this software in your own. 9 | 10 | The RabbitMQ Java client library includes third-party software under the 11 | ASL. For this license, please see LICENSE-APACHE2. For attribution of 12 | copyright and other details of provenance, please refer to the source code. 13 | 14 | If you have any questions regarding licensing, please contact us at 15 | info@rabbitmq.com. 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | MVN ?= mvn 2 | MVN_FLAGS ?= 3 | 4 | ifndef DEPS_DIR 5 | ifneq ($(wildcard ../../UMBRELLA.md),) 6 | DEPS_DIR = .. 7 | else 8 | DEPS_DIR = deps 9 | endif 10 | endif 11 | 12 | MVN_FLAGS += -Ddeps.dir="$(abspath $(DEPS_DIR))" 13 | 14 | .PHONY: all deps tests clean distclean 15 | 16 | all: deps 17 | $(MVN) $(MVN_FLAGS) compile 18 | 19 | deps: $(DEPS_DIR)/rabbitmq_codegen 20 | @: 21 | 22 | dist: clean 23 | $(MVN) $(MVN_FLAGS) -DskipTests=true -Dmaven.javadoc.failOnError=false package javadoc:javadoc 24 | 25 | $(DEPS_DIR)/rabbitmq_codegen: 26 | git clone -n --depth=1 --filter=tree:0 https://github.com/rabbitmq/rabbitmq-server.git $(DEPS_DIR)/rabbitmq-server 27 | git -C $(DEPS_DIR)/rabbitmq-server sparse-checkout set --no-cone deps/rabbitmq_codegen 28 | git -C $(DEPS_DIR)/rabbitmq-server checkout 29 | cp -R $(DEPS_DIR)/rabbitmq-server/deps/rabbitmq_codegen "$@" 30 | rm -rf $(DEPS_DIR)/rabbitmq-server 31 | 32 | tests: deps 33 | $(MVN) $(MVN_FLAGS) verify 34 | 35 | deploy: 36 | $(MVN) $(MVN_FLAGS) deploy 37 | 38 | clean: 39 | $(MVN) $(MVN_FLAGS) clean 40 | 41 | distclean: clean 42 | $(MAKE) -C $(DEPS_DIR)/rabbitmq_codegen clean 43 | 44 | .PHONY: cluster-other-node 45 | 46 | cluster-other-node: 47 | $(exec_verbose) $(RABBITMQCTL) -n $(OTHER_NODE) stop_app 48 | $(verbose) $(RABBITMQCTL) -n $(OTHER_NODE) reset 49 | $(verbose) $(RABBITMQCTL) -n $(OTHER_NODE) join_cluster \ 50 | $(if $(MAIN_NODE),$(MAIN_NODE),$(RABBITMQ_NODENAME)@$$(hostname -s)) 51 | $(verbose) $(RABBITMQCTL) -n $(OTHER_NODE) start_app 52 | -------------------------------------------------------------------------------- /ci/cluster/configuration/rabbitmq.conf: -------------------------------------------------------------------------------- 1 | cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config 2 | cluster_formation.classic_config.nodes.1 = rabbit@node0 3 | cluster_formation.classic_config.nodes.2 = rabbit@node1 4 | cluster_formation.classic_config.nodes.3 = rabbit@node2 5 | loopback_users = none 6 | 7 | listeners.ssl.default = 5671 8 | 9 | ssl_options.cacertfile = /etc/rabbitmq/tls/ca_certificate.pem 10 | ssl_options.certfile = /etc/rabbitmq/tls/server_certificate.pem 11 | ssl_options.keyfile = /etc/rabbitmq/tls/server_key.pem 12 | ssl_options.verify = verify_peer 13 | ssl_options.fail_if_no_peer_cert = false 14 | ssl_options.honor_cipher_order = true 15 | 16 | auth_mechanisms.1 = PLAIN 17 | auth_mechanisms.2 = ANONYMOUS 18 | auth_mechanisms.3 = AMQPLAIN 19 | auth_mechanisms.4 = EXTERNAL 20 | auth_mechanisms.5 = RABBIT-CR-DEMO 21 | -------------------------------------------------------------------------------- /ci/cluster/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | node0: 3 | environment: 4 | - RABBITMQ_ERLANG_COOKIE='secret_cookie' 5 | networks: 6 | - rabbitmq-cluster 7 | hostname: node0 8 | container_name: rabbitmq0 9 | image: ${RABBITMQ_IMAGE:-rabbitmq:4.1} 10 | pull_policy: always 11 | ports: 12 | - "5672:5672" 13 | - "5671:5671" 14 | tty: true 15 | volumes: 16 | - ./configuration/:/etc/rabbitmq/ 17 | - ../../rabbitmq-configuration/tls:/etc/rabbitmq/tls/ 18 | node1: 19 | environment: 20 | - RABBITMQ_ERLANG_COOKIE='secret_cookie' 21 | networks: 22 | - rabbitmq-cluster 23 | hostname: node1 24 | container_name: rabbitmq1 25 | image: ${RABBITMQ_IMAGE:-rabbitmq:4.1} 26 | pull_policy: always 27 | ports: 28 | - "5673:5672" 29 | tty: true 30 | volumes: 31 | - ./configuration/:/etc/rabbitmq/ 32 | - ../../rabbitmq-configuration/tls:/etc/rabbitmq/tls/ 33 | node2: 34 | environment: 35 | - RABBITMQ_ERLANG_COOKIE='secret_cookie' 36 | networks: 37 | - rabbitmq-cluster 38 | hostname: node2 39 | container_name: rabbitmq2 40 | image: ${RABBITMQ_IMAGE:-rabbitmq:4.1} 41 | pull_policy: always 42 | ports: 43 | - "5674:5672" 44 | tty: true 45 | volumes: 46 | - ./configuration/:/etc/rabbitmq/ 47 | - ../../rabbitmq-configuration/tls:/etc/rabbitmq/tls/ 48 | networks: 49 | rabbitmq-cluster: 50 | -------------------------------------------------------------------------------- /ci/release-java-client.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 -------------------------------------------------------------------------------- /ci/start-broker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | LOCAL_SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | RABBITMQ_IMAGE=${RABBITMQ_IMAGE:-rabbitmq:4.1} 6 | 7 | wait_for_message() { 8 | while ! docker logs "$1" | grep -q "$2"; 9 | do 10 | sleep 5 11 | echo "Waiting 5 seconds for $1 to start..." 12 | done 13 | } 14 | 15 | rm -rf rabbitmq-configuration 16 | mkdir -p rabbitmq-configuration/tls 17 | 18 | make -C "${PWD}"/tls-gen/basic 19 | 20 | rm -rf rabbitmq-configuration 21 | mkdir -p rabbitmq-configuration/tls 22 | cp -R "${PWD}"/tls-gen/basic/result/* rabbitmq-configuration/tls 23 | chmod o+r rabbitmq-configuration/tls/* 24 | chmod g+r rabbitmq-configuration/tls/* 25 | 26 | echo "loopback_users = none 27 | 28 | listeners.ssl.default = 5671 29 | 30 | ssl_options.cacertfile = /etc/rabbitmq/tls/ca_certificate.pem 31 | ssl_options.certfile = /etc/rabbitmq/tls/server_$(hostname)_certificate.pem 32 | ssl_options.keyfile = /etc/rabbitmq/tls/server_$(hostname)_key.pem 33 | ssl_options.verify = verify_peer 34 | ssl_options.fail_if_no_peer_cert = false 35 | ssl_options.honor_cipher_order = true 36 | 37 | auth_mechanisms.1 = PLAIN 38 | auth_mechanisms.2 = ANONYMOUS 39 | auth_mechanisms.3 = AMQPLAIN 40 | auth_mechanisms.4 = EXTERNAL 41 | auth_mechanisms.5 = RABBIT-CR-DEMO" >> rabbitmq-configuration/rabbitmq.conf 42 | 43 | echo "Running RabbitMQ ${RABBITMQ_IMAGE}" 44 | 45 | docker rm -f rabbitmq 2>/dev/null || echo "rabbitmq was not running" 46 | docker run -d --name rabbitmq \ 47 | --network host \ 48 | -v "${PWD}"/rabbitmq-configuration:/etc/rabbitmq \ 49 | "${RABBITMQ_IMAGE}" 50 | 51 | wait_for_message rabbitmq "completed with" 52 | 53 | docker exec rabbitmq rabbitmqctl enable_feature_flag --opt-in khepri_db 54 | docker exec rabbitmq rabbitmq-diagnostics erlang_version 55 | docker exec rabbitmq rabbitmqctl version 56 | -------------------------------------------------------------------------------- /ci/start-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export RABBITMQ_IMAGE=${RABBITMQ_IMAGE:-rabbitmq:4.1} 4 | 5 | wait_for_message() { 6 | while ! docker logs "$1" | grep -q "$2"; 7 | do 8 | sleep 2 9 | echo "Waiting 2 seconds for $1 to start..." 10 | done 11 | } 12 | 13 | rm -rf rabbitmq-configuration 14 | mkdir -p rabbitmq-configuration/tls 15 | 16 | make -C "${PWD}"/tls-gen/basic 17 | 18 | rm -rf rabbitmq-configuration 19 | mkdir -p rabbitmq-configuration/tls 20 | cp -R "${PWD}"/tls-gen/basic/result/* rabbitmq-configuration/tls 21 | mv rabbitmq-configuration/tls/server_$(hostname)_certificate.pem rabbitmq-configuration/tls/server_certificate.pem 22 | mv rabbitmq-configuration/tls/server_$(hostname)_key.pem rabbitmq-configuration/tls/server_key.pem 23 | chmod o+r rabbitmq-configuration/tls/* 24 | chmod g+r rabbitmq-configuration/tls/* 25 | 26 | docker compose --file ci/cluster/docker-compose.yml down 27 | docker compose --file ci/cluster/docker-compose.yml up --detach 28 | 29 | wait_for_message rabbitmq0 "completed with" 30 | 31 | docker exec rabbitmq0 rabbitmqctl await_online_nodes 3 32 | 33 | docker exec rabbitmq0 rabbitmqctl enable_feature_flag --opt-in khepri_db 34 | docker exec rabbitmq1 rabbitmqctl enable_feature_flag --opt-in khepri_db 35 | docker exec rabbitmq2 rabbitmqctl enable_feature_flag --opt-in khepri_db 36 | 37 | docker exec rabbitmq0 rabbitmqctl cluster_status 38 | 39 | docker compose --file ci/cluster/docker-compose.yml ps 40 | -------------------------------------------------------------------------------- /deploy-javadoc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | DEPLOY_DIRECTORY=api/current 4 | TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h')) 5 | 6 | make deps 7 | ./mvnw -q clean javadoc:javadoc -Dmaven.javadoc.failOnError=false 8 | 9 | if [ -e target/javadoc-bundle-options/element-list ] 10 | then cp target/javadoc-bundle-options/element-list target/reports/apidocs/package-list 11 | fi 12 | 13 | git co gh-pages 14 | rm -rf $DEPLOY_DIRECTORY/* 15 | cp -r target/reports/apidocs/* $DEPLOY_DIRECTORY 16 | git add $DEPLOY_DIRECTORY 17 | git commit -m "Add Javadoc for $TAG" 18 | git push origin gh-pages 19 | 20 | 21 | -------------------------------------------------------------------------------- /doc/channels/channels.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/doc/channels/channels.pdf -------------------------------------------------------------------------------- /doc/channels/channels.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/doc/channels/channels.tex -------------------------------------------------------------------------------- /doc/channels/whiteboard.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/doc/channels/whiteboard.JPG -------------------------------------------------------------------------------- /doc/channels/worktransition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/doc/channels/worktransition.pdf -------------------------------------------------------------------------------- /generate-observation-documentation.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ./mvnw -q test-compile exec:java \ 4 | -Dexec.mainClass=io.micrometer.docs.DocsGeneratorCommand \ 5 | -Dexec.classpathScope="test" \ 6 | -Dexec.args='src/main/java/com/rabbitmq/client/observation/micrometer .* target/micrometer-observation-docs' -------------------------------------------------------------------------------- /release-versions.txt: -------------------------------------------------------------------------------- 1 | RELEASE_VERSION="6.0.0.M2" 2 | DEVELOPMENT_VERSION="6.0.0-SNAPSHOT" 3 | RELEASE_BRANCH="main" 4 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/AddressResolver.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | import java.util.ArrayList; 20 | import java.util.Collections; 21 | import java.util.List; 22 | 23 | /** Strategy interface to get the potential servers to connect to. */ 24 | public interface AddressResolver { 25 | 26 | /** 27 | * Get the potential {@link Address}es to connect to. 28 | * 29 | * @return candidate {@link Address}es 30 | * @throws IOException if it encounters a problem 31 | */ 32 | List
getAddresses() throws IOException; 33 | 34 | /** 35 | * Optionally shuffle the list of addresses returned by {@link #getAddresses()}. 36 | * 37 | *

The automatic connection recovery calls this method after {@link #getAddresses()} to pick a 38 | * random address for reconnecting. 39 | * 40 | *

The default method implementation calls {@link Collections#shuffle(List)}. Custom 41 | * implementations can choose to not do any shuffling to have more predictability in the 42 | * reconnection. 43 | * 44 | * @param input 45 | * @return potentially shuffled list of addresses. 46 | */ 47 | default List

maybeShuffle(List
input) { 48 | List
list = new ArrayList
(input); 49 | Collections.shuffle(list); 50 | return list; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/AlreadyClosedException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | /** 20 | * Thrown when application tries to perform an action on connection/channel 21 | * which was already closed 22 | */ 23 | public class AlreadyClosedException extends ShutdownSignalException { 24 | /** Default for suppressing warnings without version check. */ 25 | private static final long serialVersionUID = 1L; 26 | 27 | public AlreadyClosedException(ShutdownSignalException sse) { 28 | this(sse, null); 29 | } 30 | 31 | public AlreadyClosedException(ShutdownSignalException sse, Throwable cause) { 32 | super(sse.isHardError(), 33 | sse.isInitiatedByApplication(), 34 | sse.getReason(), 35 | sse.getReference(), 36 | composeMessagePrefix(sse), 37 | ((cause == null) ? sse.getCause() : cause)); 38 | } 39 | 40 | private static String composeMessagePrefix(ShutdownSignalException sse) { 41 | String connectionOrChannel = sse.isHardError() ? "connection " : "channel "; 42 | return connectionOrChannel + "is already closed due to "; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/AuthenticationFailureException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * Thrown when the broker refuses access due to an authentication failure. 20 | */ 21 | 22 | public class AuthenticationFailureException extends PossibleAuthenticationFailureException 23 | { 24 | public AuthenticationFailureException(String reason) { 25 | super(reason); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/BlockedCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Implement this interface in order to be notified of connection block events. 22 | * Prefer it over {@link BlockedListener} for a lambda-oriented syntax. 23 | * @see BlockedListener 24 | * @see UnblockedCallback 25 | */ 26 | @FunctionalInterface 27 | public interface BlockedCallback { 28 | 29 | void handle(String reason) throws IOException; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/BlockedListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Implement this interface in order to be notified of connection block and 23 | * unblock events. 24 | * For a lambda-oriented syntax, use {@link BlockedCallback} and 25 | * {@link UnblockedCallback}. 26 | */ 27 | public interface BlockedListener { 28 | void handleBlocked(String reason) throws IOException; 29 | void handleUnblocked() throws IOException; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/BuiltinExchangeType.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client; 2 | 3 | /** 4 | * Enum for built-in exchange types. 5 | */ 6 | public enum BuiltinExchangeType { 7 | 8 | DIRECT("direct"), FANOUT("fanout"), TOPIC("topic"), HEADERS("headers"); 9 | 10 | private final String type; 11 | 12 | BuiltinExchangeType(String type) { 13 | this.type = type; 14 | } 15 | 16 | public String getType() { 17 | return type; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ChannelContinuationTimeoutException.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client; 2 | 3 | import java.io.IOException; 4 | import java.util.concurrent.TimeoutException; 5 | 6 | /** 7 | * Exception thrown when a channel times out on a continuation during a RPC call. 8 | * @since 4.1.0 9 | */ 10 | public class ChannelContinuationTimeoutException extends IOException { 11 | 12 | /** 13 | * The channel that performed the call. 14 | * Typed as Object as the underlying 15 | * object that performs the call might 16 | * not be an implementation of {@link Channel}. 17 | */ 18 | private final Object channel; 19 | 20 | /** 21 | * The number of the channel that performed the call. 22 | */ 23 | private final int channelNumber; 24 | 25 | /** 26 | * The request method that timed out. 27 | */ 28 | private final Method method; 29 | 30 | public ChannelContinuationTimeoutException(TimeoutException cause, Object channel, int channelNumber, Method method) { 31 | super( 32 | "Continuation call for method " + method + " on channel " + channel + " (#" + channelNumber + ") timed out", 33 | cause 34 | ); 35 | this.channel = channel; 36 | this.channelNumber = channelNumber; 37 | this.method = method; 38 | } 39 | 40 | /** 41 | * 42 | * @return request method that timed out 43 | */ 44 | public Method getMethod() { 45 | return method; 46 | } 47 | 48 | /** 49 | * channel that performed the call 50 | * @return 51 | */ 52 | public Object getChannel() { 53 | return channel; 54 | } 55 | 56 | /** 57 | * 58 | * @return number of the channel that performed the call 59 | */ 60 | public int getChannelNumber() { 61 | return channelNumber; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/Command.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | /** 20 | * Interface to a container for an AMQP method-and-arguments, with optional content header and body. 21 | */ 22 | public interface Command { 23 | /** 24 | * Retrieves the {@link Method} held within this Command. Downcast to 25 | * concrete (implementation-specific!) subclasses as necessary. 26 | * 27 | * @return the command's method. 28 | */ 29 | Method getMethod(); 30 | 31 | /** 32 | * Retrieves the ContentHeader subclass instance held as part of this Command, if any. 33 | * 34 | * Downcast to one of the inner classes of AMQP, 35 | * for instance {@link AMQP.BasicProperties}, as appropriate. 36 | * 37 | * @return the Command's {@link ContentHeader}, or null if none 38 | */ 39 | ContentHeader getContentHeader(); 40 | 41 | /** 42 | * Retrieves the body byte array that travelled as part of this 43 | * Command, if any. 44 | * 45 | * @return the Command's content body, or null if none 46 | */ 47 | byte[] getContentBody(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ConfirmCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Implement this interface in order to be notified of Confirm events. 23 | * Acks represent messages handled successfully; Nacks represent 24 | * messages lost by the broker. Note, the lost messages could still 25 | * have been delivered to consumers, but the broker cannot guarantee 26 | * this. 27 | * Prefer this interface over {@link ConfirmListener} for 28 | * a lambda-oriented syntax. 29 | * @see ConfirmListener 30 | */ 31 | @FunctionalInterface 32 | public interface ConfirmCallback { 33 | 34 | void handle(long deliveryTag, boolean multiple) throws IOException; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ConfirmListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Implement this interface in order to be notified of Confirm events. 23 | * Acks represent messages handled successfully; Nacks represent 24 | * messages lost by the broker. Note, the lost messages could still 25 | * have been delivered to consumers, but the broker cannot guarantee 26 | * this. 27 | * For a lambda-oriented syntax, use {@link ConfirmCallback}. 28 | */ 29 | public interface ConfirmListener { 30 | void handleAck(long deliveryTag, boolean multiple) 31 | throws IOException; 32 | 33 | void handleNack(long deliveryTag, boolean multiple) 34 | throws IOException; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ConsumerCancelledException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import com.rabbitmq.utility.SensibleClone; 19 | 20 | public class ConsumerCancelledException extends RuntimeException implements 21 | SensibleClone { 22 | 23 | /** Default for non-checking. */ 24 | private static final long serialVersionUID = 1L; 25 | 26 | @Override 27 | public ConsumerCancelledException sensibleClone() { 28 | try { 29 | return (ConsumerCancelledException) super.clone(); 30 | } catch (CloneNotSupportedException e) { 31 | // You've got to be kidding me 32 | throw new RuntimeException(e); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ConsumerShutdownSignalCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * Callback interface to be notified when either the consumer channel 22 | * or the underlying connection has been shut down. 23 | * Prefer it over {@link Consumer} for a lambda-oriented syntax, 24 | * if you don't need to implement all the application callbacks. 25 | * @see CancelCallback 26 | * @see DeliverCallback 27 | * @see Channel#basicConsume(String, boolean, String, boolean, boolean, Map, DeliverCallback, CancelCallback) 28 | * @see Channel#basicConsume(String, boolean, String, boolean, boolean, Map, DeliverCallback, ConsumerShutdownSignalCallback) 29 | * @see Channel#basicConsume(String, boolean, String, boolean, boolean, Map, DeliverCallback, CancelCallback, ConsumerShutdownSignalCallback) 30 | * @since 5.0 31 | */ 32 | @FunctionalInterface 33 | public interface ConsumerShutdownSignalCallback { 34 | 35 | /** 36 | * Called when either the channel or the underlying connection has been shut down. 37 | * @param consumerTag the consumer tag associated with the consumer 38 | * @param sig a {@link ShutdownSignalException} indicating the reason for the shut down 39 | */ 40 | void handleShutdownSignal(String consumerTag, ShutdownSignalException sig); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ContentHeader.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | /** 20 | * Public API for abstract AMQP content header objects. 21 | */ 22 | 23 | public interface ContentHeader extends Cloneable { 24 | /** 25 | * Retrieve the class ID (see the spec for a list of allowable IDs). 26 | * @return class ID of this ContentHeader. Properly an unsigned short, i.e. only the lowest 16 bits are significant 27 | */ 28 | public abstract int getClassId(); 29 | 30 | /** 31 | * Retrieve the class name, eg "basic" (see the spec for a list of these). 32 | * @return class name of this ContentHeader 33 | */ 34 | public abstract String getClassName(); 35 | 36 | /** 37 | * A debugging utility - enable properties to be appended to a string buffer for use as trace messages. 38 | * @param buffer a place to append the properties as a string 39 | */ 40 | public void appendPropertyDebugStringTo(StringBuilder buffer); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/DefaultSocketChannelConfigurator.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | import java.nio.channels.SocketChannel; 20 | 21 | public class DefaultSocketChannelConfigurator implements SocketChannelConfigurator { 22 | 23 | /** 24 | * Provides a hook to insert custom configuration of the {@link SocketChannel}s 25 | * used to connect to an AMQP server before they connect. 26 | * 27 | * The default behaviour of this method is to disable Nagle's 28 | * algorithm to get more consistently low latency. However it 29 | * may be overridden freely and there is no requirement to retain 30 | * this behaviour. 31 | * 32 | * @param socketChannel The socket channel that is to be used for the Connection 33 | */ 34 | @Override 35 | public void configure(SocketChannel socketChannel) throws IOException { 36 | socketChannel.socket().setTcpNoDelay(true); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/DefaultSocketConfigurator.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | import java.net.Socket; 20 | 21 | public class DefaultSocketConfigurator implements SocketConfigurator { 22 | /** 23 | * Provides a hook to insert custom configuration of the sockets 24 | * used to connect to an AMQP server before they connect. 25 | * 26 | * The default behaviour of this method is to disable Nagle's 27 | * algorithm to get more consistently low latency. However it 28 | * may be overridden freely and there is no requirement to retain 29 | * this behaviour. 30 | * 31 | * @param socket The socket that is to be used for the Connection 32 | */ 33 | @Override 34 | public void configure(Socket socket) throws IOException { 35 | // disable Nagle's algorithm, for more consistently low latency 36 | socket.setTcpNoDelay(true); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/DeliverCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | import java.util.Map; 20 | 21 | /** 22 | * Callback interface to be notified when a message is delivered. 23 | * Prefer it over {@link Consumer} for a lambda-oriented syntax, 24 | * if you don't need to implement all the application callbacks. 25 | * @see CancelCallback 26 | * @see ConsumerShutdownSignalCallback 27 | * @see Channel#basicConsume(String, boolean, String, boolean, boolean, Map, DeliverCallback, CancelCallback) 28 | * @see Channel#basicConsume(String, boolean, String, boolean, boolean, Map, DeliverCallback, ConsumerShutdownSignalCallback) 29 | * @see Channel#basicConsume(String, boolean, String, boolean, boolean, Map, DeliverCallback, CancelCallback, ConsumerShutdownSignalCallback) 30 | * @since 5.0 31 | */ 32 | @FunctionalInterface 33 | public interface DeliverCallback { 34 | 35 | /** 36 | * Called when a basic.deliver is received for this consumer. 37 | * @param consumerTag the consumer tag associated with the consumer 38 | * @param message the delivered message 39 | * @throws IOException if the consumer encounters an I/O error while processing the message 40 | */ 41 | void handle(String consumerTag, Delivery message) throws IOException; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/Delivery.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * Encapsulates an arbitrary message - simple "bean" holder structure. 20 | */ 21 | public class Delivery { 22 | private final Envelope _envelope; 23 | private final AMQP.BasicProperties _properties; 24 | private final byte[] _body; 25 | 26 | public Delivery(Envelope envelope, AMQP.BasicProperties properties, byte[] body) { 27 | _envelope = envelope; 28 | _properties = properties; 29 | _body = body; 30 | } 31 | 32 | /** 33 | * Retrieve the message envelope. 34 | * @return the message envelope 35 | */ 36 | public Envelope getEnvelope() { 37 | return _envelope; 38 | } 39 | 40 | /** 41 | * Retrieve the message properties. 42 | * @return the message properties 43 | */ 44 | public AMQP.BasicProperties getProperties() { 45 | return _properties; 46 | } 47 | 48 | /** 49 | * Retrieve the message body. 50 | * @return the message body 51 | */ 52 | public byte[] getBody() { 53 | return _body; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ListAddressResolver.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * Simple implementation of {@link AddressResolver} that returns a fixed list. 22 | */ 23 | public class ListAddressResolver implements AddressResolver { 24 | 25 | private final List
addresses; 26 | 27 | public ListAddressResolver(List
addresses) { 28 | this.addresses = addresses; 29 | } 30 | 31 | @Override 32 | public List
getAddresses() { 33 | return addresses; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/MalformedFrameException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Encapsulates a frame format error at the wire level. 23 | */ 24 | public class MalformedFrameException extends IOException { 25 | /** Standard serialization ID. */ 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Instantiate a MalformedFrameException. 30 | * @param reason a string describing the exception 31 | */ 32 | public MalformedFrameException(String reason) { 33 | super(reason); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/Method.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | /** 20 | * Public interface to objects representing an AMQP 0-9-1 method 21 | * @see https://www.rabbitmq.com/specification.html. 22 | */ 23 | 24 | public interface Method { 25 | /** 26 | * Retrieve the protocol class ID 27 | * @return the AMQP protocol class ID of this Method 28 | */ 29 | int protocolClassId(); /* properly an unsigned short */ 30 | 31 | /** 32 | * Retrieve the protocol method ID 33 | * @return the AMQP protocol method ID of this Method 34 | */ 35 | int protocolMethodId(); /* properly an unsigned short */ 36 | 37 | /** 38 | * Retrieve the method name 39 | * @return the AMQP protocol method name of this Method 40 | */ 41 | String protocolMethodName(); 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/MissedHeartbeatException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.net.SocketTimeoutException; 20 | 21 | /** 22 | * Encapsulates an exception indicating that the connection has missed too many heartbeats 23 | * and is being shut down. 24 | */ 25 | 26 | public class MissedHeartbeatException extends SocketTimeoutException { 27 | private static final long serialVersionUID = 1L; 28 | 29 | public MissedHeartbeatException(String reason) { 30 | super(reason); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/PossibleAuthenticationFailureException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Thrown when the likely cause is an authentication failure. 22 | */ 23 | public class PossibleAuthenticationFailureException extends IOException 24 | { 25 | /** Default for non-checking. */ 26 | private static final long serialVersionUID = 1L; 27 | 28 | public PossibleAuthenticationFailureException(Throwable cause) 29 | { 30 | super("Possibly caused by authentication failure"); 31 | super.initCause(cause); 32 | } 33 | 34 | public PossibleAuthenticationFailureException(String reason) 35 | { 36 | super(reason); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/Recoverable.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * Provides a way to register (network, AMQP 0-9-1) connection recovery 20 | * callbacks. 21 | * 22 | * When connection recovery is enabled via {@link ConnectionFactory}, 23 | * {@link ConnectionFactory#newConnection()} and {@link Connection#createChannel()} 24 | * return {@link Recoverable} connections and channels. 25 | * 26 | * @see com.rabbitmq.client.impl.recovery.AutorecoveringConnection 27 | * @see com.rabbitmq.client.impl.recovery.AutorecoveringChannel 28 | */ 29 | public interface Recoverable { 30 | /** 31 | * Registers a connection recovery callback. 32 | * 33 | * @param listener Callback function 34 | */ 35 | void addRecoveryListener(RecoveryListener listener); 36 | 37 | void removeRecoveryListener(RecoveryListener listener); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/RecoverableChannel.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client; 2 | 3 | import com.rabbitmq.client.Channel; 4 | import com.rabbitmq.client.Recoverable; 5 | 6 | /** 7 | * Convenient interface when working against auto-recovery channels. 8 | * 9 | * @since 4.0.0 10 | */ 11 | public interface RecoverableChannel extends Recoverable, Channel { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/RecoverableConnection.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client; 2 | 3 | /** 4 | * Convenient interface when working against auto-recovery connections. 5 | * 6 | * @since 4.0.0 7 | */ 8 | public interface RecoverableConnection extends Recoverable, Connection { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/RecoveryListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * A RecoveryListener receives notifications about completed automatic connection 20 | * recovery. 21 | * 22 | * @since 3.3.0 23 | */ 24 | public interface RecoveryListener { 25 | /** 26 | * Invoked when automatic connection recovery has completed. 27 | * This includes topology recovery if it was enabled. 28 | * @param recoverable a {@link Recoverable} connection. 29 | */ 30 | void handleRecovery(Recoverable recoverable); 31 | 32 | /** 33 | * Invoked before automatic connection recovery starts. 34 | * This means no recovery steps were performed at this point 35 | * during recovery process. 36 | * @param recoverable a {@link Recoverable} connection. 37 | */ 38 | void handleRecoveryStarted(Recoverable recoverable); 39 | 40 | /** 41 | * Invoked before automatic topology recovery starts. 42 | * This means that the connection and channel recovery has completed 43 | * and that exchange/queue/binding/consumer recovery is about to begin. 44 | * @param recoverable a {@link Recoverable} connection. 45 | */ 46 | default void handleTopologyRecoveryStarted(Recoverable recoverable) {} 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ResolvedInetAddress.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client; 2 | 3 | import java.net.InetAddress; 4 | import java.net.InetSocketAddress; 5 | 6 | public class ResolvedInetAddress extends Address { 7 | private final InetAddress inetAddress; 8 | 9 | public ResolvedInetAddress(String originalHostname, InetAddress inetAddress, int port) { 10 | super(originalHostname, port); 11 | this.inetAddress = inetAddress; 12 | } 13 | 14 | @Override 15 | public InetSocketAddress toInetSocketAddress(int port) { 16 | return new InetSocketAddress(inetAddress, port); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/Return.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * 20 | */ 21 | public class Return { 22 | 23 | private final int replyCode; 24 | private final String replyText; 25 | private final String exchange; 26 | private final String routingKey; 27 | private final AMQP.BasicProperties properties; 28 | private final byte[] body; 29 | 30 | public Return(int replyCode, String replyText, String exchange, String routingKey, AMQP.BasicProperties properties, byte[] body) { 31 | this.replyCode = replyCode; 32 | this.replyText = replyText; 33 | this.exchange = exchange; 34 | this.routingKey = routingKey; 35 | this.properties = properties; 36 | this.body = body; 37 | } 38 | 39 | public int getReplyCode() { 40 | return replyCode; 41 | } 42 | 43 | public String getReplyText() { 44 | return replyText; 45 | } 46 | 47 | public String getExchange() { 48 | return exchange; 49 | } 50 | 51 | public String getRoutingKey() { 52 | return routingKey; 53 | } 54 | 55 | public AMQP.BasicProperties getProperties() { 56 | return properties; 57 | } 58 | 59 | public byte[] getBody() { 60 | return body; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ReturnCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * Implement this interface in order to be notified of failed 20 | * deliveries when basicPublish is called with "mandatory" or 21 | * "immediate" flags set. 22 | * Prefer this interface over {@link ReturnListener} for 23 | * a simpler, lambda-oriented syntax. 24 | * @see Channel#basicPublish 25 | * @see ReturnListener 26 | * @see Return 27 | */ 28 | @FunctionalInterface 29 | public interface ReturnCallback { 30 | 31 | void handle(Return returnMessage); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ReturnListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Implement this interface in order to be notified of failed 23 | * deliveries when basicPublish is called with "mandatory" or 24 | * "immediate" flags set. 25 | * For a lambda-oriented syntax, use {@link ReturnCallback}. 26 | * @see Channel#basicPublish 27 | */ 28 | public interface ReturnListener { 29 | void handleReturn(int replyCode, 30 | String replyText, 31 | String exchange, 32 | String routingKey, 33 | AMQP.BasicProperties properties, 34 | byte[] body) 35 | throws IOException; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/SaslConfig.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * This interface represents a hook to allow you to control how exactly 20 | * a sasl client is selected during authentication. 21 | * @see com.rabbitmq.client.ConnectionFactory 22 | */ 23 | public interface SaslConfig { 24 | SaslMechanism getSaslMechanism(String[] mechanisms); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/SaslMechanism.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * Our own view of a SASL authentication mechanism, introduced to remove a 20 | * dependency on javax.security.sasl. 21 | */ 22 | public interface SaslMechanism { 23 | /** 24 | * The name of this mechanism (e.g. PLAIN) 25 | * @return the name 26 | */ 27 | String getName(); 28 | 29 | /** 30 | * Handle one round of challenge-response 31 | * @param challenge the challenge this round, or null on first round. 32 | * @param username name of user 33 | * @param password for username 34 | * @return response 35 | */ 36 | LongString handleChallenge(LongString challenge, String username, String password); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/ShutdownListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.util.EventListener; 20 | 21 | /** 22 | * A ShutdownListener receives information about the shutdown of connections and 23 | * channels. Note that when a connection is shut down, its associated channels are also 24 | * considered shut down and their ShutdownListeners will be notified (with the same cause). 25 | * Because of this, and the fact that channel ShutdownListeners execute in the connection's 26 | * thread, attempting to make blocking calls on a connection inside the listener will 27 | * lead to deadlock. 28 | * 29 | * @see ShutdownNotifier 30 | * @see ShutdownSignalException 31 | */ 32 | @FunctionalInterface 33 | public interface ShutdownListener extends EventListener { 34 | void shutdownCompleted(ShutdownSignalException cause); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/SocketChannelConfigurator.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | import java.nio.channels.SocketChannel; 20 | import java.util.Objects; 21 | 22 | @FunctionalInterface 23 | public interface SocketChannelConfigurator { 24 | 25 | /** 26 | * Provides a hook to insert custom configuration of the {@link SocketChannel}s 27 | * used to connect to an AMQP server before they connect. 28 | */ 29 | void configure(SocketChannel socketChannel) throws IOException; 30 | 31 | /** 32 | * Returns a composed configurator that performs, in sequence, this 33 | * operation followed by the {@code after} operation. 34 | * 35 | * @param after the operation to perform after this operation 36 | * @return a composed configurator that performs in sequence this 37 | * operation followed by the {@code after} operation 38 | * @throws NullPointerException if {@code after} is null 39 | */ 40 | default SocketChannelConfigurator andThen(SocketChannelConfigurator after) { 41 | Objects.requireNonNull(after); 42 | return t -> { configure(t); after.configure(t); }; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/SocketConfigurator.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | import java.net.Socket; 20 | import java.util.Objects; 21 | 22 | @FunctionalInterface 23 | public interface SocketConfigurator { 24 | 25 | /** 26 | * Provides a hook to insert custom configuration of the sockets 27 | * used to connect to an AMQP server before they connect. 28 | */ 29 | void configure(Socket socket) throws IOException; 30 | 31 | /** 32 | * Returns a composed configurator that performs, in sequence, this 33 | * operation followed by the {@code after} operation. 34 | * 35 | * @param after the operation to perform after this operation 36 | * @return a composed configurator that performs in sequence this 37 | * operation followed by the {@code after} operation 38 | * @throws NullPointerException if {@code after} is null 39 | */ 40 | default SocketConfigurator andThen(SocketConfigurator after) { 41 | Objects.requireNonNull(after); 42 | return t -> { 43 | configure(t); 44 | after.configure(t); 45 | }; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/SslContextFactory.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import javax.net.ssl.SSLContext; 19 | 20 | /** 21 | * A factory to create {@link SSLContext}s. 22 | * 23 | * @see ConnectionFactory#setSslContextFactory(SslContextFactory) 24 | * @since 5.0.0 25 | */ 26 | public interface SslContextFactory { 27 | 28 | /** 29 | * Create a {@link SSLContext} for a given name. 30 | * The name is typically the name of the connection. 31 | * @param name name of the connection the SSLContext is used for 32 | * @return the SSLContext for this name 33 | * @see ConnectionFactory#newConnection(String) 34 | */ 35 | SSLContext create(String name); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/SslEngineConfigurator.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import javax.net.ssl.SSLEngine; 19 | import java.io.IOException; 20 | import java.util.Objects; 21 | 22 | @FunctionalInterface 23 | public interface SslEngineConfigurator { 24 | 25 | /** 26 | * Provides a hook to insert custom configuration of the {@link SSLEngine}s 27 | * used to connect to an AMQP server before they connect. 28 | * Note this is used only when NIO are in use. 29 | */ 30 | void configure(SSLEngine sslEngine) throws IOException; 31 | 32 | /** 33 | * Returns a composed configurator that performs, in sequence, this 34 | * operation followed by the {@code after} operation. 35 | * 36 | * @param after the operation to perform after this operation 37 | * @return a composed configurator that performs in sequence this 38 | * operation followed by the {@code after} operation 39 | * @throws NullPointerException if {@code after} is null 40 | */ 41 | default SslEngineConfigurator andThen(SslEngineConfigurator after) { 42 | Objects.requireNonNull(after); 43 | return t -> { configure(t); after.configure(t); }; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/TopologyRecoveryException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import com.rabbitmq.client.impl.recovery.RecordedEntity; 19 | 20 | /** 21 | * Indicates an exception thrown during topology recovery. 22 | * 23 | * @see com.rabbitmq.client.ConnectionFactory#setTopologyRecoveryEnabled(boolean) 24 | * @since 3.3.0 25 | */ 26 | public class TopologyRecoveryException extends Exception { 27 | 28 | private final RecordedEntity recordedEntity; 29 | 30 | public TopologyRecoveryException(String message, Throwable cause) { 31 | this(message, cause, null); 32 | } 33 | 34 | public TopologyRecoveryException(String message, Throwable cause, final RecordedEntity recordedEntity) { 35 | super(message, cause); 36 | this.recordedEntity = recordedEntity; 37 | } 38 | 39 | public RecordedEntity getRecordedEntity() { 40 | return recordedEntity; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/TrafficListener.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client; 2 | 3 | /** 4 | * Contract to log outbound and inbound {@link Command}s. 5 | * 6 | * @see ConnectionFactory#setTrafficListener(TrafficListener) 7 | * @since 5.5.0 8 | */ 9 | public interface TrafficListener { 10 | 11 | /** 12 | * No-op {@link TrafficListener}. 13 | */ 14 | TrafficListener NO_OP = new TrafficListener() { 15 | 16 | @Override 17 | public void write(Command outboundCommand) { 18 | 19 | } 20 | 21 | @Override 22 | public void read(Command inboundCommand) { 23 | 24 | } 25 | }; 26 | 27 | /** 28 | * Notified for each outbound {@link Command}. 29 | * 30 | * @param outboundCommand 31 | */ 32 | void write(Command outboundCommand); 33 | 34 | /** 35 | * Notified for each inbound {@link Command}. 36 | * 37 | * @param inboundCommand 38 | */ 39 | void read(Command inboundCommand); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/UnblockedCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Implement this interface in order to be notified of connection unblock events. 22 | * Prefer it over {@link BlockedListener} for a lambda-oriented syntax. 23 | * @see BlockedListener 24 | * @see BlockedCallback 25 | */ 26 | @FunctionalInterface 27 | public interface UnblockedCallback { 28 | 29 | void handle() throws IOException; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/UnexpectedFrameError.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import com.rabbitmq.client.impl.Frame; 20 | 21 | /** 22 | * Thrown when the command parser hits an unexpected frame type. 23 | */ 24 | public class UnexpectedFrameError extends RuntimeException { 25 | private static final long serialVersionUID = 1L; 26 | private final Frame _frame; 27 | private final int _expectedFrameType; 28 | 29 | public UnexpectedFrameError(Frame frame, int expectedFrameType) { 30 | super("Received frame: " + frame + ", expected type " + expectedFrameType); 31 | _frame = frame; 32 | _expectedFrameType = expectedFrameType; 33 | } 34 | 35 | public static long getSerialVersionUID() { 36 | return serialVersionUID; 37 | } 38 | 39 | public Frame getReceivedFrame() { 40 | return _frame; 41 | } 42 | 43 | public int getExpectedFrameType() { 44 | return _expectedFrameType; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/UnknownClassOrMethodId.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Thrown when the protocol handlers detect an unknown class number or 23 | * method number. 24 | */ 25 | public class UnknownClassOrMethodId extends IOException { 26 | private static final long serialVersionUID = 1L; 27 | private static final int NO_METHOD_ID = -1; 28 | public final int classId; 29 | public final int methodId; 30 | public UnknownClassOrMethodId(int classId) { 31 | this(classId, NO_METHOD_ID); 32 | } 33 | public UnknownClassOrMethodId(int classId, int methodId) { 34 | this.classId = classId; 35 | this.methodId = methodId; 36 | } 37 | @Override 38 | public String toString() { 39 | if (this.methodId == NO_METHOD_ID) { 40 | return super.toString() + "<" + classId + ">"; 41 | } else { 42 | return super.toString() + "<" + classId + "." + methodId + ">"; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/UnroutableRpcRequestException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client; 17 | 18 | /** 19 | * Exception thrown when a RPC request isn't routed to any queue. 20 | *

21 | * The {@link RpcClient} must be configured with the mandatory 22 | * flag set to true with {@link RpcClientParams#useMandatory()}. 23 | * 24 | * @see RpcClientParams#useMandatory() 25 | * @see RpcClient#RpcClient(RpcClientParams) 26 | * @since 5.6.0 27 | */ 28 | public class UnroutableRpcRequestException extends RuntimeException { 29 | 30 | private final Return returnMessage; 31 | 32 | public UnroutableRpcRequestException(Return returnMessage) { 33 | this.returnMessage = returnMessage; 34 | } 35 | 36 | /** 37 | * The returned message. 38 | * 39 | * @return 40 | */ 41 | public Return getReturnMessage() { 42 | return returnMessage; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/AMQBasicProperties.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import java.io.DataInputStream; 19 | import java.io.IOException; 20 | 21 | import com.rabbitmq.client.BasicProperties; 22 | 23 | public abstract class AMQBasicProperties 24 | extends AMQContentHeader implements BasicProperties { 25 | 26 | protected AMQBasicProperties() { 27 | 28 | } 29 | 30 | protected AMQBasicProperties(DataInputStream in) throws IOException { 31 | super(in); 32 | } 33 | 34 | @Override 35 | public Object clone() throws CloneNotSupportedException { 36 | return super.clone(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/AbstractFrameHandlerFactory.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.SocketConfigurator; 19 | 20 | /** 21 | * 22 | */ 23 | public abstract class AbstractFrameHandlerFactory implements FrameHandlerFactory { 24 | 25 | protected final int connectionTimeout; 26 | protected final SocketConfigurator configurator; 27 | protected final boolean ssl; 28 | protected final int maxInboundMessageBodySize; 29 | 30 | protected AbstractFrameHandlerFactory(int connectionTimeout, SocketConfigurator configurator, 31 | boolean ssl, int maxInboundMessageBodySize) { 32 | this.connectionTimeout = connectionTimeout; 33 | this.configurator = configurator; 34 | this.ssl = ssl; 35 | this.maxInboundMessageBodySize = maxInboundMessageBodySize; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/AnonymousMechanism.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom 2 | // Inc. and/or its subsidiaries. 3 | // 4 | // This software, the RabbitMQ Java client library, is triple-licensed under the 5 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 6 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 7 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 8 | // please see LICENSE-APACHE2. 9 | // 10 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 11 | // either express or implied. See the LICENSE file for specific language governing 12 | // rights and limitations of this software. 13 | // 14 | // If you have any questions regarding licensing, please contact us at 15 | // info@rabbitmq.com. 16 | 17 | package com.rabbitmq.client.impl; 18 | 19 | import com.rabbitmq.client.LongString; 20 | import com.rabbitmq.client.SaslMechanism; 21 | 22 | /** 23 | * The ANONYMOUS auth mechanism 24 | * 25 | *

Requires RabbitMQ 4.0 or more. 26 | */ 27 | public class AnonymousMechanism implements SaslMechanism { 28 | @Override 29 | public String getName() { 30 | return "ANONYMOUS"; 31 | } 32 | 33 | @Override 34 | public LongString handleChallenge(LongString challenge, String username, String password) { 35 | return LongStringHelper.asLongString(""); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/CompletableFutureRpcWrapper.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.*; 19 | import com.rabbitmq.client.Method; 20 | 21 | import java.util.concurrent.CompletableFuture; 22 | 23 | /** 24 | * 25 | */ 26 | public class CompletableFutureRpcWrapper implements RpcWrapper { 27 | 28 | private final com.rabbitmq.client.Method request; 29 | 30 | private final CompletableFuture completableFuture; 31 | 32 | public CompletableFutureRpcWrapper(Method method, CompletableFuture completableFuture) { 33 | this.request = method; 34 | this.completableFuture = completableFuture; 35 | } 36 | 37 | @Override 38 | public boolean canHandleReply(AMQCommand command) { 39 | return AMQChannel.SimpleBlockingRpcContinuation.isResponseCompatibleWithRequest(request, command.getMethod()); 40 | } 41 | 42 | @Override 43 | public void complete(AMQCommand command) { 44 | completableFuture.complete(command); 45 | } 46 | 47 | @Override 48 | public void shutdown(ShutdownSignalException signal) { 49 | completableFuture.completeExceptionally(signal); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/DefaultCredentialsProvider.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | /** 19 | * Default implementation of a CredentialsProvider which simply holds a static 20 | * username and password. 21 | * 22 | * @since 4.5.0 23 | */ 24 | public class DefaultCredentialsProvider implements CredentialsProvider { 25 | 26 | private final String username; 27 | private final String password; 28 | 29 | public DefaultCredentialsProvider(String username, String password) { 30 | this.username = username; 31 | this.password = password; 32 | } 33 | 34 | @Override 35 | public String getUsername() { 36 | return username; 37 | } 38 | 39 | @Override 40 | public String getPassword() { 41 | return password; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/DefaultExceptionHandler.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.ExceptionHandler; 19 | 20 | /** 21 | * Default implementation of {@link com.rabbitmq.client.ExceptionHandler} 22 | * used by {@link AMQConnection}. 23 | */ 24 | public class DefaultExceptionHandler extends StrictExceptionHandler implements ExceptionHandler { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/Environment.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import java.util.concurrent.ThreadFactory; 19 | 20 | /** 21 | * Infers information about the execution environment, e.g. 22 | * security permissions. 23 | * Package-protected API. 24 | */ 25 | public class Environment { 26 | 27 | /** 28 | * This method is deprecated and subject to removal in the next major release. 29 | * 30 | * There is no replacement for this method, as it used to use the 31 | * {@link SecurityManager}, which is itself deprecated and subject to removal. 32 | * @deprecated 33 | * @return always returns true 34 | */ 35 | @Deprecated 36 | public static boolean isAllowedToModifyThreads() { 37 | return true; 38 | } 39 | 40 | public static Thread newThread(ThreadFactory factory, Runnable runnable, String name) { 41 | Thread t = factory.newThread(runnable); 42 | t.setName(name); 43 | return t; 44 | } 45 | 46 | public static Thread newThread(ThreadFactory factory, Runnable runnable, String name, boolean isDaemon) { 47 | Thread t = newThread(factory, runnable, name); 48 | t.setDaemon(isDaemon); 49 | return t; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/ErrorOnWriteListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.Connection; 19 | 20 | import java.io.IOException; 21 | 22 | /** 23 | * Listener called when a connection gets an IO error trying to write on the socket. 24 | * This can be used to trigger connection recovery. 25 | * 26 | * @since 4.5.0 27 | */ 28 | public interface ErrorOnWriteListener { 29 | 30 | /** 31 | * Called when writing to the socket failed 32 | * @param connection the owning connection instance 33 | * @param exception the thrown exception 34 | */ 35 | void handle(Connection connection, IOException exception) throws IOException; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/ExternalMechanism.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.LongString; 19 | import com.rabbitmq.client.SaslMechanism; 20 | 21 | /** 22 | * The EXTERNAL auth mechanism 23 | */ 24 | public class ExternalMechanism implements SaslMechanism { 25 | @Override 26 | public String getName() { 27 | return "EXTERNAL"; 28 | } 29 | 30 | @Override 31 | public LongString handleChallenge(LongString challenge, String username, String password) { 32 | return LongStringHelper.asLongString(""); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/FrameHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl; 2 | 3 | import com.rabbitmq.client.Address; 4 | 5 | import java.io.IOException; 6 | 7 | /** 8 | * 9 | */ 10 | public interface FrameHandlerFactory { 11 | 12 | FrameHandler create(Address addr, String connectionName) throws IOException; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/LogTrafficListener.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl; 2 | 3 | import com.rabbitmq.client.Command; 4 | import com.rabbitmq.client.TrafficListener; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * {@link TrafficListener} that logs {@link Command} at TRACE level. 10 | *

11 | * This implementation checks whether the TRACE log level 12 | * is enabled before logging anything. This {@link TrafficListener} 13 | * should only be activated for debugging purposes, not in a production 14 | * environment. 15 | * 16 | * @see TrafficListener 17 | * @see com.rabbitmq.client.ConnectionFactory#setTrafficListener(TrafficListener) 18 | * @since 5.5.0 19 | */ 20 | public class LogTrafficListener implements TrafficListener { 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(LogTrafficListener.class); 23 | 24 | @Override 25 | public void write(Command outboundCommand) { 26 | if (shouldLog(outboundCommand)) { 27 | LOGGER.trace("Outbound command: {}", outboundCommand); 28 | } 29 | } 30 | 31 | @Override 32 | public void read(Command inboundCommand) { 33 | if (shouldLog(inboundCommand)) { 34 | LOGGER.trace("Inbound command: {}", inboundCommand); 35 | } 36 | } 37 | 38 | protected boolean shouldLog(Command command) { 39 | return LOGGER.isTraceEnabled(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/NetworkConnection.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import java.net.InetAddress; 19 | 20 | public interface NetworkConnection { 21 | 22 | /** 23 | * Retrieve the local host. 24 | * @return the client socket address. 25 | */ 26 | InetAddress getLocalAddress(); 27 | 28 | /** 29 | * Retrieve the local port number. 30 | * @return the client socket port number 31 | */ 32 | int getLocalPort(); 33 | 34 | /** Retrieve address of peer. */ 35 | InetAddress getAddress(); 36 | 37 | /** Retrieve port number of peer. */ 38 | int getPort(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/OAuthTokenManagementException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | public class OAuthTokenManagementException extends RuntimeException { 19 | 20 | public OAuthTokenManagementException(String message, Throwable cause) { 21 | super(message, cause); 22 | } 23 | 24 | public OAuthTokenManagementException(String message) { 25 | super(message); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/PlainMechanism.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.LongString; 19 | import com.rabbitmq.client.SaslMechanism; 20 | 21 | /** 22 | * The PLAIN auth mechanism 23 | */ 24 | public class PlainMechanism implements SaslMechanism { 25 | @Override 26 | public String getName() { 27 | return "PLAIN"; 28 | } 29 | 30 | @Override 31 | public LongString handleChallenge(LongString challenge, 32 | String username, 33 | String password) { 34 | return LongStringHelper.asLongString("\0" + username + 35 | "\0" + password); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/RpcContinuationRpcWrapper.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.ShutdownSignalException; 19 | 20 | /** 21 | * 22 | */ 23 | public class RpcContinuationRpcWrapper implements RpcWrapper { 24 | 25 | private final AMQChannel.RpcContinuation continuation; 26 | 27 | public RpcContinuationRpcWrapper(AMQChannel.RpcContinuation continuation) { 28 | this.continuation = continuation; 29 | } 30 | 31 | @Override 32 | public boolean canHandleReply(AMQCommand command) { 33 | return continuation.canHandleReply(command); 34 | } 35 | 36 | @Override 37 | public void complete(AMQCommand command) { 38 | continuation.handleCommand(command); 39 | } 40 | 41 | @Override 42 | public void shutdown(ShutdownSignalException signal) { 43 | continuation.handleShutdownSignal(signal); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/RpcWrapper.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | import com.rabbitmq.client.ShutdownSignalException; 19 | 20 | /** 21 | * 22 | */ 23 | public interface RpcWrapper { 24 | 25 | boolean canHandleReply(AMQCommand command); 26 | 27 | void complete(AMQCommand command); 28 | 29 | void shutdown(ShutdownSignalException signal); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/UnknownChannelException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.impl; 18 | 19 | class UnknownChannelException extends RuntimeException { 20 | /** Default for non-checking. */ 21 | private static final long serialVersionUID = 1L; 22 | private final int channelNumber; 23 | 24 | public UnknownChannelException(int channelNumber) { 25 | super("Unknown channel number " + channelNumber); 26 | this.channelNumber = channelNumber; 27 | } 28 | 29 | public int getChannelNumber() { 30 | return channelNumber; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/Utils.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | final class Utils { 19 | 20 | private static final int AVAILABLE_PROCESSORS = 21 | Integer.parseInt( 22 | System.getProperty( 23 | "rabbitmq.amqp.client.availableProcessors", 24 | String.valueOf(Runtime.getRuntime().availableProcessors()))); 25 | 26 | static int availableProcessors() { 27 | return AVAILABLE_PROCESSORS; 28 | } 29 | 30 | private Utils() {} 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/WorkPoolFullException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl; 17 | 18 | /** 19 | * Exception thrown when {@link WorkPool} enqueueing times out. 20 | */ 21 | public class WorkPoolFullException extends RuntimeException { 22 | 23 | public WorkPoolFullException(String msg) { 24 | super(msg); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/BlockingQueueNioQueue.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl.nio; 2 | 3 | import java.util.concurrent.BlockingQueue; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | /** 7 | * Bridge between {@link NioQueue} and JDK's {@link BlockingQueue}. 8 | * 9 | * @see NioQueue 10 | * @since 5.5.0 11 | */ 12 | public class BlockingQueueNioQueue implements NioQueue { 13 | 14 | private final BlockingQueue delegate; 15 | private final int writeEnqueuingTimeoutInMs; 16 | 17 | public BlockingQueueNioQueue(BlockingQueue delegate, int writeEnqueuingTimeoutInMs) { 18 | this.delegate = delegate; 19 | this.writeEnqueuingTimeoutInMs = writeEnqueuingTimeoutInMs; 20 | } 21 | 22 | @Override 23 | public boolean offer(WriteRequest writeRequest) throws InterruptedException { 24 | return this.delegate.offer(writeRequest, writeEnqueuingTimeoutInMs, TimeUnit.MILLISECONDS); 25 | } 26 | 27 | @Override 28 | public int size() { 29 | return this.delegate.size(); 30 | } 31 | 32 | @Override 33 | public WriteRequest poll() { 34 | return this.delegate.poll(); 35 | } 36 | 37 | @Override 38 | public boolean isEmpty() { 39 | return this.delegate.isEmpty(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/ByteBufferFactory.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl.nio; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /** 6 | * Contract to create {@link ByteBuffer}s. 7 | * 8 | * @see NioParams 9 | * @since 5.5.0 10 | */ 11 | public interface ByteBufferFactory { 12 | 13 | /** 14 | * Create the {@link ByteBuffer} that contains inbound frames. 15 | * This buffer is the network buffer for plain connections. 16 | * When using SSL/TLS, this buffer isn't directly connected to 17 | * the network, the encrypted read buffer is. 18 | * 19 | * @param nioContext 20 | * @return 21 | */ 22 | ByteBuffer createReadBuffer(NioContext nioContext); 23 | 24 | /** 25 | * Create the {@link ByteBuffer} that contains outbound frames. 26 | * This buffer is the network buffer for plain connections. 27 | * When using SSL/TLS, this buffer isn't directed connected to 28 | * the network, the encrypted write buffer is. 29 | * 30 | * @param nioContext 31 | * @return 32 | */ 33 | ByteBuffer createWriteBuffer(NioContext nioContext); 34 | 35 | /** 36 | * Create the network read {@link ByteBuffer}. 37 | * This buffer contains encrypted frames read from the network. 38 | * The {@link javax.net.ssl.SSLEngine} decrypts frame and pass them 39 | * over to the read buffer. 40 | * 41 | * @param nioContext 42 | * @return 43 | */ 44 | ByteBuffer createEncryptedReadBuffer(NioContext nioContext); 45 | 46 | /** 47 | * Create the network write {@link ByteBuffer}. 48 | * This buffer contains encrypted outbound frames. These 49 | * frames come from the write buffer that sends them through 50 | * the {@link javax.net.ssl.SSLContext} for encryption to 51 | * this buffer. 52 | * 53 | * @param nioContext 54 | * @return 55 | */ 56 | ByteBuffer createEncryptedWriteBuffer(NioContext nioContext); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/ByteBufferOutputStream.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | import java.io.IOException; 19 | import java.io.OutputStream; 20 | import java.nio.ByteBuffer; 21 | import java.nio.channels.WritableByteChannel; 22 | 23 | /** 24 | * Bridge between the byte buffer and stream worlds. 25 | */ 26 | public class ByteBufferOutputStream extends OutputStream { 27 | 28 | private final WritableByteChannel channel; 29 | 30 | private final ByteBuffer buffer; 31 | 32 | public ByteBufferOutputStream(WritableByteChannel channel, ByteBuffer buffer) { 33 | this.buffer = buffer; 34 | this.channel = channel; 35 | } 36 | 37 | @Override 38 | public void write(int b) throws IOException { 39 | if(!buffer.hasRemaining()) { 40 | drain(channel, buffer); 41 | } 42 | buffer.put((byte) b); 43 | } 44 | 45 | @Override 46 | public void flush() throws IOException { 47 | drain(channel, buffer); 48 | } 49 | 50 | public static void drain(WritableByteChannel channel, ByteBuffer buffer) throws IOException { 51 | buffer.flip(); 52 | while(buffer.hasRemaining() && channel.write(buffer) != -1); 53 | buffer.clear(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/FrameWriteRequest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | import com.rabbitmq.client.impl.Frame; 19 | 20 | import java.io.DataOutputStream; 21 | import java.io.IOException; 22 | 23 | /** 24 | * 25 | */ 26 | public class FrameWriteRequest implements WriteRequest { 27 | 28 | final Frame frame; 29 | 30 | public FrameWriteRequest(Frame frame) { 31 | this.frame = frame; 32 | } 33 | 34 | @Override 35 | public void handle(DataOutputStream outputStream) throws IOException { 36 | frame.writeTo(outputStream); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/HeaderWriteRequest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | import com.rabbitmq.client.AMQP; 19 | 20 | import java.io.DataOutputStream; 21 | import java.io.IOException; 22 | 23 | /** 24 | * 25 | */ 26 | public class HeaderWriteRequest implements WriteRequest { 27 | 28 | public static final WriteRequest SINGLETON = new HeaderWriteRequest(); 29 | 30 | private HeaderWriteRequest() { } 31 | 32 | @Override 33 | public void handle(DataOutputStream outputStream) throws IOException { 34 | outputStream.write("AMQP".getBytes("US-ASCII")); 35 | outputStream.write(0); 36 | outputStream.write(AMQP.PROTOCOL.MAJOR); 37 | outputStream.write(AMQP.PROTOCOL.MINOR); 38 | outputStream.write(AMQP.PROTOCOL.REVISION); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/NioContext.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl.nio; 2 | 3 | import javax.net.ssl.SSLEngine; 4 | 5 | /** 6 | * Context when creating resources for a NIO-based connection. 7 | * 8 | * @see ByteBufferFactory 9 | * @since 5.5.0 10 | */ 11 | public class NioContext { 12 | 13 | private final NioParams nioParams; 14 | 15 | private final SSLEngine sslEngine; 16 | 17 | NioContext(NioParams nioParams, SSLEngine sslEngine) { 18 | this.nioParams = nioParams; 19 | this.sslEngine = sslEngine; 20 | } 21 | 22 | /** 23 | * NIO params. 24 | * 25 | * @return 26 | */ 27 | public NioParams getNioParams() { 28 | return nioParams; 29 | } 30 | 31 | /** 32 | * {@link SSLEngine} for SSL/TLS connection. 33 | * Null for plain connection. 34 | * 35 | * @return 36 | */ 37 | public SSLEngine getSslEngine() { 38 | return sslEngine; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/NioHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | import java.io.IOException; 19 | import java.nio.ByteBuffer; 20 | import java.nio.channels.ReadableByteChannel; 21 | 22 | public class NioHelper { 23 | 24 | static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException { 25 | int read = channel.read(buffer); 26 | if(read < 0) { 27 | throw new IOException("I/O thread: reached EOF"); 28 | } 29 | return read; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/NioQueue.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl.nio; 2 | 3 | /** 4 | * Contract to exchange frame between application threads and NIO thread. 5 | *

6 | * This is a simplified subset of {@link java.util.concurrent.BlockingQueue}. 7 | * This interface is considered a SPI and is likely to move between 8 | * minor and patch releases. 9 | * 10 | * @see NioParams 11 | * @since 5.5.0 12 | */ 13 | public interface NioQueue { 14 | 15 | /** 16 | * Enqueue a frame, block if the queue is full. 17 | * 18 | * @param writeRequest 19 | * @return 20 | * @throws InterruptedException 21 | */ 22 | boolean offer(WriteRequest writeRequest) throws InterruptedException; 23 | 24 | /** 25 | * Get the current size of the queue. 26 | * 27 | * @return 28 | */ 29 | int size(); 30 | 31 | /** 32 | * Retrieves and removes the head of this queue, 33 | * or returns {@code null} if this queue is empty. 34 | * 35 | * @return the head of this queue, or {@code null} if this queue is empty 36 | */ 37 | WriteRequest poll(); 38 | 39 | /** 40 | * Returns {@code true} if the queue contains no element. 41 | * 42 | * @return {@code true} if the queue contains no element 43 | */ 44 | boolean isEmpty(); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/SelectorHolder.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | import java.nio.channels.Selector; 19 | import java.util.Collections; 20 | import java.util.Set; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | /** 24 | * 25 | */ 26 | public class SelectorHolder { 27 | 28 | final Selector selector; 29 | 30 | final Set registrations = Collections 31 | .newSetFromMap(new ConcurrentHashMap()); 32 | 33 | SelectorHolder(Selector selector) { 34 | this.selector = selector; 35 | } 36 | 37 | public void registerFrameHandlerState(SocketChannelFrameHandlerState state, int operations) { 38 | registrations.add(new SocketChannelRegistration(state, operations)); 39 | selector.wakeup(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/SocketChannelRegistration.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | /** 19 | * 20 | */ 21 | public class SocketChannelRegistration { 22 | 23 | final SocketChannelFrameHandlerState state; 24 | final int operations; 25 | 26 | public SocketChannelRegistration(SocketChannelFrameHandlerState state, int operations) { 27 | this.state = state; 28 | this.operations = operations; 29 | } 30 | 31 | @Override 32 | public boolean equals(Object o) { 33 | if (this == o) 34 | return true; 35 | if (o == null || getClass() != o.getClass()) 36 | return false; 37 | 38 | SocketChannelRegistration that = (SocketChannelRegistration) o; 39 | 40 | return state.getChannel().equals(that.state.getChannel()); 41 | } 42 | 43 | @Override 44 | public int hashCode() { 45 | return state.getChannel().hashCode(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/WriteRequest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.nio; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | /** 22 | * 23 | */ 24 | public interface WriteRequest { 25 | 26 | void handle(DataOutputStream dataOutputStream) throws IOException; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/nio/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * NIO network connector. 3 | */ 4 | package com.rabbitmq.client.impl.nio; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementations of interfaces specified in the client API, and their supporting classes. 3 | */ 4 | package com.rabbitmq.client.impl; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/BackoffPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | /** 19 | * Backoff policy for topology recovery retry attempts. 20 | * 21 | * @see DefaultRetryHandler 22 | * @see TopologyRecoveryRetryHandlerBuilder 23 | * @since 5.4.0 24 | */ 25 | @FunctionalInterface 26 | public interface BackoffPolicy { 27 | 28 | /** 29 | * Wait depending on the current attempt number (1, 2, 3, etc) 30 | * @param attemptNumber current attempt number 31 | * @throws InterruptedException 32 | */ 33 | void backoff(int attemptNumber) throws InterruptedException; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/ConsumerRecoveryListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | /** 19 | * Not part of the public API. Mean to be used by JVM RabbitMQ clients that build on 20 | * top of the Java client and need to be notified when consumer tag changes 21 | * after recovery. 22 | */ 23 | public interface ConsumerRecoveryListener { 24 | void consumerRecovered(String oldConsumerTag, String newConsumerTag); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/QueueRecoveryListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | /** 19 | * Not part of the public API. Mean to be used by JVM RabbitMQ clients that build on 20 | * top of the Java client and need to be notified when server-name queue name changes 21 | * after recovery. 22 | */ 23 | public interface QueueRecoveryListener { 24 | void queueRecovered(String oldName, String newName); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RecordedEntity.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | import com.rabbitmq.client.Channel; 19 | 20 | /** 21 | * @since 3.3.0 22 | */ 23 | public abstract class RecordedEntity { 24 | protected final AutorecoveringChannel channel; 25 | 26 | public RecordedEntity(AutorecoveringChannel channel) { 27 | this.channel = channel; 28 | } 29 | 30 | public AutorecoveringChannel getChannel() { 31 | return channel; 32 | } 33 | 34 | public Channel getDelegateChannel() { 35 | return channel.getDelegate(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RecordedExchangeBinding.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * @since 3.3.0 22 | */ 23 | public class RecordedExchangeBinding extends RecordedBinding { 24 | public RecordedExchangeBinding(AutorecoveringChannel channel) { 25 | super(channel); 26 | } 27 | 28 | @Override 29 | public void recover() throws IOException { 30 | this.channel.getDelegate().exchangeBind(this.destination, this.source, this.routingKey, this.arguments); 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "RecordedExchangeBinding[source=" + source + ", destination=" + destination + ", routingKey=" + routingKey + ", arguments=" + arguments + ", channel=" + channel + "]"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RecordedNamedEntity.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | import java.io.IOException; 19 | /** 20 | * @since 3.3.0 21 | */ 22 | public abstract class RecordedNamedEntity extends RecordedEntity { 23 | protected String name; 24 | 25 | public RecordedNamedEntity(AutorecoveringChannel channel, String name) { 26 | super(channel); 27 | this.name = name; 28 | } 29 | 30 | public abstract void recover() throws IOException; 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueueBinding.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * @since 3.3.0 22 | */ 23 | public class RecordedQueueBinding extends RecordedBinding { 24 | public RecordedQueueBinding(AutorecoveringChannel channel) { 25 | super(channel); 26 | } 27 | 28 | @Override 29 | public void recover() throws IOException { 30 | this.channel.getDelegate().queueBind(this.destination, this.source, this.routingKey, this.arguments); 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "RecordedQueueBinding[source=" + source + ", destination=" + destination + ", routingKey=" + routingKey + ", arguments=" + arguments + ", channel=" + channel + "]"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RecoveredQueueNameSupplier.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl.recovery; 2 | 3 | /** 4 | * Functional callback interface that can be used to rename a queue during topology recovery. 5 | * Can use along with {@link QueueRecoveryListener} to know when such a queue has been recovered successfully. 6 | * 7 | * @see QueueRecoveryListener 8 | */ 9 | @FunctionalInterface 10 | public interface RecoveredQueueNameSupplier { 11 | 12 | /** 13 | * Get the queue name to use when recovering this RecordedQueue entity 14 | * @param recordedQueue the queue to be recovered 15 | * @return new queue name 16 | */ 17 | String getNameToUseForRecovery(final RecordedQueue recordedQueue); 18 | } -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RecoveryCanBeginListener.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | import com.rabbitmq.client.ShutdownSignalException; 19 | 20 | /** 21 | * Used internally to indicate when connection recovery can 22 | * begin. 23 | * This is package-local by design. 24 | * 25 | * @see Issue 135 on GitHub 26 | */ 27 | public interface RecoveryCanBeginListener { 28 | void recoveryCanBegin(ShutdownSignalException cause); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/RetryResult.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | /** 19 | * The retry of a retriable topology recovery operation. 20 | * 21 | * @since 5.4.0 22 | */ 23 | public class RetryResult { 24 | 25 | /** 26 | * The entity to recover. 27 | */ 28 | private final RecordedEntity recordedEntity; 29 | 30 | /** 31 | * The result of the recovery operation. 32 | * E.g. a consumer tag when recovering a consumer. 33 | */ 34 | private final Object result; 35 | 36 | public RetryResult(RecordedEntity recordedEntity, Object result) { 37 | this.recordedEntity = recordedEntity; 38 | this.result = result; 39 | } 40 | 41 | /** 42 | * The entity to recover. 43 | * 44 | * @return 45 | */ 46 | public RecordedEntity getRecordedEntity() { 47 | return recordedEntity; 48 | } 49 | 50 | /** 51 | * The result of the recovery operation. 52 | * E.g. a consumer tag when recovering a consumer. 53 | */ 54 | public Object getResult() { 55 | return result; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/Utils.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.impl.recovery; 17 | 18 | import java.io.IOException; 19 | import java.util.concurrent.TimeoutException; 20 | 21 | final class Utils { 22 | 23 | private Utils() {} 24 | 25 | @FunctionalInterface 26 | interface IoTimeoutExceptionRunnable { 27 | 28 | void run() throws IOException, TimeoutException; 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/impl/recovery/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of connection and topology recovery. 3 | */ 4 | package com.rabbitmq.client.impl.recovery; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/observation/NoOpObservationCollector.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. 2 | // The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 3 | // 4 | // This software, the RabbitMQ Java client library, is triple-licensed under the 5 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 6 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 7 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 8 | // please see LICENSE-APACHE2. 9 | // 10 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 11 | // either express or implied. See the LICENSE file for specific language governing 12 | // rights and limitations of this software. 13 | // 14 | // If you have any questions regarding licensing, please contact us at 15 | // info@rabbitmq.com. 16 | package com.rabbitmq.client.observation; 17 | 18 | import com.rabbitmq.client.AMQP; 19 | import com.rabbitmq.client.Consumer; 20 | import com.rabbitmq.client.GetResponse; 21 | import java.io.IOException; 22 | 23 | final class NoOpObservationCollector implements ObservationCollector { 24 | 25 | @Override 26 | public void publish( 27 | PublishCall call, 28 | AMQP.Basic.Publish publish, 29 | AMQP.BasicProperties properties, 30 | byte[] body, 31 | ConnectionInfo connectionInfo) 32 | throws IOException { 33 | call.publish(properties); 34 | } 35 | 36 | @Override 37 | public Consumer basicConsume(String queue, String consumerTag, Consumer consumer) { 38 | return consumer; 39 | } 40 | 41 | @Override 42 | public GetResponse basicGet(BasicGetCall call, String queue) { 43 | return call.get(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/observation/micrometer/DefaultProcessObservationConvention.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. 2 | // The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 3 | // 4 | // This software, the RabbitMQ Java client library, is triple-licensed under the 5 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 6 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 7 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 8 | // please see LICENSE-APACHE2. 9 | // 10 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 11 | // either express or implied. See the LICENSE file for specific language governing 12 | // rights and limitations of this software. 13 | // 14 | // If you have any questions regarding licensing, please contact us at 15 | // info@rabbitmq.com. 16 | package com.rabbitmq.client.observation.micrometer; 17 | 18 | public class DefaultProcessObservationConvention extends DefaultDeliverObservationConvention { 19 | 20 | public DefaultProcessObservationConvention(String operation) { 21 | super(operation); 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "rabbitmq.process"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/observation/micrometer/DefaultReceiveObservationConvention.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. 2 | // The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 3 | // 4 | // This software, the RabbitMQ Java client library, is triple-licensed under the 5 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 6 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 7 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 8 | // please see LICENSE-APACHE2. 9 | // 10 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 11 | // either express or implied. See the LICENSE file for specific language governing 12 | // rights and limitations of this software. 13 | // 14 | // If you have any questions regarding licensing, please contact us at 15 | // info@rabbitmq.com. 16 | package com.rabbitmq.client.observation.micrometer; 17 | 18 | public class DefaultReceiveObservationConvention extends DefaultDeliverObservationConvention { 19 | 20 | public DefaultReceiveObservationConvention(String operation) { 21 | super(operation); 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "rabbitmq.receive"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/observation/micrometer/DeliverObservationConvention.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. 2 | // The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 3 | // 4 | // This software, the RabbitMQ Java client library, is triple-licensed under the 5 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 6 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 7 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 8 | // please see LICENSE-APACHE2. 9 | // 10 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 11 | // either express or implied. See the LICENSE file for specific language governing 12 | // rights and limitations of this software. 13 | // 14 | // If you have any questions regarding licensing, please contact us at 15 | // info@rabbitmq.com. 16 | package com.rabbitmq.client.observation.micrometer; 17 | 18 | import io.micrometer.observation.Observation; 19 | import io.micrometer.observation.ObservationConvention; 20 | 21 | /** 22 | * {@link ObservationConvention} for RabbitMQ client instrumentation. 23 | * 24 | * @since 5.19.0 25 | */ 26 | public interface DeliverObservationConvention extends ObservationConvention { 27 | 28 | @Override 29 | default boolean supportsContext(Observation.Context context) { 30 | return context instanceof DeliverContext; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/observation/micrometer/PublishObservationConvention.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. 2 | // The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 3 | // 4 | // This software, the RabbitMQ Java client library, is triple-licensed under the 5 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 6 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 7 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 8 | // please see LICENSE-APACHE2. 9 | // 10 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 11 | // either express or implied. See the LICENSE file for specific language governing 12 | // rights and limitations of this software. 13 | // 14 | // If you have any questions regarding licensing, please contact us at 15 | // info@rabbitmq.com. 16 | package com.rabbitmq.client.observation.micrometer; 17 | 18 | import io.micrometer.observation.Observation; 19 | import io.micrometer.observation.ObservationConvention; 20 | 21 | /** 22 | * {@link ObservationConvention} for RabbitMQ client instrumentation. 23 | * 24 | * @since 5.19.0 25 | */ 26 | public interface PublishObservationConvention extends ObservationConvention { 27 | 28 | @Override 29 | default boolean supportsContext(Observation.Context context) { 30 | return context instanceof PublishContext; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/client/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The client API proper: classes and interfaces representing the AMQP 3 | * connections, channels, and wire-protocol framing descriptors. 4 | */ 5 | package com.rabbitmq.client; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/tools/json/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * JSON reader/writer and utility classes. 3 | */ 4 | package com.rabbitmq.tools.json; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/tools/jsonrpc/JsonRpcMappingException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.tools.jsonrpc; 17 | 18 | /** 19 | * 20 | * @since 5.4.0 21 | */ 22 | public class JsonRpcMappingException extends RuntimeException { 23 | 24 | public JsonRpcMappingException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/tools/jsonrpc/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * JSON-RPC client and server classes for supporting JSON-RPC over an AMQP transport. 3 | */ 4 | package com.rabbitmq.tools.jsonrpc; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/tools/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Non-core utilities and administration tools. 3 | */ 4 | package com.rabbitmq.tools; -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/utility/BlockingValueOrException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.utility; 17 | 18 | import java.util.concurrent.TimeoutException; 19 | 20 | public class BlockingValueOrException> 21 | extends BlockingCell> 22 | { 23 | public void setValue(V v) { 24 | super.set(ValueOrException.makeValue(v)); 25 | } 26 | 27 | public void setException(E e) { 28 | super.set(ValueOrException.makeException(e)); 29 | } 30 | 31 | public V uninterruptibleGetValue() throws E { 32 | return uninterruptibleGet().getValue(); 33 | } 34 | 35 | public V uninterruptibleGetValue(int timeout) throws E, TimeoutException { 36 | return uninterruptibleGet(timeout).getValue(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/utility/SensibleClone.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.utility; 17 | 18 | /** 19 | * This interface exists as a workaround for the annoyingness of java.lang.Cloneable. 20 | * It is used for generic methods which need to accept something they can actually clone 21 | * (Object.clone is protected and java.lang.Cloneable does not define a public clone method) 22 | * and want to provide some guarantees of the type of the cloned object. 23 | */ 24 | public interface SensibleClone> extends Cloneable { 25 | 26 | /** 27 | * Like Object.clone but sensible; in particular, public and declared to return 28 | * the right type. 29 | */ 30 | public T sensibleClone(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rabbitmq/utility/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utility package of helper classes, mostly used in the implementation code. 3 | */ 4 | package com.rabbitmq.utility; -------------------------------------------------------------------------------- /src/main/resources/META-INF/native-image/com.rabbitmq/amqp-client/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=-H:IncludeResources=rabbitmq-amqp-client.properties|version.properties 2 | -------------------------------------------------------------------------------- /src/main/resources/rabbitmq-amqp-client.properties: -------------------------------------------------------------------------------- 1 | com.rabbitmq.client.version = ${project.version} 2 | -------------------------------------------------------------------------------- /src/main/resources/version.properties: -------------------------------------------------------------------------------- 1 | # here for backward compatibility 2 | # use rabbitmq-amqp-client.properties to add or read properties 3 | com.rabbitmq.client.version = ${project.version} 4 | -------------------------------------------------------------------------------- /src/main/scripts/generate_amqp_sources.groovy: -------------------------------------------------------------------------------- 1 | import java.security.MessageDigest 2 | 3 | def md5(final file) { 4 | MessageDigest digest = MessageDigest.getInstance("MD5") 5 | file.withInputStream() { is -> 6 | byte[] buffer = new byte[8192] 7 | int read = 0 8 | while ((read = is.read(buffer)) > 0) { 9 | digest.update(buffer, 0, read); 10 | } 11 | } 12 | byte[] md5sum = digest.digest() 13 | BigInteger bigInt = new BigInteger(1, md5sum) 14 | return bigInt.toString(16) 15 | } 16 | 17 | def generate_source(final type, final filename) { 18 | String[] command = [ 19 | 'python', 20 | properties['script'], type, 21 | properties['spec'], 22 | filename 23 | ] 24 | 25 | def pb = new ProcessBuilder(command) 26 | pb.environment().put('PYTHONPATH', properties['codegen.dir']) 27 | pb.redirectErrorStream(true) 28 | 29 | def process = pb.start() 30 | process.waitFor() 31 | if (process.exitValue() != 0) { 32 | println(process.in.text.trim()) 33 | fail("Failed to generate ${filename} with command: ${command.join(' ')}") 34 | } 35 | } 36 | 37 | def maybe_regen_source(final type, final filename) { 38 | def file = new File(filename) 39 | 40 | if (file.exists()) { 41 | def tmp_filename = filename + '.new' 42 | def tmp_file = new File(tmp_filename) 43 | 44 | generate_source(type, tmp_filename) 45 | old_md5 = md5(file) 46 | new_md5 = md5(tmp_file) 47 | 48 | if (old_md5 == new_md5) { 49 | tmp_file.delete() 50 | } else { 51 | tmp_file.renameTo(file) 52 | } 53 | } else { 54 | generate_source(type, filename) 55 | } 56 | 57 | } 58 | 59 | maybe_regen_source('header', properties['header']) 60 | maybe_regen_source('body', properties['body']) 61 | -------------------------------------------------------------------------------- /src/test/java/SanityCheck.java: -------------------------------------------------------------------------------- 1 | ///usr/bin/env jbang "$0" "$@" ; exit $? 2 | //DEPS com.rabbitmq:amqp-client:${version} 3 | //DEPS org.slf4j:slf4j-simple:1.7.36 4 | 5 | import com.rabbitmq.client.AMQP; 6 | import com.rabbitmq.client.Channel; 7 | import com.rabbitmq.client.Connection; 8 | import com.rabbitmq.client.ConnectionFactory; 9 | import com.rabbitmq.client.DefaultConsumer; 10 | import com.rabbitmq.client.Envelope; 11 | import com.rabbitmq.client.impl.ClientVersion; 12 | import java.util.concurrent.CountDownLatch; 13 | import java.util.concurrent.TimeUnit; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | 17 | public class SanityCheck { 18 | 19 | private static final Logger LOGGER = LoggerFactory.getLogger("rabbitmq"); 20 | 21 | public static void main(String[] args) { 22 | try (Connection connection = new ConnectionFactory().newConnection()) { 23 | Channel ch = connection.createChannel(); 24 | String queue = ch.queueDeclare().getQueue(); 25 | CountDownLatch latch = new CountDownLatch(1); 26 | ch.basicConsume( 27 | queue, 28 | true, 29 | new DefaultConsumer(ch) { 30 | @Override 31 | public void handleDelivery( 32 | String consumerTag, 33 | Envelope envelope, 34 | AMQP.BasicProperties properties, 35 | byte[] body) { 36 | latch.countDown(); 37 | } 38 | }); 39 | ch.basicPublish("", queue, null, "test".getBytes()); 40 | boolean received = latch.await(5, TimeUnit.SECONDS); 41 | if (!received) { 42 | throw new IllegalStateException("Didn't receive message in 5 seconds"); 43 | } 44 | LOGGER.info("Test succeeded with Java client {}", ClientVersion.VERSION); 45 | System.exit(0); 46 | } catch (Exception e) { 47 | LOGGER.info("Test failed with Java client {}", ClientVersion.VERSION, e); 48 | System.exit(1); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/impl/recovery/AutorecoveringChannelTest.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.impl.recovery; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.junit.jupiter.api.Test; 5 | import org.mockito.Mock; 6 | import org.mockito.MockitoAnnotations; 7 | 8 | import static org.mockito.Mockito.times; 9 | import static org.mockito.Mockito.verify; 10 | 11 | public final class AutorecoveringChannelTest { 12 | 13 | private AutorecoveringChannel channel; 14 | 15 | @Mock 16 | private AutorecoveringConnection autorecoveringConnection; 17 | 18 | @Mock 19 | private RecoveryAwareChannelN recoveryAwareChannelN; 20 | 21 | @BeforeEach 22 | void setup() { 23 | MockitoAnnotations.openMocks(this); 24 | this.channel = new AutorecoveringChannel(autorecoveringConnection, recoveryAwareChannelN); 25 | } 26 | 27 | @Test 28 | void abort() { 29 | this.channel.abort(); 30 | verify(recoveryAwareChannelN, times(1)).abort(); 31 | } 32 | 33 | @Test 34 | void abortWithDetails() { 35 | int closeCode = 1; 36 | String closeMessage = "reason"; 37 | this.channel.abort(closeCode, closeMessage); 38 | verify(recoveryAwareChannelN, times(1)).abort(closeCode, closeMessage); 39 | } 40 | 41 | @Test 42 | void abortWithDetailsCloseMessageNull() { 43 | int closeCode = 1; 44 | this.channel.abort(closeCode, null); 45 | verify(recoveryAwareChannelN, times(1)).abort(closeCode, ""); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/ClientVersionTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test; 17 | 18 | import com.rabbitmq.client.impl.ClientVersion; 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | public class ClientVersionTest { 24 | 25 | @Test 26 | public void clientVersion() { 27 | assertThat(ClientVersion.VERSION).isNotNull(); 28 | assertThat(ClientVersion.VERSION).isNotEqualTo("0.0.0"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/ClonePropertiesTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test; 17 | 18 | import com.rabbitmq.client.AMQP.BasicProperties; 19 | import com.rabbitmq.client.MessageProperties; 20 | import org.junit.jupiter.api.Test; 21 | 22 | import static org.junit.jupiter.api.Assertions.assertEquals; 23 | import static org.junit.jupiter.api.Assertions.assertTrue; 24 | 25 | public class ClonePropertiesTest { 26 | 27 | 28 | @Test public void propertyCloneIsDistinct() 29 | throws CloneNotSupportedException 30 | { 31 | assertTrue(MessageProperties.MINIMAL_PERSISTENT_BASIC != 32 | MessageProperties.MINIMAL_PERSISTENT_BASIC.clone()); 33 | } 34 | 35 | @Test public void propertyClonePreservesValues() 36 | throws CloneNotSupportedException 37 | { 38 | assertEquals(MessageProperties.MINIMAL_PERSISTENT_BASIC.getDeliveryMode(), 39 | ((BasicProperties) MessageProperties.MINIMAL_PERSISTENT_BASIC.clone()) 40 | .getDeliveryMode()); 41 | assertEquals(Integer.valueOf(2), 42 | ((BasicProperties) MessageProperties.MINIMAL_PERSISTENT_BASIC.clone()) 43 | .getDeliveryMode()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/DnsRecordIpAddressResolverTests.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.test; 2 | 3 | import com.rabbitmq.client.Connection; 4 | import com.rabbitmq.client.ConnectionFactory; 5 | import com.rabbitmq.client.DnsRecordIpAddressResolver; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.io.IOException; 9 | import java.net.UnknownHostException; 10 | import java.util.concurrent.TimeoutException; 11 | 12 | import static org.junit.jupiter.api.Assertions.fail; 13 | 14 | /** 15 | * 16 | */ 17 | public class DnsRecordIpAddressResolverTests extends BrokerTestCase { 18 | 19 | @Test public void localhostResolution() throws IOException, TimeoutException { 20 | DnsRecordIpAddressResolver addressResolver = new DnsRecordIpAddressResolver("localhost"); 21 | ConnectionFactory connectionFactory = newConnectionFactory(); 22 | Connection connection = connectionFactory.newConnection(addressResolver); 23 | try { 24 | connection.createChannel(); 25 | } finally { 26 | connection.abort(); 27 | } 28 | } 29 | 30 | @Test public void loopbackInterfaceResolution() throws IOException, TimeoutException { 31 | DnsRecordIpAddressResolver addressResolver = new DnsRecordIpAddressResolver("127.0.0.1"); 32 | ConnectionFactory connectionFactory = newConnectionFactory(); 33 | Connection connection = connectionFactory.newConnection(addressResolver); 34 | try { 35 | connection.createChannel(); 36 | } finally { 37 | connection.abort(); 38 | } 39 | } 40 | 41 | @Test public void resolutionFails() throws IOException, TimeoutException { 42 | DnsRecordIpAddressResolver addressResolver = new DnsRecordIpAddressResolver( 43 | "afancyandunlikelyhostname" 44 | ); 45 | try { 46 | connectionFactory.newConnection(addressResolver); 47 | fail("The host resolution should have failed"); 48 | } catch (UnknownHostException e) { 49 | // expected 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/LongStringTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test; 17 | 18 | import com.rabbitmq.client.LongString; 19 | import com.rabbitmq.client.impl.LongStringHelper; 20 | import org.junit.jupiter.api.Test; 21 | 22 | import java.io.UnsupportedEncodingException; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertTrue; 25 | 26 | public class LongStringTest { 27 | 28 | @Test public void testToString() throws UnsupportedEncodingException { 29 | String s = "abcdef"; 30 | LongString ls = LongStringHelper.asLongString(s); 31 | 32 | assertTrue(ls.toString().equals(s)); 33 | assertTrue(ls.toString().equals(new String(ls.getBytes(), "UTF-8"))); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/RequiredPropertiesSuite.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.test; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | /** 10 | * 11 | */ 12 | public class RequiredPropertiesSuite { //extends Suite { 13 | 14 | /* 15 | private static final Logger LOGGER = LoggerFactory.getLogger(RequiredPropertiesSuite.class); 16 | 17 | public RequiredPropertiesSuite(Class klass, RunnerBuilder builder) throws InitializationError { 18 | super(klass, builder); 19 | } 20 | 21 | public RequiredPropertiesSuite(RunnerBuilder builder, Class[] classes) throws InitializationError { 22 | super(builder, classes); 23 | } 24 | 25 | protected RequiredPropertiesSuite(Class klass, Class[] suiteClasses) throws InitializationError { 26 | super(klass, suiteClasses); 27 | } 28 | 29 | protected RequiredPropertiesSuite(RunnerBuilder builder, Class klass, Class[] suiteClasses) throws InitializationError { 30 | super(builder, klass, suiteClasses); 31 | } 32 | 33 | protected RequiredPropertiesSuite(Class klass, List runners) throws InitializationError { 34 | super(klass, runners); 35 | } 36 | 37 | @Override 38 | protected List getChildren() { 39 | if(!AbstractRMQTestSuite.requiredProperties()) { 40 | return new ArrayList(); 41 | } else { 42 | return super.getChildren(); 43 | } 44 | } 45 | 46 | @Override 47 | protected void runChild(Runner runner, RunNotifier notifier) { 48 | LOGGER.info("Running test {}", runner.getDescription().getDisplayName()); 49 | super.runChild(runner, notifier); 50 | } 51 | 52 | */ 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/BasicConsume.java: -------------------------------------------------------------------------------- 1 | package com.rabbitmq.client.test.functional; 2 | 3 | import com.rabbitmq.client.AMQP; 4 | import com.rabbitmq.client.Channel; 5 | import com.rabbitmq.client.DefaultConsumer; 6 | import com.rabbitmq.client.Envelope; 7 | import com.rabbitmq.client.test.BrokerTestCase; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import java.io.IOException; 11 | import java.util.concurrent.CountDownLatch; 12 | import java.util.concurrent.TimeUnit; 13 | 14 | import static org.junit.jupiter.api.Assertions.assertTrue; 15 | 16 | /** 17 | * 18 | */ 19 | public class BasicConsume extends BrokerTestCase { 20 | 21 | @Test public void basicConsumeOk() throws IOException, InterruptedException { 22 | String q = channel.queueDeclare().getQueue(); 23 | basicPublishPersistent("msg".getBytes("UTF-8"), q); 24 | basicPublishPersistent("msg".getBytes("UTF-8"), q); 25 | 26 | CountDownLatch latch = new CountDownLatch(2); 27 | channel.basicConsume(q, new CountDownLatchConsumer(channel, latch)); 28 | 29 | boolean nbOfExpectedMessagesHasBeenConsumed = latch.await(1, TimeUnit.SECONDS); 30 | assertTrue(nbOfExpectedMessagesHasBeenConsumed, "Not all the messages have been received"); 31 | } 32 | 33 | static class CountDownLatchConsumer extends DefaultConsumer { 34 | 35 | private final CountDownLatch latch; 36 | 37 | public CountDownLatchConsumer(Channel channel, CountDownLatch latch) { 38 | super(channel); 39 | this.latch = latch; 40 | } 41 | 42 | @Override 43 | public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { 44 | latch.countDown(); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/ConsumerCount.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | 20 | import java.io.IOException; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import com.rabbitmq.client.DefaultConsumer; 25 | import com.rabbitmq.client.test.BrokerTestCase; 26 | 27 | public class ConsumerCount extends BrokerTestCase { 28 | @Test public void consumerCount() throws IOException { 29 | String q = generateQueueName(); 30 | channel.queueDeclare(q, false, true, false, null); 31 | assertEquals(0, channel.consumerCount(q)); 32 | 33 | String tag = channel.basicConsume(q, new DefaultConsumer(channel)); 34 | assertEquals(1, channel.consumerCount(q)); 35 | 36 | channel.basicCancel(tag); 37 | assertEquals(0, channel.consumerCount(q)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/DoubleDeletion.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.functional; 18 | 19 | import java.io.IOException; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | import com.rabbitmq.client.test.BrokerTestCase; 24 | 25 | public class DoubleDeletion extends BrokerTestCase 26 | { 27 | protected static final String Q = "DoubleDeletionQueue"; 28 | protected static final String X = "DoubleDeletionExchange"; 29 | 30 | @Test public void doubleDeletionQueue() 31 | throws IOException 32 | { 33 | channel.queueDelete(Q); 34 | channel.queueDeclare(Q, false, false, false, null); 35 | channel.queueDelete(Q); 36 | channel.queueDelete(Q); 37 | } 38 | 39 | @Test public void doubleDeletionExchange() 40 | throws IOException 41 | { 42 | channel.exchangeDelete(X); 43 | channel.exchangeDeclare(X, "direct"); 44 | channel.exchangeDelete(X); 45 | channel.exchangeDelete(X); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/ExchangeDeletePredeclared.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import com.rabbitmq.client.AMQP; 19 | import com.rabbitmq.client.test.BrokerTestCase; 20 | 21 | import java.io.IOException; 22 | 23 | public class ExchangeDeletePredeclared extends BrokerTestCase { 24 | public void testDeletingPredeclaredAmqExchange() throws IOException { 25 | try { 26 | channel.exchangeDelete("amq.fanout"); 27 | } catch (IOException e) { 28 | checkShutdownSignal(AMQP.ACCESS_REFUSED, e); 29 | } 30 | } 31 | 32 | public void testDeletingPredeclaredAmqRabbitMQExchange() throws IOException { 33 | try { 34 | channel.exchangeDelete("amq.rabbitmq.log"); 35 | } catch (IOException e) { 36 | checkShutdownSignal(AMQP.ACCESS_REFUSED, e); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/ExchangeEquivalenceBase.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import static org.junit.jupiter.api.Assertions.fail; 19 | 20 | import java.io.IOException; 21 | import java.util.Map; 22 | 23 | import com.rabbitmq.client.AMQP; 24 | import com.rabbitmq.client.test.BrokerTestCase; 25 | 26 | public abstract class ExchangeEquivalenceBase extends BrokerTestCase { 27 | public void verifyEquivalent(String name, 28 | String type, boolean durable, boolean autoDelete, 29 | Map args) throws IOException { 30 | channel.exchangeDeclarePassive(name); 31 | channel.exchangeDeclare(name, type, durable, autoDelete, args); 32 | } 33 | 34 | // Note: this will close the channel 35 | public void verifyNotEquivalent(String name, 36 | String type, boolean durable, boolean autoDelete, 37 | Map args) throws IOException { 38 | channel.exchangeDeclarePassive(name); 39 | try { 40 | channel.exchangeDeclare(name, type, durable, autoDelete, args); 41 | fail("Exchange was supposed to be not equivalent"); 42 | } catch (IOException ioe) { 43 | checkShutdownSignal(AMQP.PRECONDITION_FAILED, ioe); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/Heartbeat.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.functional; 18 | 19 | import com.rabbitmq.client.ConnectionFactory; 20 | import com.rabbitmq.client.impl.recovery.AutorecoveringConnection; 21 | import com.rabbitmq.client.test.BrokerTestCase; 22 | import org.junit.jupiter.api.Test; 23 | 24 | import java.io.IOException; 25 | 26 | import static org.junit.jupiter.api.Assertions.*; 27 | 28 | public class Heartbeat extends BrokerTestCase { 29 | 30 | @Override 31 | protected ConnectionFactory newConnectionFactory() { 32 | ConnectionFactory cf = super.newConnectionFactory(); 33 | cf.setRequestedHeartbeat(1); 34 | return cf; 35 | } 36 | 37 | @Test 38 | public void heartbeat() throws InterruptedException { 39 | assertEquals(1, connection.getHeartbeat()); 40 | Thread.sleep(3100); 41 | assertTrue(connection.isOpen()); 42 | ((AutorecoveringConnection) connection).getDelegate().setHeartbeat(0); 43 | assertEquals(0, connection.getHeartbeat()); 44 | Thread.sleep(3100); 45 | assertFalse(connection.isOpen()); 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/InvalidAcks.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import java.io.IOException; 19 | 20 | public class InvalidAcks extends InvalidAcksBase { 21 | protected void select() throws IOException {} 22 | protected void commit() throws IOException {} 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/InvalidAcksTx.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import java.io.IOException; 19 | 20 | public class InvalidAcksTx extends InvalidAcksBase { 21 | protected void select() throws IOException { 22 | channel.txSelect(); 23 | } 24 | 25 | protected void commit() throws IOException { 26 | channel.txCommit(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/MessageCount.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | 20 | import java.io.IOException; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import com.rabbitmq.client.test.BrokerTestCase; 25 | 26 | public class MessageCount extends BrokerTestCase { 27 | @Test public void messageCount() throws IOException { 28 | String q = generateQueueName(); 29 | channel.queueDeclare(q, false, true, false, null); 30 | assertEquals(0, channel.messageCount(q)); 31 | 32 | basicPublishVolatile(q); 33 | assertEquals(1, channel.messageCount(q)); 34 | basicPublishVolatile(q); 35 | assertEquals(2, channel.messageCount(q)); 36 | 37 | channel.queuePurge(q); 38 | assertEquals(0, channel.messageCount(q)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/RequeueOnChannelClose.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.functional; 18 | 19 | import java.io.IOException; 20 | 21 | public class RequeueOnChannelClose extends RequeueOnClose 22 | { 23 | 24 | protected void open() throws IOException 25 | { 26 | openChannel(); 27 | } 28 | 29 | protected void close() throws IOException 30 | { 31 | closeChannel(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/RequeueOnConnectionClose.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.functional; 18 | 19 | import java.io.IOException; 20 | import java.util.concurrent.TimeoutException; 21 | 22 | public class RequeueOnConnectionClose extends RequeueOnClose 23 | { 24 | 25 | protected void open() throws IOException, TimeoutException { 26 | openConnection(); 27 | openChannel(); 28 | } 29 | 30 | protected void close() throws IOException 31 | { 32 | closeConnection(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/functional/UnbindAutoDeleteExchange.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.functional; 17 | 18 | import static org.junit.jupiter.api.Assertions.fail; 19 | 20 | import java.io.IOException; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import com.rabbitmq.client.AMQP; 25 | import com.rabbitmq.client.test.BrokerTestCase; 26 | 27 | /** 28 | * Test that unbinding from an auto-delete exchange causes the exchange to go 29 | * away 30 | */ 31 | public class UnbindAutoDeleteExchange extends BrokerTestCase { 32 | @Test public void unbind() throws IOException, InterruptedException { 33 | String exchange = "myexchange"; 34 | channel.exchangeDeclare(exchange, "fanout", false, true, null); 35 | String queue = channel.queueDeclare().getQueue(); 36 | channel.queueBind(queue, exchange, ""); 37 | channel.queueUnbind(queue, exchange, ""); 38 | 39 | try { 40 | channel.exchangeDeclarePassive(exchange); 41 | fail("exchange should no longer be there"); 42 | } 43 | catch (IOException e) { 44 | checkShutdownSignal(AMQP.NOT_FOUND, e); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/server/AlternateExchangeEquivalence.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.server; 18 | 19 | import java.io.IOException; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import org.junit.jupiter.api.Test; 24 | 25 | import com.rabbitmq.client.test.functional.ExchangeEquivalenceBase; 26 | 27 | public class AlternateExchangeEquivalence extends ExchangeEquivalenceBase { 28 | static final Map args = new HashMap(); 29 | { 30 | args.put("alternate-exchange", "UME"); 31 | } 32 | 33 | @Test public void alternateExchangeEquivalence() throws IOException { 34 | channel.exchangeDeclare("alternate", "direct", false, false, args); 35 | verifyEquivalent("alternate", "direct", false, false, args); 36 | } 37 | 38 | @Test public void alternateExchangeNonEquivalence() throws IOException { 39 | channel.exchangeDeclare("alternate", "direct", false, false, args); 40 | Map altargs = new HashMap(); 41 | altargs.put("alternate-exchange", "somewhere"); 42 | verifyNotEquivalent("alternate", "direct", false, false, altargs); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/server/HaTestSuite.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.server; 17 | 18 | import com.rabbitmq.client.test.functional.FunctionalTestSuite; 19 | import org.junit.platform.suite.api.SelectClasses; 20 | import org.junit.platform.suite.api.Suite; 21 | 22 | @Suite 23 | @SelectClasses({ 24 | FunctionalTestSuite.class, 25 | ServerTestSuite.class, 26 | LastHaTestSuite.class, 27 | }) 28 | public class HaTestSuite { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/server/LastHaTestSuite.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.server; 17 | 18 | import com.rabbitmq.client.test.server.LastHaTestSuite.DummyTest; 19 | import org.junit.jupiter.api.Test; 20 | import org.junit.platform.suite.api.SelectClasses; 21 | import org.junit.platform.suite.api.Suite; 22 | 23 | /** 24 | * Marker test suite to signal the end of the HA test suite. 25 | */ 26 | @Suite 27 | @SelectClasses(DummyTest.class) 28 | public class LastHaTestSuite { 29 | 30 | static class DummyTest { 31 | @Test 32 | void noOp() { 33 | 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/server/MessageRecovery.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.server; 17 | 18 | import java.io.IOException; 19 | 20 | import org.junit.jupiter.api.Test; 21 | 22 | import com.rabbitmq.client.AMQP; 23 | import com.rabbitmq.client.MessageProperties; 24 | import com.rabbitmq.client.test.ConfirmBase; 25 | import org.junit.jupiter.api.Test; 26 | 27 | public class MessageRecovery extends ConfirmBase 28 | { 29 | 30 | private final static String Q = "recovery-test"; 31 | private final static String Q2 = "recovery-test-ha-check"; 32 | 33 | @Test public void messageRecovery() 34 | throws Exception 35 | { 36 | channel.queueDelete(Q); 37 | channel.queueDelete(Q2); 38 | channel.confirmSelect(); 39 | channel.queueDeclare(Q, true, false, false, null); 40 | channel.basicPublish("", Q, false, false, 41 | MessageProperties.PERSISTENT_BASIC, 42 | "nop".getBytes()); 43 | waitForConfirms(); 44 | 45 | channel.queueDeclare(Q2, false, false, false, null); 46 | 47 | restart(); 48 | 49 | assertDelivered(Q, 1, false); 50 | channel.queueDelete(Q); 51 | channel.queueDelete(Q2); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/server/ServerTestSuite.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.server; 18 | 19 | import org.junit.platform.suite.api.SelectClasses; 20 | import org.junit.platform.suite.api.Suite; 21 | 22 | @Suite 23 | @SelectClasses({ 24 | Permissions.class, 25 | DurableBindingLifecycle.class, 26 | DeadLetterExchangeDurable.class, 27 | EffectVisibilityCrossNodeTest.class, 28 | ExclusiveQueueDurability.class, 29 | AlternateExchangeEquivalence.class, 30 | MemoryAlarms.class, 31 | MessageRecovery.class, 32 | Firehose.class, 33 | PersistenceGuarantees.class, 34 | Shutdown.class, 35 | BlockedConnection.class, 36 | ChannelLimitNegotiation.class, 37 | LoopbackUsers.class, 38 | XDeathHeaderGrowth.class, 39 | PriorityQueues.class, 40 | TopicPermissions.class 41 | }) 42 | public class ServerTestSuite { 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/server/Shutdown.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.server; 17 | 18 | import org.junit.jupiter.api.Test; 19 | 20 | import com.rabbitmq.client.AMQP; 21 | import com.rabbitmq.client.test.BrokerTestCase; 22 | 23 | public class Shutdown extends BrokerTestCase { 24 | 25 | @Test public void errorOnShutdown() throws Exception { 26 | bareRestart(); 27 | expectError(AMQP.CONNECTION_FORCED); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/ssl/BadVerifiedConnection.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.ssl; 17 | 18 | import org.junit.jupiter.api.Test; 19 | 20 | import javax.net.ssl.SSLContext; 21 | import javax.net.ssl.SSLHandshakeException; 22 | import java.io.IOException; 23 | import java.util.concurrent.TimeoutException; 24 | import org.junit.jupiter.api.condition.EnabledForJreRange; 25 | import org.junit.jupiter.api.condition.JRE; 26 | 27 | import static org.junit.jupiter.api.Assertions.fail; 28 | 29 | /** 30 | * Test for bug 19356 - SSL Support in rabbitmq 31 | * 32 | */ 33 | @EnabledForJreRange(min = JRE.JAVA_11) 34 | public class BadVerifiedConnection extends UnverifiedConnection { 35 | 36 | public void openConnection() 37 | throws IOException, TimeoutException { 38 | try { 39 | SSLContext c = TlsTestUtils.badVerifiedSslContext(); 40 | connectionFactory.useSslProtocol(c); 41 | } catch (Exception ex) { 42 | throw new IOException(ex); 43 | } 44 | 45 | try { 46 | connection = connectionFactory.newConnection(); 47 | fail(); 48 | } catch (SSLHandshakeException ignored) { 49 | } catch (IOException e) { 50 | fail(); 51 | } 52 | } 53 | 54 | public void openChannel() {} 55 | @Test public void sSL() {} 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/ssl/ConnectionFactoryDefaultTlsVersion.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | package com.rabbitmq.client.test.ssl; 17 | 18 | import com.rabbitmq.client.ConnectionFactory; 19 | import org.junit.jupiter.api.Assertions; 20 | import org.junit.jupiter.api.Test; 21 | 22 | public class ConnectionFactoryDefaultTlsVersion { 23 | 24 | @Test public void defaultTlsVersionJdk16ShouldTakeFallback() { 25 | String [] supportedProtocols = {"SSLv2Hello", "SSLv3", "TLSv1"}; 26 | String tlsProtocol = ConnectionFactory.computeDefaultTlsProtocol(supportedProtocols); 27 | Assertions.assertEquals("TLSv1",tlsProtocol); 28 | } 29 | 30 | @Test public void defaultTlsVersionJdk17ShouldTakePrefered() { 31 | String [] supportedProtocols = {"SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}; 32 | String tlsProtocol = ConnectionFactory.computeDefaultTlsProtocol(supportedProtocols); 33 | Assertions.assertEquals("TLSv1.2",tlsProtocol); 34 | } 35 | 36 | @Test public void defaultTlsVersionJdk18ShouldTakePrefered() { 37 | String [] supportedProtocols = {"SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}; 38 | String tlsProtocol = ConnectionFactory.computeDefaultTlsProtocol(supportedProtocols); 39 | Assertions.assertEquals("TLSv1.2",tlsProtocol); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/rabbitmq/client/test/ssl/SslTestSuite.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 2 | // 3 | // This software, the RabbitMQ Java client library, is triple-licensed under the 4 | // Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2 5 | // ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see 6 | // LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, 7 | // please see LICENSE-APACHE2. 8 | // 9 | // This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 10 | // either express or implied. See the LICENSE file for specific language governing 11 | // rights and limitations of this software. 12 | // 13 | // If you have any questions regarding licensing, please contact us at 14 | // info@rabbitmq.com. 15 | 16 | 17 | package com.rabbitmq.client.test.ssl; 18 | 19 | import com.rabbitmq.client.test.SslContextFactoryTest; 20 | 21 | import org.junit.platform.suite.api.SelectClasses; 22 | import org.junit.platform.suite.api.Suite; 23 | 24 | @Suite 25 | @SelectClasses({ 26 | UnverifiedConnection.class, 27 | VerifiedConnection.class, 28 | BadVerifiedConnection.class, 29 | ConnectionFactoryDefaultTlsVersion.class, 30 | NioTlsUnverifiedConnection.class, 31 | HostnameVerification.class, 32 | TlsConnectionLogging.class, 33 | SslContextFactoryTest.class 34 | }) 35 | public class SslTestSuite { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension: -------------------------------------------------------------------------------- 1 | com.rabbitmq.client.AmqpClientTestExtension -------------------------------------------------------------------------------- /src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.extensions.autodetection.enabled=true -------------------------------------------------------------------------------- /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 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/property-file-initialisation/configuration.properties: -------------------------------------------------------------------------------- 1 | rabbitmq.uri=amqp://bar:foo@somewhere:5674/foobar 2 | rabbitmq.username=foo 3 | rabbitmq.password=bar 4 | rabbitmq.virtual.host=dummy 5 | rabbitmq.host=127.0.0.1 6 | rabbitmq.port=5673 7 | rabbitmq.connection.channel.max=1 8 | rabbitmq.connection.frame.max=2 9 | rabbitmq.connection.heartbeat=10 10 | rabbitmq.connection.timeout=10000 11 | rabbitmq.handshake.timeout=5000 12 | rabbitmq.shutdown.timeout=20000 13 | rabbitmq.use.default.client.properties=true 14 | rabbitmq.client.properties.foo=bar 15 | rabbitmq.connection.recovery.enabled=false 16 | rabbitmq.topology.recovery.enabled=false 17 | rabbitmq.connection.recovery.interval=10000 18 | rabbitmq.channel.rpc.timeout=10000 19 | rabbitmq.channel.should.check.rpc.response.type=true 20 | rabbitmq.use.nio=true 21 | rabbitmq.nio.read.byte.buffer.size=32000 22 | rabbitmq.nio.write.byte.buffer.size=32000 23 | rabbitmq.nio.nb.io.threads=2 24 | rabbitmq.nio.write.enqueuing.timeout.in.ms=5000 25 | rabbitmq.nio.write.queue.capacity=1000 26 | -------------------------------------------------------------------------------- /src/test/resources/property-file-initialisation/tls/keystore.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/src/test/resources/property-file-initialisation/tls/keystore.p12 -------------------------------------------------------------------------------- /src/test/resources/property-file-initialisation/tls/truststore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitmq/rabbitmq-java-client/0f47be41d8081bd779d0909753a4f4d7de166cee/src/test/resources/property-file-initialisation/tls/truststore.jks --------------------------------------------------------------------------------