Skip to content

ContainerAnalysis: Update topic id #1505

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

Merged
merged 2 commits into from
Jul 9, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public synchronized void receiveMessage(PubsubMessage message, AckReplyConsumer
public static Subscription createOccurrenceSubscription(String subId, String projectId)
throws IOException, StatusRuntimeException, InterruptedException {
// This topic id will automatically receive messages when Occurrences are added or modified
String topicId = "container-analysis-occurrences-v1beta1";
String topicId = "container-analysis-occurrences-v1";
ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId);
ProjectSubscriptionName subName = ProjectSubscriptionName.of(projectId, subId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.google.cloud.devtools.containeranalysis.v1.ContainerAnalysisClient;
import com.google.cloud.pubsub.v1.Subscriber;
import com.google.cloud.pubsub.v1.SubscriptionAdminClient;
import com.google.cloud.pubsub.v1.TopicAdminClient;
import com.google.pubsub.v1.ProjectSubscriptionName;
import com.google.pubsub.v1.ProjectTopicName;
import io.grafeas.v1.DiscoveryNote;
import io.grafeas.v1.DiscoveryOccurrence;
import io.grafeas.v1.DiscoveryOccurrence.AnalysisStatus;
Expand Down Expand Up @@ -202,6 +204,14 @@ public void testOccurrencesForNote() throws Exception {
public void testPubSub() throws Exception {
int newCount;
int tries;
// create new topic and subscription if needed
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
String topicId = "container-analysis-occurrences-v1";
ProjectTopicName topicName = ProjectTopicName.of(PROJECT_ID, topicId);
topicAdminClient.createTopic(topicName);
} catch (StatusRuntimeException e) {
System.out.println("Topic already exists");
}
ProjectSubscriptionName subName = ProjectSubscriptionName.of(PROJECT_ID, subId);
try {
Subscriptions.createOccurrenceSubscription(subId, PROJECT_ID);
Expand Down