Closed maikaliu closed 2 months ago
Hi @maikaliu,
Thank you for using our client.
The WriteApi
is designed to facilitate asynchronous data writing via a background thread, acting as a gateway to queue data and handle the actual writing process in the background. This setup is intended to maximize efficiency and throughput by decoupling data collection from data transmission.
If you need to monitor or react to errors that occur during the write process, you can attach to the error event using the EventHandler mechanism provided by the API. This allows you to handle exceptions and take appropriate actions without disrupting the main workflow.
For scenarios where you require immediate error feedback or if your application logic depends on knowing the outcome of each write operation directly, consider using the WriteApiAsync
. This API variant throws errors directly and operates on a synchronous task-based model, making it more suitable for applications where write success needs to be guaranteed before proceeding.
Here's how you might use it:
using (var writeApiAsync = client.GetWriteApiAsync())
{
try
{
await writeApiAsync.WriteRecordAsync(bucket, org, WritePrecision.Ns, "temperature,location=north value=60.0");
}
catch (Exception ex)
{
Console.WriteLine($"Error writing to InfluxDB: {ex.Message}");
}
}
This approach ensures that errors are handled immediately as they occur, providing you with full control over the error management process.
Please let me know if you need further clarification or additional assistance.
Best Regards
Thank you for your explanation Best Regards
InfluxDB.Client don't throw any exception
code: using var client = new InfluxDBClient("http://localhost:123", "abc"); using (var writeApi = client.GetWriteApi()) { // // Write by Point // var point = PointData.Measurement("temperature") .Tag("location", "west") .Field("value", 55D) .Timestamp(DateTime.UtcNow.AddSeconds(-10), WritePrecision.Ns);
}
Expected behavior: throw a exception
Actual behavior: don't throw any exception
Specifications: