This repository was archived by the owner on May 21, 2020. It is now read-only.
File tree 3 files changed +18
-14
lines changed
src/main/scala/aserralle/akka/stream/kcl
3 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 4
4
- 2.11.12
5
5
- 2.12.7
6
6
jdk :
7
- - oraclejdk8
7
+ - openjdk8
8
8
script :
9
9
- sbt -J-XX:ReservedCodeCacheSize=128m ++$TRAVIS_SCALA_VERSION ";test:compile"
10
10
# make 'git branch' work again
Original file line number Diff line number Diff line change 5
5
package aserralle .akka .stream .kcl
6
6
7
7
import akka .Done
8
+ import software .amazon .kinesis .exceptions .ShutdownException
8
9
import software .amazon .kinesis .lifecycle .ShutdownReason
9
10
import software .amazon .kinesis .processor .RecordProcessorCheckpointer
10
11
import software .amazon .kinesis .retrieval .KinesisClientRecord
@@ -30,10 +31,16 @@ class CommittableRecord(
30
31
def canBeCheckpointed (): Boolean =
31
32
recordProcessorShutdownReason().isEmpty
32
33
33
- def tryToCheckpoint (): Future [Done ] =
34
+ def tryToCheckpoint (): Future [Boolean ] =
34
35
Future {
35
- checkpointer.checkpoint(sequenceNumber, subSequenceNumber)
36
- Done
36
+ try {
37
+ checkpointer.checkpoint(sequenceNumber, subSequenceNumber)
38
+ true
39
+ } catch {
40
+ case _ : ShutdownException =>
41
+ false
42
+ case exception => throw exception
43
+ }
37
44
}
38
45
}
39
46
Original file line number Diff line number Diff line change @@ -86,26 +86,23 @@ object KinesisWorkerSource {
86
86
87
87
val `{` =
88
88
b.add(scaladsl.Broadcast [immutable.Seq [CommittableRecord ]](2 ))
89
- val `}` = b.add(Zip [Done , immutable.Seq [CommittableRecord ]])
89
+ val `}` = b.add(Zip [Boolean , immutable.Seq [CommittableRecord ]])
90
90
val `=` = b.add(Flow [KinesisClientRecord ])
91
91
92
92
`{`.out(0 )
93
93
.map(_.max)
94
- .mapAsync(1 )(r =>
95
- if (r.canBeCheckpointed()) r.tryToCheckpoint()
96
- else Future .successful(Done )) ~> `}`.in0
94
+ .mapAsync(1 )(
95
+ r =>
96
+ if (r.canBeCheckpointed()) r.tryToCheckpoint()
97
+ else Future .successful(true )
98
+ ) ~> `}`.in0
97
99
`{`.out(1 ) ~> `}`.in1
98
100
99
- `}`.out.map(_._2).mapConcat(identity).map(_.record) ~> `=`
101
+ `}`.out.filter(_._1). map(_._2).mapConcat(identity).map(_.record) ~> `=`
100
102
101
103
FlowShape (`{`.in, `=`.out)
102
104
})
103
105
.mergeSubstreams
104
- .withAttributes(ActorAttributes .supervisionStrategy {
105
- case _ : ShutdownException =>
106
- Resume
107
- case _ => Stop
108
- })
109
106
110
107
def checkpointRecordsSink (
111
108
settings : KinesisWorkerCheckpointSettings =
You can’t perform that action at this time.
0 commit comments