Migration from Apache Pekko Connectors 1.x to 2.x

Apache Pekko Connectors 2.x requires Apache Pekko 2.x and Apache Pekko HTTP 2.x. The connectors that use gRPC require Apache Pekko gRPC 2.x. See the Pekko 1.x to 2.x migration guide, the Pekko HTTP 1.x to 2.x migration guide and the Pekko gRPC 1.x to 2.x migration guide for the changes in those libraries.

See the 2.0 release notes for the full list of changes.

General changes

  • Java 17 is the minimum Java version. The File connector’s DirectoryChangesSource works best with Java 17.0.4 or later, see File.
  • Scala 2.12 is no longer supported. The connectors are built for Scala 2.13 and Scala 3.
  • Deprecated code has been removed, see Removed deprecated APIs. Before upgrading, build against the latest Pekko Connectors 1.x release and fix any deprecation warnings.
  • Pekko Connectors 2.x needs to be used with Pekko 2.x, which is not binary compatible with Pekko 1.x. Recompile your code against the 2.x libraries. Libraries that depend on Pekko Connectors 1.x need to be rebuilt and released for Pekko Connectors 2.x.
  • All Pekko Connectors modules that you use should be upgraded together, because they share the Pekko dependencies.

Removed connectors

  • The IronMQ connector (pekko-connectors-ironmq) has been removed (PR1898). It could no longer be tested, because the Docker images that its tests need are no longer available. The 1.x artifacts remain on Maven Central but they only work with Pekko 1.x.

Dependency changes

Java 17 as the minimum Java version made it possible to upgrade dependencies that no longer support Java 8 or 11. Some of these are new major versions, with their own breaking changes:

Connector Dependency 1.x 2.x
Apache Geode Apache Geode 1.15.x 2.0.x
Apache Solr SolrJ 8.11.x 9.x
Google Cloud BigQuery Storage Apache Arrow 17.x 20.x
Google Cloud Pub/Sub gRPC, Google Cloud BigQuery Storage protobuf-java 3.25.x 4.x
HBase HBase client 1.4.x 2.6.x
HBase Apache Hadoop 2.7.x 3.4.x
HDFS Apache Hadoop 3.3.x 3.4.x
Slick Slick 3.5.x 3.6.x
Spring Web Spring Framework 5.3.x 7.x
Spring Web Spring Boot 2.7.x 4.x
  • Java classes generated by protoc 3.x may not work with the protobuf-java 4.x runtime. Regenerate your own protobuf code and check any third-party libraries that ship generated protobuf classes.
  • The Solr connector uses SolrJ 9 (PR1813). Code that creates the SolrClient passed to the connector needs to follow the SolrJ 9 API.
  • The Spring Web connector needs Spring Framework 7 and Spring Boot 4, which use the jakarta namespaces.

Removed deprecated APIs

These APIs were deprecated in Alpakka, before the first Pekko Connectors release.

Connector Removed Use instead
AWS DynamoDB javadsl DynamoDb.single taking a Materializer the overload taking an actor system
AWS S3 S3.download (scaladsl and javadsl) S3.getObject
Elasticsearch ElasticsearchConnectionSettings.withConnectionContext withSSLContext
FTP javadsl mkdirAsync taking a Materializer the overload taking an actor system
Google Cloud Pub/Sub PubSubConfig.apply and create taking a project id, client email and private key, and PubSubConfig.projectId GoogleSettings, see Google Common
Google Cloud Pub/Sub gRPC PubSubSettings.callCredentials and withCallCredentials GoogleSettings, see Google Common
Google Cloud Storage GCStorageSettings, GCStorageExt, GCStorageAttributes, GCStorageSettingsPath, GCStorageSettingsValue and StorageSettings GoogleSettings and GoogleAttributes
Google Cloud Storage javadsl getBucket, createBucket and deleteBucket taking a Materializer the overloads taking an actor system
Google FCM The legacy API in org.apache.pekko.stream.connectors.google.firebase.fcm (GoogleFcm, FcmNotification, FcmNotificationModels, FcmResponse, ForwardProxy and the related classes) and the deprecated members of FcmSettings The equivalent classes in org.apache.pekko.stream.connectors.google.firebase.fcm.v1, and GoogleSettings for the credentials and the forward proxy
JMS, Jakarta Messaging NullMessageProperty and NullMapMessageEntry These were unused
Pravega TableReaderSettingsBuilder.withTableKey withKeyExtractor
Server-sent Events javadsl EventSource.create taking a Materializer the overload taking an actor system
Spring Web PekkoStreamsRegistrar(Materializer) the constructor taking an actor system

Removed in PR1164, PR1187, PR1730, PR1731 and PR1748.

API changes

A number of Java DSL methods exposed Scala types, such as scala.concurrent.Future, scala.Function1 and scala.Option. Many of them have been replaced, or have a new alternative and are now deprecated. The changes that are not source compatible are listed here. The other Java API additions are listed in the release notes.

AMQP

  • The Java API takes and returns the host and port pairs as Pair<String, Integer>. Java code previously saw them as Pair<String, Object> (PR2050). This applies to AmqpDetailsConnectionProvider.create and to withHostsAndPorts of AmqpDetailsConnectionProvider and AmqpConnectionFactoryConnectionProvider. A list that is declared as List<Pair<String, Object>> needs the new type. This is binary compatible.

Apache Cassandra

  • The javadsl CassandraFlow.create and withContext take a org.apache.pekko.japi.function.Function2 statement binder instead of the deprecated org.apache.pekko.japi.Function2 (PR1132). Java lambdas compile unchanged.
  • The javadsl CassandraFlow.createUnloggedBatch takes org.apache.pekko.japi.function.Function2 and org.apache.pekko.japi.function.Function parameters instead of Scala functions (PR1527). The previous method is available as the deprecated createUnloggedBatchWithScalaStatementBinder.

Couchbase

  • The javadsl CouchbaseSession.counter returns a CompletionStage<java.lang.Long> and createIndex returns a CompletionStage<java.lang.Boolean>. Java code previously saw both as CompletionStage<Object> (PR2052). Code that assigns the result to the previous type needs the new type. This is binary compatible.

Couchbase3

The Java DSL of the couchbase3 connector has been reworked (PR1526, PR1528, PR2052):

  • The CouchbaseSink factory methods materialize a CompletionStage instead of a scala.concurrent.Future. The previous methods are available with a Future suffix (insertDocFuture, upsertFuture, …) and are deprecated.
  • CouchbaseFlow and CouchbaseSink take a java.util.function.Function to extract the document id instead of a scala.Function1.
  • CouchbaseFlow.exists emits java.lang.Boolean.
  • CouchbaseFlow and CouchbaseSource take the options and the collection or scope as explicit parameters of a single parameter list, instead of Scala default arguments and implicit parameters. There are overloads without the options.

CSV

  • The javadsl CsvFormatting.format overload with parameters takes an additional boolean mitigateFormulaInjection as its last parameter (PR1820). There is no overload without it, so Java callers need to add the argument. Pass false to keep the previous behaviour. format() without arguments is unchanged. In the scaladsl, the parameter has a default value of false.

Slick

  • The javadsl Slick.flowWithPassThrough overloads that take a scala.concurrent.ExecutionContext are deprecated in favour of overloads that take a java.util.concurrent.Executor (PR1527, PR1535).

Google Cloud Pub/Sub

  • The javadsl GooglePubSub.subscribeFlow materializes a CompletionStage<NotUsed> instead of a scala.concurrent.Future (PR1526). The previous method is available as the deprecated subscribeFlowFuture.

Google Cloud BigQuery

  • The Java accessor InsertAllRetryPolicy.withoutDeduplication returned the policy with deduplication by mistake. It now returns the policy without deduplication (PR2044).
  • QueryRequest.getMaximumBytesBilled returns an Optional<java.lang.Long> instead of an Optional<Object> (a java.util.Optional[Long] in Scala). Code that assigns the result to the previous type needs the new type. This is binary compatible (PR2061).
  • JobConfiguration.getLabels and QueryRequest.getLabels are deprecated, because the optional value is a Scala Map. Use getLabelsAsJava, which returns a java.util.Map (PR2061).

Google Cloud BigQuery Storage

  • The javadsl BigQueryStorage.create, and the read and readMerged methods of BigQueryArrowStorage and BigQueryAvroStorage, that emit a scala.Tuple2 are deprecated. Use createAsPair, readAsPair and readMergedAsPair, which emit an org.apache.pekko.japi.Pair (PR2061).

Google Common

  • RequestSettings.getForwardProxy is deprecated, because it returns a scala.Option. Use RequestSettings.getForwardProxyOptional, which returns a java.util.Optional (PR2061). From GoogleSettings, that is getRequestSettings().getForwardProxyOptional().
  • Java code that called the request methods through Google$.MODULE$ can call them statically on the new GoogleApi object, such as GoogleApi.singleRequest(...) (PR2061).

Google Cloud Storage

  • StorageObject.getTemporaryHold and getEventBasedHold return an Optional<java.lang.Boolean> instead of an Optional<Object> (a java.util.Optional[Boolean] in Scala). Code that assigns the result to the previous type needs the new type. This is binary compatible (PR2061).
  • StorageObject.create is deprecated, because its optional values are Scala types. Use createFromJava, which takes java.lang.Boolean, java.lang.Integer, java.util.Map and java.util.List (PR2061).

AWS Kinesis

  • The javadsl KinesisSchedulerSource.createSharded materializes a CompletionStage<Scheduler> instead of a scala.concurrent.Future (PR1526). The previous method is available as the deprecated createShardedFuture.

Elasticsearch

  • The Java getter ReadResult.getVersion returns Optional<Long>. Java code previously saw it as Optional<Object> (PR2055).

MQTT Streaming

  • The QoS constants of ControlPacketFlags (QoSAtMostOnceDelivery, QoSAtLeastOnceDelivery, QoSExactlyOnceDelivery, QoSReserved and QoSFailure) and ControlPacketFlags.ReservedUnsubAck have been removed (PR1594). The QoS bits are encoded differently in a PUBLISH header and in a SUBSCRIBE payload, and the shared constants were wrong when subscribing. Use PublishQoSFlags for Publish and SubscribeQoSFlags for Subscribe.

OrientDB

  • OrientDbSourceSettings and OrientDbWriteSettings take a com.orientechnologies.orient.core.db.ODatabasePool instead of the deprecated OPartitionedDatabasePool (PR1553).

Binary incompatible changes

These changes are source compatible, so recompiling is enough:

  • CSV: the scaladsl CsvFormatting.format has an additional mitigateFormulaInjection parameter with a default value (PR1820). The javadsl change is not source compatible, see CSV.
  • Google Common and Huawei Push Kit: ForwardProxy.apply has an additional minTlsVersion parameter (PR1808).
  • Google Common and Google Cloud BigQuery: the implicit parameters of singleRequest are ordered differently in the bytecode (PR1682).

Behavior changes

AMQP

  • AmqpCachedConnectionProvider replaces a cached connection that the broker has closed, unless the connection is recovering automatically (PR2063). Concurrent callers share one connection attempt, so one failure fails all of them.
  • Releasing an automatically recovering connection that is not open aborts it. This applies to all connection providers. A connection that is recovering when its stage stops no longer reconnects.
  • AmqpFlow.withConfirm and AmqpFlowWithContext.withConfirm report each message’s own confirmation result (PR2018). Previously, a message could be reported with the result of another message.
  • The toString of the connection providers masks the password (PR1809).

AWS SPI Pekko HTTP

  • A client built without explicit ConnectionPoolSettings or a custom settings builder applies the HTTP options of the AWS SDK (CONNECTION_TIMEOUT, CONNECTION_MAX_IDLE_TIMEOUT, MAX_CONNECTIONS and CONNECTION_TIME_TO_LIVE) on top of the Pekko HTTP configuration (PR1909). For example, the SDK defaults of 50 connections and a 2 second connect timeout replace the Pekko HTTP defaults of max-connections = 4 and connecting-timeout = 10s. Pass explicit ConnectionPoolSettings to keep control of these values.
  • Request bodies of GET and DELETE requests are sent instead of being dropped (PR1907).
  • Request headers with more than one value are sent as one header per value, instead of failing with an IllegalArgumentException (PR1906).
  • A negative Content-Length is rejected with an IllegalArgumentException (PR1908, PR2118).
  • close() logs a failure to shut down instead of throwing, and the actor systems that the client creates are named aws-pekko-http-1, aws-pekko-http-2 and so on, instead of all being named aws-pekko-http (PR1904).

Apache Kudu

  • The default pekko.connectors.kudu.encryptionPolicy is REQUIRED_REMOTE instead of OPTIONAL (PR1818). Connections to remote servers that do not support encryption fail. Connections to localhost may still be unencrypted.

Elasticsearch and Opensearch

  • A request with credentials is rejected when the base URL does not use https (PR1810, PR1871). For local development and testing, ElasticsearchConnectionSettings.withAllowInsecureCredentialsTransport(true) logs a warning instead.
  • A connection context set with withSSLContext is also used when credentials are set. It was ignored in that case.

File

  • DirectoryChangesSource no longer passes the JDK internal SensitivityWatchEventModifier.HIGH when it registers the directory to watch (PR1882). Java 17.0.4 is the minimum Java version that keeps the previous behaviour on platforms where the JDK polls the directory (macOS, for example). With Java 17.0.0 to 17.0.3, changes can take up to 10 seconds to be emitted instead of up to 2 seconds.
  • TarArchiveMetadata and ZipArchiveMetadata reject names that are absolute paths, or that contain .. segments or backslashes, with an IllegalArgumentException (PR1807).
  • A zip archive that cannot be opened fails the stream of Archive.zipReader instead of throwing an exception when the stream is materialized (PR1929). A missing archive is reported as a NoSuchFileException instead of a FileNotFoundException.

FTP

  • The paths passed to the FTP and SFTP operations (retrieve, store, move, remove and make directory) are validated. Paths that contain .. segments are rejected with an IllegalArgumentException (PR1807).

Google connectors

  • OAuth2Credentials can be closed (PR1927). Requests made after close() fail with an IllegalStateException.
  • The project id is resolved from the new pekko.connectors.google.project-id setting, then from the credentials provider, then from the new default-project-id setting, which reads the GOOGLE_CLOUD_PROJECT, GCLOUD_PROJECT and GCP_PROJECT environment variables (PR1926). An existing configuration resolves the same project id as before, unless the credentials provider does not supply one and one of these environment variables is set.
  • The forward proxy creates its SSLContext with the TLS protocol instead of SSL (PR1808). This also applies to Huawei Push Kit.
  • The toString of the credentials and access token classes masks secrets (PR1809).
  • Google Cloud Pub/Sub gRPC: PubSubSettings no longer resolves credentials. They always come from GoogleSettings (PR1494, PR1748). When you use the Pub/Sub emulator, set pekko.connectors.google.credentials.provider = none.
  • Google FCM: LightSettings.light_off_duration(value) sets the light-off duration. It set the light-on duration by mistake (PR2045).

Huawei Push Kit

  • The access token is refreshed according to the expires_in value of the token response, instead of a fixed hour (PR1812).
  • The toString of HmsSettings masks secrets (PR1809).

JMS and Jakarta Messaging

  • The toString of Credentials masks the password (PR1809).

MQTT Streaming

  • UNSUBACK packets are decoded with the fixed header flags that the MQTT specification defines (PR1594).
  • The Java constructor of Command that takes a CompletionStage completes it exceptionally when the session fails the command (PR2048). A stage that the session cannot complete, such as minimalCompletionStage(), is rejected with an IllegalArgumentException.

OrientDB

  • The class name passed to OrientDbSource is validated when no query is given (PR1821, PR1874).

S3

  • The toString of the S3 model classes masks secrets (PR1809).

XML

  • Invalid XML fails the stream with the XMLStreamException, without the parser stage also logging an error (PR2015).

Configuration changes in Pekko Connectors 2.x

Changed default values

  • pekko.connectors.kudu.encryptionPolicy = "REQUIRED_REMOTE" (was "OPTIONAL")
  • pekko.connectors.s3.allowed-headers: UploadPart also allows Content-Type and x-amz-trailer, and InitiateMultipartUpload also allows Content-Length and Content-MD5 (PR1544)

Removed configuration

  • pekko.connectors.google.cloud.pubsub.grpc.callCredentials: use pekko.connectors.google.credentials.provider
  • pekko.connectors.google.cloud.storage (project-id, client-email, private-key, base-url, base-path, token-url and token-scope): configure the project id and the credentials with pekko.connectors.google.project-id and pekko.connectors.google.credentials, and a proxy with pekko.connectors.google.forward-proxy. Non-default values of base-url, base-path and token-url were already rejected in 1.x. A custom endpoint is configured with pekko.connectors.google.cloud-storage.endpoint-url and pekko.connectors.google.cloud-storage.base-path, which also exist in 1.x.
  • pekko.connectors.ironmq: the connector has been removed

New configuration

  • pekko.connectors.google.project-id and pekko.connectors.google.default-project-id: see Google Common (PR1926)
  • pekko.connectors.google.credentials.provider = google-application-default, with its pekko.connectors.google.credentials.google-application-default.project-id setting: resolves the credentials with Google’s google-auth-library-java, which supports GKE Workload Identity (PR1494). The default provider is still application-default.
  • pekko.connectors.google.forward-proxy.min-tls-version and pekko.connectors.huawei.pushkit.forward-proxy.min-tls-version: the minimum TLS version of the forward proxy connection, TLSv1.2 by default. It is only applied when trust-pem is also set. Without trust-pem, the default HTTPS context of Pekko HTTP is used unchanged (PR1808, PR1870)
  • pekko.connectors.s3.signing.path-encoded-characters: the characters that are percent-encoded in the path when a request is signed, for S3-compatible services such as Huawei OBS and Tencent COS (PR1971)