Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TH2-2212] merged with dev 5 #283

Merged
merged 60 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
7cf0aec
[TH2-2212] fixed increasing recovery delay, added delay time deviatio…
Xanclry Jun 14, 2022
d4949c1
[TH2-2212] fixed configurations tests
Xanclry Jun 15, 2022
fa2f55f
[TH2-2212] simplified logic of connection recovery triggering
Xanclry Jun 16, 2022
9ae7680
Merge branch 'master' into TH2-2212-common-cannot-recover-channel-lev…
Xanclry Jun 16, 2022
16d1cf2
[TH2-2212] added retry for channel level errors
Xanclry Jun 21, 2022
6b85ae2
[TH2-2212] minor logger fixes, readme update
Xanclry Jun 21, 2022
dad038c
[TH2-2212] channel level errors logging
Xanclry Jun 23, 2022
0261f2f
[TH2-2212] fix: added throws
Xanclry Jun 23, 2022
92129f3
Merge branch 'master' into TH2-2212-common-cannot-recover-channel-lev…
Xanclry Jun 23, 2022
3ca6ddd
[TH2-2212] version bump, readme edited
Xanclry Jun 23, 2022
eb394c2
[TH2-2212] added interrupted exception to basicConsume
Xanclry Jun 24, 2022
0547a17
[TH2-2212] title version bump
Xanclry Jun 24, 2022
7ed4122
[TH2-2212] added integration tests
Xanclry Nov 7, 2022
6b643fd
[TH2-2212] merged master
Xanclry Nov 7, 2022
e4a9ad6
[TH2-2212] recoverable subscriptions, added integrations tests
Xanclry Nov 10, 2022
c22cef6
[TH2-2212] publish-consume test, refactoring
Xanclry Nov 11, 2022
8be1815
[TH2-2212] rabbit container reusing in the tests
Xanclry Nov 14, 2022
aaf58d1
[TH2-2212] added test for ack timeout among several channels
Xanclry Nov 14, 2022
1e9de98
[TH2-2212] added one more test
Xanclry Nov 14, 2022
23bc510
[TH2-2212] added more complexity to the several channels test
Xanclry Nov 15, 2022
3bd042c
[TH2-2212] refactoring
Xanclry Nov 16, 2022
0efa181
[TH2-2212] merge master
Xanclry Nov 16, 2022
17dc5a5
[TH2-2212] refactor
Xanclry Nov 17, 2022
0cbfb9b
[TH2-2212] removed unnecessary threads in the tests
Xanclry Nov 18, 2022
4b75b33
[TH2-2212] threads handling
Xanclry Nov 18, 2022
2f63aa7
[TH2-2212] assertion fix
Xanclry Nov 18, 2022
7ed2dd6
[TH2-2212] refactored
Xanclry Nov 18, 2022
19182f9
Merge branch 'TH2-2212-common-cannot-recover-channel-level-exceptions…
Nikita-Smirnov-Exactpro Nov 18, 2022
f1900b7
[TH2-2212] refactored 'handles ack timeout' test
Nikita-Smirnov-Exactpro Nov 18, 2022
8b81bf6
[TH2-2212] refactored 'thread interruption test' test
Nikita-Smirnov-Exactpro Nov 18, 2022
b91cc5c
[TH2-2212] fix `thread interruption test`
Xanclry Nov 18, 2022
9cbd388
[TH2-4466] fixed channels amount after recovery. Added related tests
Xanclry Nov 24, 2022
822e274
merge attempt
Oct 19, 2023
34c9ebe
fixes after merge
Oct 23, 2023
b0183b6
Merge branch 'dev-version-5' into TH2-2212-merged-with-dev-5
Oct 23, 2023
3d8f7ef
fixes after review
Oct 23, 2023
0b4ccbf
`isAutomaticRecoveryEnabled` added to `ConnectionManagerConfiguration`
Oct 25, 2023
767ee07
fixes after review
Oct 26, 2023
57b2d02
fix: cancelled consumer channel resubscribed during recovery
Oct 30, 2023
7fc34cc
fixed catching ShutdownSignalException exceptions
Oct 31, 2023
0afeda6
Merge branch 'dev-version-5' into TH2-2212-merged-with-dev-5
Nov 1, 2023
3c2e1d7
channel is not recovered by ConnectionManager if it's connection is c…
Nov 6, 2023
0def228
recovering channel after NOT_FOUND error added
Nov 7, 2023
e79d84b
comment proofreading
lumber1000 Nov 7, 2023
385e484
fixes after review
Nov 7, 2023
3a29537
locking reworked
Nov 9, 2023
3fb9036
test added to TestConnectionManager (multiple subscribers in parallel)
Nov 13, 2023
41c247e
unnecessary `isSubscribed` flag reset removed
Nov 13, 2023
28b9e4b
`recoverSubscriptionsOfChannel` refactored
Nov 13, 2023
49ecdb6
Merge branch 'dev-version-5' into TH2-2212-merged-with-dev-5
Nov 13, 2023
672f098
sync with dev-version-5
Nov 13, 2023
50e8891
changes after review
Nov 16, 2023
04df9ac
locking in `retryingPublishWithLock`
Nov 17, 2023
df85890
README.md
Nov 17, 2023
d9f110b
recoverSubscriptionsOfChannel refactored
Nov 17, 2023
5949809
locking
Nov 20, 2023
04ede78
Merge branch 'dev-version-5' into TH2-2212-merged-with-dev-5
Mar 4, 2024
eb2ef35
deps updated
Mar 4, 2024
945d364
test fixed
Mar 4, 2024
4835df2
test fixed
Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# th2 common library (Java) (5.7.1)
# th2 common library (Java) (5.8.0)

## Usage

Expand Down Expand Up @@ -110,6 +110,7 @@ The `CommonFactory` reads a RabbitMQ configuration from the rabbitMQ.json file.
"maxRecoveryAttempts": 5,
"minConnectionRecoveryTimeout": 10000,
"maxConnectionRecoveryTimeout": 60000,
"retryTimeDeviationPercent": 10,
"prefetchCount": 10,
Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved Hide resolved
"messageRecursionLimit": 100
}
Expand Down Expand Up @@ -501,6 +502,14 @@ dependencies {

## Release notes

### 5.8.0-dev

+ Added retry in case of a RabbitMQ channel or connection error (when possible).
+ Added InterruptedException to basicConsume method signature.
Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved Hide resolved
+ Added additional logging for RabbitMQ errors.
+ Fixed connection recovery delay time.
+ Integration tests for these scenarios.

Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved Hide resolved
### 5.7.1-dev

#### Updated:
Expand Down Expand Up @@ -965,4 +974,4 @@ dependencies {
### 3.0.1

+ metrics related to time measurement of an incoming message handling (Raw / Parsed / Event) migrated to
Prometheus [histogram](https://prometheus.io/docs/concepts/metric_types/#histogram)
Prometheus [histogram](https://prometheus.io/docs/concepts/metric_types/#histogram)
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,11 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
testImplementation "org.testcontainers:testcontainers:1.17.1"
testImplementation "org.testcontainers:rabbitmq:1.17.1"
testImplementation "org.testcontainers:testcontainers:1.17.4"
testImplementation "org.testcontainers:rabbitmq:1.17.4"
testImplementation("org.junit-pioneer:junit-pioneer:2.1.0") {
because("system property tests")
}

testFixturesImplementation group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit5', version: kotlin_version
testFixturesImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
}
Expand Down Expand Up @@ -355,4 +354,4 @@ licenseReport {
]
excludeOwnGroup = false
allowedLicensesFile = new URL("https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/allowed-licenses.json")
}
}
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
release_version=5.7.1

release_version=5.8.0
description='th2 common library (Java)'
vcs_url=https://github.com/th2-net/th2-common-j
kapt.include.compile.classpath=false
kapt.include.compile.classpath=false
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ protected PrometheusConfiguration loadPrometheusConfiguration() {
}

protected ConnectionManager createRabbitMQConnectionManager() {
return new ConnectionManager(getRabbitMqConfiguration(), getConnectionManagerConfiguration(), livenessMonitor::disable);
return new ConnectionManager(getRabbitMqConfiguration(), getConnectionManagerConfiguration());
}

protected ConnectionManager getRabbitMqConnectionManager() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Exactpro (Exactpro Systems Limited)
* Copyright 2020-2023 Exactpro (Exactpro Systems Limited)
* Licensed 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
Expand All @@ -15,8 +15,8 @@

package com.exactpro.th2.common.schema.grpc.router;

import com.exactpro.th2.common.grpc.router.ServerGrpcInterceptor;
import com.exactpro.th2.common.grpc.router.MethodDetails;
import com.exactpro.th2.common.grpc.router.ServerGrpcInterceptor;
import com.exactpro.th2.common.metrics.CommonMetrics;
import com.exactpro.th2.common.schema.grpc.configuration.GrpcConfiguration;
import com.exactpro.th2.common.schema.grpc.configuration.GrpcRouterConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void subscribe() {
consumerMonitor.updateAndGet(previous -> previous == EMPTY_INITIALIZER
? Suppliers.memoize(this::basicConsume)
: previous)
.get(); // initialize subscribtion
.get(); // initialize subscription
} catch (Exception e) {
throw new IllegalStateException("Can not start listening", e);
}
Expand Down Expand Up @@ -189,6 +189,10 @@ private SubscriberMonitor basicConsume() {
return connectionManager.basicConsume(queue, this::handle, this::canceled);
} catch (IOException e) {
throw new IllegalStateException("Can not subscribe to queue = " + queue, e);
} catch (InterruptedException e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we catch InterruptedException in here (private method). I think InterruptedException should be a signal for interruption of retry or subscribe process

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are in catch block subscribe retry process is already interrupted (because it's in try block - connectionManager.basicConsume).

Thread.currentThread().interrupt();
LOGGER.error("Interrupted exception while consuming from queue '{}'", queue);
throw new IllegalStateException("Thread was interrupted while consuming", e);
}
}

Expand Down Expand Up @@ -232,4 +236,4 @@ private void canceled(String consumerTag) {
private static <T> Supplier<T> emptySupplier() {
return (Supplier<T>) EMPTY_INITIALIZER;
}
}
}
Loading
Loading