Search code examples
gonats-streaming-server

NATS streaming "StartAt" subscription option


I am a little confused about the requirement/significance of StartAt subscription option when compared to others such as StartAtSequence, StartWithLastReceived etc.

I tried to dig into the Java client docs but that did not help either - such as an option cannot be set, but it is gettable

Inputs appreciated!


Solution

  • Abhishek,

    You should have had a look at the Go README.md, since it seems that you are actually interested in the Go client, not the Java one :-)

    Here is a link to the start position.

    As you understand, the StartAtSequence is used to create a subscription at a given sequence number, while StartWithLastReceived indicates that the server should send the last one.

    The StartAt() is simply the generic option in which you would pass the pb.StartPosition, which is an int32, representing the possible options:

    StartPosition_NewOnly        StartPosition = 0
    StartPosition_LastReceived   StartPosition = 1
    StartPosition_TimeDeltaStart StartPosition = 2
    StartPosition_SequenceStart  StartPosition = 3
    StartPosition_First          StartPosition = 4
    

    So you don't need it as long as there is a the "Start" option function for what you want.

    Also, you can find more about subscriptions in our doc.

    Hope this helps.