public void CreateTopicAndSubscription()
{
try
{
_pub.CreateTopic(_topicName);
_logger.LogVerbose("Created topic " + _topicName);
}
catch (Grpc.Core.RpcException e)
when (e.Status.StatusCode == Grpc.Core.StatusCode.AlreadyExists)
{
// The topic already exists. Ok.
_logger.LogError(_topicName + " already exists", e);
}
try
{
_sub.CreateSubscription(_subscriptionName, _topicName, null, 0);
_logger.LogVerbose("Created subscription " + _subscriptionName);
}
catch (Grpc.Core.RpcException e)
when (e.Status.StatusCode == Grpc.Core.StatusCode.AlreadyExists)
{
// The subscription already exists. Ok.
_logger.LogError(_subscriptionName + " already exists", e);
}
}
// [END createtopicandsubscription]