Skip to content

Not receiving GCS Cloud Pub/Sub Notifications. #2255

Description

@kirankumar-mahi

Hi There,

  • I am not getting object change notification using pub/sub.

I created topic and sub and associated it to bucket notification as below and
gsutil notification create -f json -t projects/syncdemo/topics/filesync gs://mybucket

I wrote code to receive the notifications as below.

        subscriptionName = SubscriptionName.create("syncdemo", "filesyncsub");

        MessageReceiver receiver =
                new MessageReceiver() {
                    @Override
                    public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
                        System.out.println("Id : " + message.getMessageId());
                        System.out.println("Received message: " + message.getData());
                        consumer.ack();
                    }
                };

        // Configure max number of messages to be pulled
        FlowControlSettings flowControlSettings = FlowControlSettings.newBuilder()
                .setMaxOutstandingElementCount(1000l)
                .build();
        subscriber = Subscriber.defaultBuilder(subscriptionName, receiver)
                .setFlowControlSettings(flowControlSettings)
                .build();
        subscriber.startAsync();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions