Skip to content

Commit 8c5a7f7

Browse files
kannappanrharshavardhana
authored andcommitted
Modify example to use SQS configuration in Notification (#725)
1 parent ff7ff1b commit 8c5a7f7

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

examples/SetBucketNotification.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Minio Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2017 Minio, Inc.
2+
* Minio Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2017, 2018 Minio, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626

2727
import io.minio.MinioClient;
2828
import io.minio.messages.NotificationConfiguration;
29-
import io.minio.messages.TopicConfiguration;
29+
import io.minio.messages.QueueConfiguration;
3030
import io.minio.messages.EventType;
3131
import io.minio.messages.Filter;
3232

@@ -39,9 +39,8 @@ public class SetBucketNotification {
3939
public static void main(String[] args)
4040
throws IOException, NoSuchAlgorithmException, InvalidKeyException, XmlPullParserException {
4141
try {
42-
/* play.minio.io for test and development. */
43-
MinioClient minioClient = new MinioClient("https://play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F",
44-
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
42+
/* Local Minio for test and development. */
43+
MinioClient minioClient = new MinioClient("http://127.0.0.1:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETKEY");
4544

4645
/* Amazon S3: */
4746
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
@@ -50,23 +49,23 @@ public static void main(String[] args)
5049
// Get current notification configuration.
5150
NotificationConfiguration notificationConfiguration = minioClient.getBucketNotification("my-bucketname");
5251

53-
// Add a new topic configuration.
54-
List<TopicConfiguration> topicConfigurationList = notificationConfiguration.topicConfigurationList();
55-
TopicConfiguration topicConfiguration = new TopicConfiguration();
56-
topicConfiguration.setTopic("arn:aws:sns:us-west-2:444455556666:sns-topic-xyz");
52+
// Add a new SQS configuration.
53+
List<QueueConfiguration> queueConfigurationList = notificationConfiguration.queueConfigurationList();
54+
QueueConfiguration queueConfiguration = new QueueConfiguration();
55+
queueConfiguration.setQueue("arn:minio:sqs::1:webhook");
5756

5857
List<EventType> eventList = new LinkedList<>();
5958
eventList.add(EventType.OBJECT_CREATED_PUT);
6059
eventList.add(EventType.OBJECT_CREATED_COPY);
61-
topicConfiguration.setEvents(eventList);
60+
queueConfiguration.setEvents(eventList);
6261

6362
Filter filter = new Filter();
6463
filter.setPrefixRule("images");
6564
filter.setSuffixRule("pg");
66-
topicConfiguration.setFilter(filter);
65+
queueConfiguration.filter(filter);
6766

68-
topicConfigurationList.add(topicConfiguration);
69-
notificationConfiguration.setTopicConfigurationList(topicConfigurationList);
67+
queueConfigurationList.add(queueConfiguration);
68+
notificationConfiguration.setQueueConfigurationList(queueConfigurationList);
7069

7170
// Set updated notification configuration.
7271
minioClient.setBucketNotification("my-bucketname", notificationConfiguration);

0 commit comments

Comments
 (0)