Skip to content

5.0.0

Compare
Choose a tag to compare
@acogoluegnes acogoluegnes released this 22 Sep 12:25
· 2132 commits to main since this release

Changes between 4.x.x and 5.0.0

This major release requires Java 8. It introduces several new features and lambda-oriented methods for common use cases. It has also a few breaking changes that should have minor or no impact on most applications.

Users running Java 8 or Java 9 are encouraged to upgrade to this release.

Java 8 is Now Required

The client no longer supports JDK 6 and 7. JDK 8 is now required to both build and run (use) this library. Starting with the 5.0 release, there are Java 8-specific features in the API (e.g. lambdas).

Because of the Java 8 requirement, this client only supports Android 7.0 or later. If support
for earlier Android versions is desired, use the 4.x releases instead.

GitHub issue: #304.

Lambda-oriented API for Consumers

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).