-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for querying last known sequence number by persistenceId. (…
…#267) * Add support for querying last known sequence number by persistenceId. * Align to existing code style. * Update license headers for new files. * Align to existing code style. * Remove marker trait. * mima issue * Create CurrentLastKnownSequenceNumberByPersistenceIdTest.scala * Return java.lang.Long value in javadsl. --------- Co-authored-by: PJ Fanning <[email protected]>
- Loading branch information
Showing
12 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
core/src/main/mima-filters/1.1.x.backwards.excludes/LastKnownSequenceNumber.excludes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# https://github.com/apache/pekko-persistence-jdbc/pull/267 | ||
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.persistence.jdbc.query.dao.ReadJournalDao.lastPersistenceIdSequenceNumber") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...ache/pekko/persistence/jdbc/query/CurrentLastKnownSequenceNumberByPersistenceIdTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.pekko.persistence.jdbc.query | ||
|
||
import org.scalatest.concurrent.ScalaFutures | ||
|
||
abstract class CurrentLastKnownSequenceNumberByPersistenceIdTest(config: String) extends QueryTestSpec(config) | ||
with ScalaFutures { | ||
|
||
it should "return None for unknown persistenceId" in withActorSystem { implicit system => | ||
val journalOps = new ScalaJdbcReadJournalOperations(system) | ||
|
||
journalOps | ||
.currentLastKnownSequenceNumberByPersistenceId("unknown") | ||
.futureValue shouldBe None | ||
} | ||
|
||
it should "return last sequence number for known persistenceId" in withActorSystem { implicit system => | ||
val journalOps = new ScalaJdbcReadJournalOperations(system) | ||
|
||
withTestActors() { (actor1, _, _) => | ||
actor1 ! 1 | ||
actor1 ! 2 | ||
actor1 ! 3 | ||
actor1 ! 4 | ||
|
||
eventually { | ||
journalOps | ||
.currentLastKnownSequenceNumberByPersistenceId("my-1") | ||
.futureValue shouldBe Some(4) | ||
|
||
// Just ensuring that query targets the correct persistenceId. | ||
journalOps | ||
.currentLastKnownSequenceNumberByPersistenceId("my-2") | ||
.futureValue shouldBe None | ||
} | ||
} | ||
} | ||
} | ||
|
||
class H2ScalaCurrentLastKnownSequenceNumberByPersistenceIdTest | ||
extends CurrentLastKnownSequenceNumberByPersistenceIdTest("h2-shared-db-application.conf") | ||
with H2Cleaner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ekko/persistence/jdbc/integration/CurrentLastKnownSequenceNumberByPersistenceIdTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* license agreements; and to You under the Apache License, version 2.0: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This file is part of the Apache Pekko project, which was derived from Akka. | ||
*/ | ||
|
||
package org.apache.pekko.persistence.jdbc.integration | ||
|
||
import org.apache.pekko.persistence.jdbc.query.{ | ||
CurrentLastKnownSequenceNumberByPersistenceIdTest, | ||
MysqlCleaner, | ||
OracleCleaner, | ||
PostgresCleaner, | ||
SqlServerCleaner | ||
} | ||
|
||
// Note: these tests use the shared-db configs, the test for all (so not only current) events use the regular db config | ||
|
||
class PostgresScalaCurrentLastKnownSequenceNumberByPersistenceIdTest | ||
extends CurrentLastKnownSequenceNumberByPersistenceIdTest("postgres-shared-db-application.conf") | ||
with PostgresCleaner | ||
|
||
class MySQLScalaCurrentLastKnownSequenceNumberByPersistenceIdTest | ||
extends CurrentLastKnownSequenceNumberByPersistenceIdTest("mysql-shared-db-application.conf") | ||
with MysqlCleaner | ||
|
||
class OracleScalaCurrentLastKnownSequenceNumberByPersistenceIdTest | ||
extends CurrentLastKnownSequenceNumberByPersistenceIdTest("oracle-shared-db-application.conf") | ||
with OracleCleaner | ||
|
||
class SqlServerScalaCurrentLastKnownSequenceNumberByPersistenceIdTest | ||
extends CurrentLastKnownSequenceNumberByPersistenceIdTest("sqlserver-shared-db-application.conf") | ||
with SqlServerCleaner |