title: Google PubSub and duplicated messages from the TOPIC
body: <p>How to prevent duplicated msg from happening in Google Cloud PubSub?</p>
  
  <p>Say, I have a code that handles the msg that it is subscribed for.</p>
  
  <p>Say, I have 2 nodes with the same Service that has this code.</p>
  
  <p>Once one has received the msg but not yet acknowledged it, another node will receive the same message. And this is where there's the problem that we have two <strong>duplicated msgs</strong>.</p>
  
  <pre><code>void messageReceiver(PubsubMessage pubsubMessage, AckReplyConsumer ackReply) {
  
          submitHandler.handle(toMessage(pubsubMessage))
                  .doOnSuccess((response) -&gt; {
                      log.info("Acknowledging the successfully processed message id: {}, response {}", pubsubMessage.getMessageId(), response);
                      ackReply.ack();  // &lt;---- acknowledged
                  })
                  .doOnError((e) -&gt; {
                      log.error("Not acknowledging due to an exception", e);
                      ackReply.nack();
                  })
                  .doOnTerminate(span::finish)
                  .subscribe();
      }
  </code></pre>
  
  <p>What is the solution for this? Is it normal behaviour?</p>