-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate kafka producers for each proxy (#78)
* Introduces more reliability by separating Kafka Producers.
- Loading branch information
Showing
22 changed files
with
304 additions
and
165 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
version=0.25.1 | ||
version=0.26.0 |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
17 changes: 17 additions & 0 deletions
17
tw-tkms-starter/src/main/java/com/transferwise/kafka/tkms/ITkmsInterrupterService.java
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,17 @@ | ||
package com.transferwise.kafka.tkms; | ||
|
||
import com.transferwise.common.baseutils.concurrency.ScheduledTaskExecutor.TaskHandle; | ||
import java.time.Duration; | ||
|
||
public interface ITkmsInterrupterService { | ||
|
||
TaskHandle interruptAfter(Thread t, Duration duration); | ||
|
||
/** | ||
* Cancels the previously set interruption task. | ||
* | ||
* <p>The handle has to be the one returned from the `interruptAfter` call. | ||
*/ | ||
void cancelInterruption(TaskHandle handler); | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
tw-tkms-starter/src/main/java/com/transferwise/kafka/tkms/TkmsInterrupterService.java
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,40 @@ | ||
package com.transferwise.kafka.tkms; | ||
|
||
import com.transferwise.common.baseutils.concurrency.IExecutorServicesProvider; | ||
import com.transferwise.common.baseutils.concurrency.ScheduledTaskExecutor; | ||
import com.transferwise.common.baseutils.concurrency.ScheduledTaskExecutor.TaskHandle; | ||
import java.time.Duration; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@Slf4j | ||
public class TkmsInterrupterService implements ITkmsInterrupterService, InitializingBean { | ||
|
||
@Autowired | ||
private IExecutorServicesProvider executorServicesProvider; | ||
private ScheduledTaskExecutor scheduledTaskExecutor; | ||
|
||
public void afterPropertiesSet() { | ||
this.scheduledTaskExecutor = executorServicesProvider.getGlobalScheduledTaskExecutor(); | ||
} | ||
|
||
@Override | ||
public TaskHandle interruptAfter(Thread t, Duration duration) { | ||
return scheduledTaskExecutor.scheduleOnce(() -> { | ||
var threadName = Thread.currentThread().getName(); | ||
try { | ||
Thread.currentThread().setName("tkms-interrupt"); | ||
log.warn("Had to interrupt thread '{}'.", t.getName()); | ||
t.interrupt(); | ||
} finally { | ||
Thread.currentThread().setName(threadName); | ||
} | ||
}, duration); | ||
} | ||
|
||
@Override | ||
public void cancelInterruption(TaskHandle handler) { | ||
handler.stop(); | ||
} | ||
} |
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
Oops, something went wrong.