diff --git a/.vscode/launch.json b/.vscode/launch.json index f8377ea..f77115d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/franz.tests/bin/Debug/net6.0/franz.tests.dll", + "program": "${workspaceFolder}/franz.tests/bin/Debug/net7.0/franz.tests.dll", "args": [], "cwd": "${workspaceFolder}/franz.tests", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/Jenkinsfile b/Jenkinsfile index 26e5a4a..46f4836 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent any tools { - dotnetsdk 'dotnet6' + dotnetsdk 'dotnet7' } stages { stage('build franz') { diff --git a/franz.tests/Program.cs b/franz.tests/Program.cs index 7b1385d..130220b 100644 --- a/franz.tests/Program.cs +++ b/franz.tests/Program.cs @@ -9,7 +9,7 @@ namespace franz.tests static void Main(string[] args) { Console.WriteLine("Hello World, I'm " + Dns.GetHostName()); - Telefranz.Configure("tester", "alloces:9092", new System.Collections.Generic.List(){"a!"}); + Telefranz.Configure("tester", "alloces.lan:9092", new System.Collections.Generic.List(){"a!"}); Console.WriteLine("telefranz configured"); diff --git a/franz.tests/franz.tests.csproj b/franz.tests/franz.tests.csproj index 8975cac..a7e4034 100644 --- a/franz.tests/franz.tests.csproj +++ b/franz.tests/franz.tests.csproj @@ -6,7 +6,7 @@ Exe - net6.0 + net7.0 diff --git a/franz/Telefranz.cs b/franz/Telefranz.cs index 5b75289..55f2d2c 100644 --- a/franz/Telefranz.cs +++ b/franz/Telefranz.cs @@ -104,6 +104,7 @@ namespace franz { config = new ConsumerConfig { + AllowAutoCreateTopics = true, BootstrapServers = bootstrap_servers, GroupId = name, AutoOffsetReset = AutoOffsetReset.Earliest diff --git a/franz/franz.csproj b/franz/franz.csproj index c4750cf..2c6c877 100644 --- a/franz/franz.csproj +++ b/franz/franz.csproj @@ -1,14 +1,14 @@ - net6.0 + net7.0 greyn.franz - 2.0.1 + 2.1.0 Adam R Grey - + diff --git a/topiclister/Program.cs b/topiclister/Program.cs index ea65dd7..e7790b3 100644 --- a/topiclister/Program.cs +++ b/topiclister/Program.cs @@ -1,14 +1,23 @@ using franz; using System; +using System.Threading.Tasks; using System.Linq; +using Confluent.Kafka; +using Confluent.Kafka.Admin; namespace topiclister { class Program { - static void Main(string[] args) + static async Task Main(string[] args) { - Telefranz.Configure("shut up", "localhost:9092"); + try{ + var ignoreme = Telefranz.Instance ; + } + catch(NotInitializedException) + { + //gulp, mmm + } var listOfBs = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(domainAssembly => domainAssembly.GetTypes()) .Where(type => type.IsSubclassOf(typeof(gray_messages.message)) && !type.IsAbstract) @@ -16,15 +25,28 @@ namespace topiclister if (listOfBs != null && listOfBs.Any()) { - foreach (var b in listOfBs) + using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = "alloces.lan:9092" }).Build()) { - Console.WriteLine(b); + foreach (var b in listOfBs) + { + Console.WriteLine(b.ToString()); + try + { + await adminClient.CreateTopicsAsync(new TopicSpecification[] { + new TopicSpecification { Name = b.ToString(), ReplicationFactor = 1, NumPartitions = 1, } }); + } + catch (CreateTopicsException e) + { + Console.WriteLine($"An error occured creating topic {e.Results[0].Topic}: {e.Results[0].Error.Reason}"); + } + } } } else { Console.WriteLine(":("); } + } } } \ No newline at end of file diff --git a/topiclister/topiclister.csproj b/topiclister/topiclister.csproj index ac85f5e..e576f41 100644 --- a/topiclister/topiclister.csproj +++ b/topiclister/topiclister.csproj @@ -6,7 +6,10 @@ Exe - net6.0 + net7.0 + + +