projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: Errors during shard-publishing should not kill the instance
[demos/kafka/chat]
/
src
/
main
/
java
/
de
/
juplo
/
kafka
/
chat
/
backend
/
implementation
/
kafka
/
DataChannel.java
diff --git
a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java
b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java
index
f139b76
..
b4cc33f
100644
(file)
--- a/
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java
+++ b/
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java
@@
-28,6
+28,7
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
private final Consumer<String, AbstractMessageTo> consumer;
private final ZoneId zoneId;
private final int numShards;
private final Consumer<String, AbstractMessageTo> consumer;
private final ZoneId zoneId;
private final int numShards;
+ private final Duration pollingInterval;
private final int bufferSize;
private final Clock clock;
private final boolean[] isShardOwned;
private final int bufferSize;
private final Clock clock;
private final boolean[] isShardOwned;
@@
-49,6
+50,7
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
Consumer<String, AbstractMessageTo> dataChannelConsumer,
ZoneId zoneId,
int numShards,
Consumer<String, AbstractMessageTo> dataChannelConsumer,
ZoneId zoneId,
int numShards,
+ Duration pollingInterval,
int bufferSize,
Clock clock,
InfoChannel infoChannel,
int bufferSize,
Clock clock,
InfoChannel infoChannel,
@@
-65,6
+67,7
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
this.producer = producer;
this.zoneId = zoneId;
this.numShards = numShards;
this.producer = producer;
this.zoneId = zoneId;
this.numShards = numShards;
+ this.pollingInterval = pollingInterval;
this.bufferSize = bufferSize;
this.clock = clock;
this.isShardOwned = new boolean[numShards];
this.bufferSize = bufferSize;
this.clock = clock;
this.isShardOwned = new boolean[numShards];
@@
-152,7
+155,8
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
"Could not publish instance {} as owner of shard {}: {}",
instanceId,
partition,
"Could not publish instance {} as owner of shard {}: {}",
instanceId,
partition,
- throwable))
+ throwable.toString()))
+ .onErrorComplete()
.block();
});
.block();
});
@@
-189,7
+193,7
@@
public class DataChannel implements Runnable, ConsumerRebalanceListener
{
try
{
{
try
{
- ConsumerRecords<String, AbstractMessageTo> records = consumer.poll(
Duration.ofMinutes(1)
);
+ ConsumerRecords<String, AbstractMessageTo> records = consumer.poll(
pollingInterval
);
log.info("Fetched {} messages", records.count());
if (loadInProgress)
log.info("Fetched {} messages", records.count());
if (loadInProgress)