5.0.0.RC1
Pre-release5.0.0.RC1
Changes between 4.x.x and 5.0.0
Java 8 is now a pre-requisite
The client neither supports Java 6 anymore nor Java 7. The client pre-requisite is now Java 8 and it uses some of the Java 8 features in its API (e.g. lambdas).
GitHub issue: #304
Lambda-oriented methods for consuming messages
Channel has now basicConsume methods with functional interfaces as arguments, making it possible to use lambdas in the method call. Note that not all the methods of Consumer are supported, we retained only the "essential" ones: when a message is delivered, when the consumer is cancelled, and when the channel/connection is closed. Simple or straightforward consumers will benefit from these lambda-based methods, more advanced consumers can still implement all the callbacks they need in the Consumer interface. Have a look at the test class for examples of usage.
GitHub issue: #247
Make it possible to use lambdas instead of *Listener objects
It's now possible to use lambdas for the following listeners: ConfirmListener, ReturnListener, and BlockedListener, thanks to new functional interfaces and new methods in Connection and in Channel. The original *Listener methods and interfaces are still around though. Have a look at the test class for examples of usage.
GitHub issue: #246
Add an asynchronous method which returns a CompletableFuture
Channel has a new method to handle AMQP asynchronous calls:
CompletableFuture<Command> asyncCompletableRpc(Method method) throws IOException;This method is a foundation to build so-called reactive applications, thanks to the returned CompletableFuture. It's on purpose quite low-level (using the Method type as an argument).
GitHub issue: #215
Introduce SslContextFactory interface to create SSLContext instances
ConnectionFactory has now a new SslContextFactory property to create SSLContext contexts for connections. The connection name (part of the connection properties) can be used to conditionally create the SSLContext instance for the connection. This way the same ConnectionFactory instance can create connections with different certificates but sharing the same resources (e.g. IO threads when using NIO). This features introduces a breaking change: the FrameHandlerFactory#create method has now an extra connectionName String argument. This shouldn't impact applications as FrameHandlerFactory is an interface meant to be used internally. Note all the ConnectionFactory#useSslProtocol methods still work the same way, they use the SslContextFactory interface under the covers.
GitHub issue: #241
Remove QueueingConsumer from RpcServer
RpcServer was using QueueingConsumer internally, which has been removed in this release. Depending on the use of RpcServer, this can imply breaking changes (see below). The overall behavior of RpcServer shouldn't change, as it's using now its own private version of a QueueingConsumer.
GitHub issue: #221
Replace AssertionErrors with more appropriate exceptions
AssertionErrors have been replaced by more appropriate, less dramatic exceptions classes (e.g. IllegalArgumentException). AssertionsErrors were used in a few places of internal APIs, this change shouldn't impact application code.
GitHub issue: #239
Channel implements AutoCloseable
Channel can now be used inside try-with-resources statements. The JVM will automatically close the Channel once the program exits from a try-with-resources statement.
Thanks to Venil Noronha for this contribution.
GitHub issue: #258
Removal of deprecated classes and methods
The following deprecated classes and interfaces have been removed: QueueingConsumer, NullTrustManager, FlowListener, and SingleShotLinearTimer. Please see the implications below.
GitHub issue: #212
Breaking changes
Connection
A new method has been introduced, addBlockedListener(BlockedCallback, UnblockedCallback). This is a concern only if you implement your own Connection. If you only use Connection in your application, the rest of the API hasn't changed.
Channel
New methods have been introduced: addReturnListener(ReturnCallback), addConfirmListener(ConfirmCallback, ConfirmCallback), asyncCompletableRpc(Method), and "lambda-enabled" basicConsume methods. This is a concern only if you implement your own Channel. If you only use Channel in your application, the rest of the API hasn't changed.
RpcServer
RpcServer doesn't rely anymore on QueueingConsumer, which has been removed. If your RpcServer implementation relies on QueueingConsumer.Delivery, use RpcServer.Delivery instead (it has the same API). If you override setupConsumer to create the consumer, you need now to create an implementation of RpcServer.RpcConsumer in this method.
FrameHandlerFactory
FrameHandlerFactory#create has an extra connectionName String parameter. Note this interface isn't meant to be used in applications, so this change shouldn't impact application code.
Removal of AssertionError usages
AssertionsErrors were used in a few places of internal APIs (e.g. BlockingCell), not meant to be used by applications. Nevertheless, if you use those, have a look at the code changes in the GitHub issue #239.
Removal of QueueuingConsumer
QueueingConsumer had been originally introduced to allow applications to overcome a limitation in the way Connection managed threads and consumer dispatching. The threading behavior of Connection and Channel has been changed since then, making QueueingConsumer less relevant. If blocking behavior is needed, applications can use DefaultConsumer and a JDK BlockingQueue.
Removal of NullTrustManager
Use TrustEverythingTrustManager instead, it has the same behavior, but a more meaningful name.
Removal of FlowListener
Channel flow events have been superseded by TCP back pressure. Corresponding methods have been removed from the Channel and ExceptionHandler interfaces, so implementations of those interfaces need to remove them as well (most likely ExceptionHandler implementations, Channel not being an interface implemented in applications).