Max retry attempts and back off interval not changing - spring-kafka

I am trying to retry consumer on exception in my code.
my consumer looks like below
#Bean
public Consumer<Message<String>> input(){
return -> {
String output = service.getValues();
};
}
below are the ways i have tried out.
1.
#Bean
public Consumer<Message<String>> input(){
return -> {
RetryTemplate retryTemplate = new RetryTemplate();
RetryPolicy retryPolicy = new SimpleRetryPolicy(2);
FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
backOffPolicy.setBackOffPeriod(600000);
retryTemplate.setBackOffPolicy(backOffPolicy);
retryTemplate.setRetryPolicy(retryPolicy);
retryTemplate.execute(context -> {
try {
String output = service.getValues();
}
catch (Exception e) {
throw new IllegalStateException(..);
}
});
};
}
2
#StreamRetryTemplate
public RetryTemplate myRetryTemplate() {
return new RetryTemplate();
}
instead of RetryTemplate setting maxRetry and backOff values in consumer properties like below
spring.cloud.stream.bindings.input-in-0.consumer.maxAttempts=2
spring.cloud.stream.bindings.input-in-0.consumer.backOffInitialInterval=600000
spring.cloud.stream.bindings.input-in-0.consumer.backOffMaxInterval=600000
spring.cloud.stream.bindings.input-in-0.consumer.backoffMultiplier=1.0
spring.cloud.stream.bindings.input-in-0.consumer.defaultRetryable=false
Nothing working, seems its retrying with default retry only. For my surprise its doing retry more than 10 times. May be I may missing some basic initial setup things please help whats I am doing wrong
below are my consumer properties in console on startup
[pool-8-thread-2] INFO o.a.k.c.consumer.ConsumerConfig - ConsumerConfig values:
allow.auto.create.topics = true
auto.commit.interval.ms = 5000
auto.offset.reset = latest
bootstrap.servers = [server.domian:9092]
check.crcs = true
client.dns.lookup = use_all_dns_ips
client.id = consumer-fsf-gateway-5
client.rack =
connections.max.idle.ms = 540000
default.api.timeout.ms = 60000
enable.auto.commit = true
exclude.internal.topics = true
fetch.max.bytes = 52428800
fetch.max.wait.ms = 500
fetch.min.bytes = 1
group.id = group_id_val
group.instance.id = null
heartbeat.interval.ms = 3000
interceptor.classes = []
internal.leave.group.on.close = true
internal.throw.on.fetch.stable.offset.unsupported = false
isolation.level = read_uncommitted
key.deserializer = class org.apache.kafka.common.serialization.ByteArrayDeserializer
max.partition.fetch.bytes = 1048576
max.poll.interval.ms = 300000
max.poll.records = 500
metadata.max.age.ms = 300000
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
receive.buffer.bytes = 65536
reconnect.backoff.max.ms = 1000
reconnect.backoff.ms = 50
request.timeout.ms = 30000
retry.backoff.ms = 100
sasl.client.callback.handler.class = null
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.service.name = kafka
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.login.callback.handler.class = null
sasl.login.class = null
sasl.login.refresh.buffer.seconds = 300
sasl.login.refresh.min.period.seconds = 60
sasl.login.refresh.window.factor = 0.8
sasl.login.refresh.window.jitter = 0.05
sasl.mechanism = GSSAPI
security.protocol = SASL_SSL
security.providers = null
send.buffer.bytes = 131072
session.timeout.ms = 10000
ssl.cipher.suites = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.3]
ssl.endpoint.identification.algorithm = https
ssl.engine.factory.class = null
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.protocol = TLSv1.3
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
value.deserializer = class org.apache.kafka.common.serialization.ByteArrayDeserializer

What ever configurations provided in question are working for retry. The issue was due to lot of previous failures it was retrying previous request. as all the previous requests queued up, those should solve first then next will come.

Related

TlSharp uses TlRequestGetParticipants to obtain the maximum number of channel members only 10K. Is there any way to break through this limit

while (offset < (res.FullChat as TLChannelFull).ParticipantsCount)
{
var pReq = new TLRequestGetParticipants()
{
Channel = new TLInputChannel() { AccessHash = chat.AccessHash.Value, ChannelId = chat.Id },
Filter = new TLChannelParticipantsRecent() { },
//Filter = new TLChannelParticipantsSearch() { Q = "a" },
Limit = 200,
Offset = offset,
};
var pRes = await client.SendRequestAsync<TLChannelParticipants>(pReq);
//result.Users.AddRange(pRes.users.lists.Cast<TLUser>());
offset += 200;
await Task.Delay(500);
}
I can only get 10K users with this method, and I can't break this limit

Amazon DynamoDBv2 QueryOperationConfig SelectValues.Count not working

I have this piece of code like this:
var options = new DynamoDBOperationConfig
{
ConditionalOperator = ConditionalOperatorValues.Or,
OverrideTableName = nameTable,
ConsistentRead = true
};
new QueryOperationConfig()
{
IndexName = indexName,
Filter = queryFilter,
Select = SelectValues.Count
};
result = context.FromQueryAsync<TEntity>(queryConfig, options).GetRemainingAsync().Result;
as per the documentation, it should return just the count of values that match the filter, at least, the piece of code in the SelectValues class says that
//
// Summary:
// An enumeration of all supported Select values for Query and Scan. Value of Count
// will force service to return the number of items, not the items themselves.
but result is always an empty list; how can i make the count work ?
If you are still looking for the answer, this is the solution:
new QueryOperationConfig()
{
IndexName = indexName,
Filter = queryFilter,
Select = SelectValues.Count,
ConsistentRead = true
};
var table = context.GetTargetTable<TEntity>();
var search = table.Query(queryConfig);
result = search.Count;
Having ConsistentRead set to true will cause it to give you real time updates when the table is updated.
It's not working on Document level...
You can try to do this in low level model.
int count = 0;
Dictionary<string, AttributeValue> lastKey = null;
do
{
var request = new QueryRequest
{
TableName = "tableNmae",
IndexName = "indexName",
KeyConditionExpression = "ID= :v_ID",
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{
":v_ID",
new AttributeValue
{
N = "1"
}
}
},
ConsistentRead = false,
Select = Select.COUNT,
ExclusiveStartKey = lastKey
};
var respone = await tableClient.QueryAsync(request);
count += respone.Count;
lastKey = respone.LastEvaluatedKey;
} while (lastKey != null && lastKey.Count != 0);

System.Data.SQLite transaction lock whole database

I'm trying to insert into 2 different tables from different transactions. Unfortunally I'm getting "database locked" exeption onto cn2.Execute...
var cb = new System.Data.SQLite.SQLiteConnectionStringBuilder
{
BinaryGUID = true,
DataSource = string.Format("file:SqliteTest-{0:N}.db", Guid.NewGuid()),
FailIfMissing = false,
JournalMode = System.Data.SQLite.SQLiteJournalModeEnum.Wal,
LegacyFormat = false,
Pooling = true,
SyncMode = System.Data.SQLite.SynchronizationModes.Normal,
DefaultIsolationLevel = System.Data.IsolationLevel.ReadCommitted
};
using (var cn1 = new System.Data.SQLite.SQLiteConnection(cb.ToString()))
{
cn1.Open();
cn1.Execute("create table t_1(uuid BLOB not null primary key, ts INTEGER not null);");
cn1.Execute("create table t_2(uuid BLOB not null primary key, ts INTEGER not null);");
using (var cn2 = (System.Data.SQLite.SQLiteConnection)cn1.Clone())
{
using (var tr1 = cn1.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
using (var tr2 = cn2.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
{
cn1.Execute("insert into t_1(uuid,ts) values(#uuid, #ts);",
new { uuid = Guid.NewGuid(), ts = DateTime.UtcNow.Ticks }, tr1);
cn2.Execute("insert into t_2(uuid,ts) values(#uuid, #ts);",
new { uuid = Guid.NewGuid(), ts = DateTime.UtcNow.Ticks }, tr2);
}
}
}

OMNET++ - How to prioritize UDP over TCP

Hello i'm new with omnet++ and networking simulations, i have the following network:
import inet.common.misc.NetAnimTrace;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.node.inet.StandardHost;
import ned.DatarateChannel;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.node.ethernet.Eth100M;
import inet.node.inet.Router;
import inet.node.inet.StandardHost;
import inet.node.inet.WirelessHost;
import inet.node.wireless.AccessPoint;
import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadioMedium;
import inet.visualizer.contract.IIntegratedVisualizer;
network clienteServer
{
#display("bgb=500,300");
submodules:
visualizer: <default("IntegratedCanvasVisualizer")> like IIntegratedVisualizer if hasVisualizer() {
parameters:
#display("p=100,50");
}
configurator: IPv4NetworkConfigurator {
parameters:
assignDisjunctSubnetAddresses = false;
#display("p=100,150");
}
radioMedium: Ieee80211ScalarRadioMedium {
parameters:
#display("p=100,250");
}
TCP1: WirelessHost {
parameters:
#display("p=186,178");
}
UDP1: WirelessHost {
parameters:
#display("p=193,77");
}
Server: WirelessHost {
parameters:
#display("p=438,122");
}
accessPoint: AccessPoint {
parameters:
#display("p=315,108");
}
UDP2: WirelessHost {
parameters:
#display("p=255,30");
}
}
and my .ini file, is the following, is very simple
[General]
network = clienteServer
total-stack = 7MiB
tkenv-plugin-path = ../../../etc/plugins
debug-on-errors = true
record-eventlog = true
**.addDefaultRoutes = false
**.UDP1.numUdpApps = 10
**.UDP1.udpApp[*].typename = "UDPVideoStreamCli"
**.UDP1.udpApp[*].serverAddress = "Server"
**.UDP1.udpApp[*].serverPort = 1000
**.UDP2.numUdpApps = 1
**.UDP2.udpApp[*].typename = "UDPBasicApp"
**.UDP2.udpApp[*].destAddresses = "Server"
**.UDP2.udpApp[*].messageLength = 1000B
**.UDP2.udpApp[*].sendInterval = 12ms
**.Server.numUdpApps = 1
**.Server.udpApp[*].typename = "UDPVideoStreamSvr"
**.Server.udpApp[*].localPort = 1000
**.Server.udpApp[*].sendInterval = 10ms
**.Server.udpApp[*].packetLen = 2000B
**.Server.udpApp[*].videoSize = 100000B
**.TCP1.numTcpApps = 1
**.TCP1.tcpApp[*].typename = "TelnetApp"
**.TCP1.tcpApp[0].localAddress = ""
**.TCP1.tcpApp[0].localPort = -1
**.TCP1.tcpApp[0].connectAddress = "Server"
**.TCP1.tcpApp[0].connectPort = 1000
**.TCP1.tcpApp[0].startTime = 0
**.TCP1.tcpApp[0].commandLength = exponential(10B)
**.TCP1.tcpApp[0].commandOutputLength = exponential(5B)
**.TCP1.tcpApp[0].thinkTime = truncnormal(1s,2s)
**.TCP1.tcpApp[0].idleInterval = 10ms
**.TCP1.tcpApp[0].reconnectInterval = 3s
**.TCP1.tcpApp[0].dataTransferMode = "object"
**.Server.numTcpApps = 1
**.Server.tcpApp[*].typename = "TCPGenericSrvApp"
**.Server.tcpApp[0].localAddress = ""
**.Server.tcpApp[0].localPort = 1000
**.Server.tcpApp[0].replyDelay = 0
**.initialZ = 0
**.scalar-recording = true
**.vector-recording = true
As you can see, i only have 4 host, one that acts like a server, 2 UDP ones and one that send TCP msgs, How can i prioritize udp traffic over tcp, in a simple way, any suggestions please??

Flex application throws error when making http call (GET request)

I get following error occasionally while running my flex application. I dont know what is wrong as it works intermittently.
Error occured (mx.messaging.messages::ErrorMessage)#0
body = ""
clientId = "DirectHTTPChannel0"
correlationId = "ACB1E8D4-51AF-21B9-E440-8ADBA0D4301E"
destination = ""
extendedData = (null)
faultCode = "Server.Error.Request"
faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost/api/wireless/lookupNumber/6501234567/"]. URL: http://localhost/api/wireless/lookupNumber/6501234567/"
faultString = "HTTP request error"
headers = (Object)#1
DSStatusCode = 0
messageId = "21CFD7A0-209E-81E2-8416-8ADBAC4F6B69"
rootCause = (flash.events::IOErrorEvent)#2
bubbles = false
cancelable = false
currentTarget = (flash.net::URLLoader)#3
bytesLoaded = 0
bytesTotal = 0
data = ""
dataFormat = "text"
errorID = 0
eventPhase = 2
target = (flash.net::URLLoader)#3
text = "Error #2032: Stream Error. URL: http://localhost/api/wireless/lookupNumber/6501234567/"
type = "ioError"
timestamp = 0
timeToLive = 0
Can you please guide me ?
Thanks

Resources