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

tests: Create repro for issue 12964 #12965

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions issues/Issue12964/Issue12964.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<ProjectReference Include="..\..\apis\Google.Cloud.PubSub.V1\Google.Cloud.PubSub.V1\Google.Cloud.PubSub.V1.csproj" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions issues/Issue12964/Issue12964.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Issue12964", "Issue12964.csproj", "{41562B49-7518-423B-957D-876704FF3F85}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Cloud.PubSub.V1", "..\..\apis\Google.Cloud.PubSub.V1\Google.Cloud.PubSub.V1\Google.Cloud.PubSub.V1.csproj", "{C7261A02-B28E-4457-A661-4C61BB000B28}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41562B49-7518-423B-957D-876704FF3F85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41562B49-7518-423B-957D-876704FF3F85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41562B49-7518-423B-957D-876704FF3F85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41562B49-7518-423B-957D-876704FF3F85}.Release|Any CPU.Build.0 = Release|Any CPU
{C7261A02-B28E-4457-A661-4C61BB000B28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7261A02-B28E-4457-A661-4C61BB000B28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7261A02-B28E-4457-A661-4C61BB000B28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7261A02-B28E-4457-A661-4C61BB000B28}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FDFAD55E-A2C5-4D70-9BB7-9A086622EC9F}
EndGlobalSection
EndGlobal
47 changes: 47 additions & 0 deletions issues/Issue12964/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2024 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Cloud.PubSub.V1;
using Microsoft.Extensions.Logging;

if (args.Length != 2)
{
Console.WriteLine("Arguments: <project-id> <subscription-id>");
return;
}

var loggerFactory = LoggerFactory.Create(builder => builder.AddSimpleConsole(options =>
{
options.SingleLine = true;
options.TimestampFormat = "yyyy-MM-dd'T'HH:mm:ss.fff'Z '";
options.UseUtcTimestamp = true;
}));

var client = new SubscriberClientBuilder
{
SubscriptionName = new SubscriptionName(args[0], args[1]),
Logger = loggerFactory.CreateLogger("Subscriber")
}.Build();

var handlerLogger = loggerFactory.CreateLogger("Handler");

loggerFactory.CreateLogger("Timing").LogInformation("Starting subscriber");
var task = client.StartAsync((message, cancellationToken) =>
{
handlerLogger.LogInformation("Received message with text '{text}'. MessageID='{id}'",
message.Data.ToStringUtf8(), message.MessageId);
return Task.FromResult(SubscriberClient.Reply.Ack);
});

await task;