
@cloudshell:~ (poetic-genius-271117)$ gcloud pubsub subscriptions pull Labsub3 –auto-ack –limit=3
┌───────┬──────────────────┬────────────┬──────────────────┐
│ DATA │ MESSAGE_ID │ ATTRIBUTES │ DELIVERY_ATTEMPT │
├───────┼──────────────────┼────────────┼──────────────────┤
│ Yho 1 │ 1427032616808217 │ │ │
└───────┴──────────────────┴────────────┴──────────────────┘
@cloudshell:~ (poetic-genius-271117)$ gcloud pubsub subscriptions pull Labsub3 –auto-ack –limit=3
┌───────────┬──────────────────┬────────────┬──────────────────┐
│ DATA │ MESSAGE_ID │ ATTRIBUTES │ DELIVERY_ATTEMPT │
├───────────┼──────────────────┼────────────┼──────────────────┤
│ Yho 1+1=2 │ 1427031684530098 │ │ │
│ Yho 2+1=3 │ 1427032940823233 │ │ │
│ Yho 2+2=4 │ 1427031469909841 │ │ │
└───────────┴──────────────────┴────────────┴──────────────────┘
Hey Anoop….Limit is just to read only 3 messages when if you have more than 3 messages ready for pull but if you have less than 3 messages ready for pull then it displays only those. In your case, during first run only one message was ready to be pulled and then next time, there were three messages ready to be pulled so it displays all three. There were 4 messages into your topic as shown by distinct 4 message ids.