Skip to content

Commit bd4b537

Browse files
committed
delete publish-related methods from PubSub
1 parent 994479f commit bd4b537

File tree

11 files changed

+8
-827
lines changed

11 files changed

+8
-827
lines changed

google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/PubSubExample.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -285,40 +285,6 @@ public String params() {
285285
}
286286
}
287287

288-
/**
289-
* This class demonstrates how to publish messages to a Pub/Sub topic.
290-
*
291-
* @see <a href="https://cloud.google.com/pubsub/publisher#publish-messages-to-a-topic">Publish
292-
* messages to a topic</a>
293-
*/
294-
private static class PublishMessagesAction extends PubSubAction<Tuple<String, List<Message>>> {
295-
@Override
296-
public void run(PubSub pubsub, Tuple<String, List<Message>> params) {
297-
String topic = params.x();
298-
List<Message> messages = params.y();
299-
pubsub.publish(topic, messages);
300-
System.out.printf("Published %d messages to topic %s%n", messages.size(), topic);
301-
}
302-
303-
@Override
304-
Tuple<String, List<Message>> parse(String... args) throws Exception {
305-
if (args.length < 2) {
306-
throw new IllegalArgumentException("Missing required topic and messages");
307-
}
308-
String topic = args[0];
309-
List<Message> messages = new ArrayList<>();
310-
for (String payload : Arrays.copyOfRange(args, 1, args.length)) {
311-
messages.add(Message.of(payload));
312-
}
313-
return Tuple.of(topic, messages);
314-
}
315-
316-
@Override
317-
public String params() {
318-
return "<topic> <message>+";
319-
}
320-
}
321-
322288
private abstract static class SubscriptionAction extends PubSubAction<String> {
323289
@Override
324290
String parse(String... args) throws Exception {
@@ -643,7 +609,6 @@ public void run(PubSub pubsub, Tuple<String, List<String>> param) throws Excepti
643609
ACTIONS.put("get-policy", new ParentAction(GET_IAM_ACTIONS));
644610
ACTIONS.put("add-identity", new ParentAction(REPLACE_IAM_ACTIONS));
645611
ACTIONS.put("test-permissions", new ParentAction(TEST_IAM_ACTIONS));
646-
ACTIONS.put("publish", new PublishMessagesAction());
647612
ACTIONS.put("replace-push-config", new ReplacePushConfigAction());
648613
}
649614

google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/CreateTopicAndPublishMessages.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/PubSubSnippets.java

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -186,99 +186,6 @@ public boolean deleteTopicAsync(String topicName)
186186
return deleted;
187187
}
188188

189-
/**
190-
* Example of publishing one message to a topic.
191-
*/
192-
// [TARGET publish(String, Message)]
193-
// [VARIABLE "my_topic_name"]
194-
public String publishOneMessage(String topicName) {
195-
// [START publishOneMessage]
196-
Message message = Message.of("payload");
197-
String messageId = pubsub.publish(topicName, message);
198-
// [END publishOneMessage]
199-
return messageId;
200-
}
201-
202-
/**
203-
* Example of asynchronously publishing one message to a topic.
204-
*/
205-
// [TARGET publishAsync(String, Message)]
206-
// [VARIABLE "my_topic_name"]
207-
public String publishOneMessageAsync(String topicName)
208-
throws ExecutionException, InterruptedException {
209-
// [START publishOneMessageAsync]
210-
Message message = Message.of("payload");
211-
Future<String> future = pubsub.publishAsync(topicName, message);
212-
// ...
213-
String messageId = future.get();
214-
// [END publishOneMessageAsync]
215-
return messageId;
216-
}
217-
218-
/**
219-
* Example of publishing a list of messages to a topic.
220-
*/
221-
// [TARGET publish(String, Iterable)]
222-
// [VARIABLE "my_topic_name"]
223-
public List<String> publishMessageList(String topicName) {
224-
// [START publishMessageList]
225-
List<Message> messages = new LinkedList<>();
226-
messages.add(Message.of("payload1"));
227-
messages.add(Message.of("payload2"));
228-
List<String> messageIds = pubsub.publish(topicName, messages);
229-
// [END publishMessageList]
230-
return messageIds;
231-
}
232-
233-
/**
234-
* Example of asynchronously publishing a list of messages to a topic.
235-
*/
236-
// [TARGET publishAsync(String, Iterable)]
237-
// [VARIABLE "my_topic_name"]
238-
public List<String> publishMessageListAsync(String topicName)
239-
throws ExecutionException, InterruptedException {
240-
// [START publishMessageListAsync]
241-
List<Message> messages = new LinkedList<>();
242-
messages.add(Message.of("payload1"));
243-
messages.add(Message.of("payload2"));
244-
Future<List<String>> future = pubsub.publishAsync(topicName, messages);
245-
// ...
246-
List<String> messageIds = future.get();
247-
// [END publishMessageListAsync]
248-
return messageIds;
249-
}
250-
251-
/**
252-
* Example of publishing some messages to a topic.
253-
*/
254-
// [TARGET publish(String, Message, Message...)]
255-
// [VARIABLE "my_topic_name"]
256-
public List<String> publishMessages(String topicName) {
257-
// [START publishMessages]
258-
Message message1 = Message.of("payload1");
259-
Message message2 = Message.of("payload2");
260-
List<String> messageIds = pubsub.publish(topicName, message1, message2);
261-
// [END publishMessages]
262-
return messageIds;
263-
}
264-
265-
/**
266-
* Example of asynchronously publishing some messages to a topic.
267-
*/
268-
// [TARGET publishAsync(String, Message, Message...)]
269-
// [VARIABLE "my_topic_name"]
270-
public List<String> publishMessagesAsync(String topicName)
271-
throws ExecutionException, InterruptedException {
272-
// [START publishMessagesAsync]
273-
Message message1 = Message.of("payload1");
274-
Message message2 = Message.of("payload2");
275-
Future<List<String>> future = pubsub.publishAsync(topicName, message1, message2);
276-
// ...
277-
List<String> messageIds = future.get();
278-
// [END publishMessagesAsync]
279-
return messageIds;
280-
}
281-
282189
/**
283190
* Example of creating a pull subscription for a topic.
284191
*/

google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicSnippets.java

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -113,94 +113,6 @@ public boolean deleteAsync() throws ExecutionException, InterruptedException {
113113
return deleted;
114114
}
115115

116-
/**
117-
* Example of publishing one message to the topic.
118-
*/
119-
// [TARGET publish(Message)]
120-
public String publishOneMessage() {
121-
// [START publishOneMessage]
122-
Message message = Message.of("payload");
123-
String messageId = topic.publish(message);
124-
// [END publishOneMessage]
125-
return messageId;
126-
}
127-
128-
/**
129-
* Example of asynchronously publishing one message to the topic.
130-
*/
131-
// [TARGET publishAsync(Message)]
132-
public String publishOneMessageAsync()
133-
throws ExecutionException, InterruptedException {
134-
// [START publishOneMessageAsync]
135-
Message message = Message.of("payload");
136-
Future<String> future = topic.publishAsync(message);
137-
// ...
138-
String messageId = future.get();
139-
// [END publishOneMessageAsync]
140-
return messageId;
141-
}
142-
143-
144-
/**
145-
* Example of publishing a list of messages to the topic.
146-
*/
147-
// [TARGET publish(Iterable)]
148-
public List<String> publishMessageList() {
149-
// [START publishMessageList]
150-
List<Message> messages = new LinkedList<>();
151-
messages.add(Message.of("payload1"));
152-
messages.add(Message.of("payload2"));
153-
List<String> messageIds = topic.publish(messages);
154-
// [END publishMessageList]
155-
return messageIds;
156-
}
157-
158-
/**
159-
* Example of asynchronously publishing a list of messages to the topic.
160-
*/
161-
// [TARGET publishAsync(Iterable)]
162-
public List<String> publishMessageListAsync()
163-
throws ExecutionException, InterruptedException {
164-
// [START publishMessageListAsync]
165-
List<Message> messages = new LinkedList<>();
166-
messages.add(Message.of("payload1"));
167-
messages.add(Message.of("payload2"));
168-
Future<List<String>> future = topic.publishAsync(messages);
169-
// ...
170-
List<String> messageIds = future.get();
171-
// [END publishMessageListAsync]
172-
return messageIds;
173-
}
174-
175-
/**
176-
* Example of publishing some messages to the topic.
177-
*/
178-
// [TARGET publish(Message, Message...)]
179-
public List<String> publishMessages() {
180-
// [START publishMessages]
181-
Message message1 = Message.of("payload1");
182-
Message message2 = Message.of("payload2");
183-
List<String> messageIds = topic.publish(message1, message2);
184-
// [END publishMessages]
185-
return messageIds;
186-
}
187-
188-
/**
189-
* Example of asynchronously publishing some messages to the topic.
190-
*/
191-
// [TARGET publishAsync(Message, Message...)]
192-
public List<String> publishMessagesAsync()
193-
throws ExecutionException, InterruptedException {
194-
// [START publishMessagesAsync]
195-
Message message1 = Message.of("payload1");
196-
Message message2 = Message.of("payload2");
197-
Future<List<String>> future = topic.publishAsync(message1, message2);
198-
// ...
199-
List<String> messageIds = future.get();
200-
// [END publishMessagesAsync]
201-
return messageIds;
202-
}
203-
204116
/**
205117
* Example of listing subscriptions for the topic, specifying the page size.
206118
*/

google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITTopicSnippets.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ public void testTopic() throws ExecutionException, InterruptedException {
7070
assertEquals(topic, updatedTopic);
7171
updatedTopic = topicSnippets.reloadAsync();
7272
assertEquals(topic, updatedTopic);
73-
assertNotNull(topicSnippets.publishOneMessage());
74-
assertNotNull(topicSnippets.publishOneMessageAsync());
75-
assertEquals(2, topicSnippets.publishMessageList().size());
76-
assertEquals(2, topicSnippets.publishMessageListAsync().size());
77-
assertEquals(2, topicSnippets.publishMessages().size());
78-
assertEquals(2, topicSnippets.publishMessagesAsync().size());
7973
}
8074

8175
@Test

0 commit comments

Comments
 (0)