Skip to content

Commit 0699b05

Browse files
[azservicebus] Updating to include link to the message browsing documentation. (Azure#21834)
According to Azure#19758, customers are sometimes confused about the feature altogether. Adding in a link to the longer-form description from the Service Bus team. Fixes Azure#16897
1 parent 176048d commit 0699b05

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

sdk/messaging/azservicebus/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (client *Client) NewSender(queueOrTopic string, options *NewSenderOptions)
232232

233233
// AcceptSessionForQueue accepts a session from a queue with a specific session ID.
234234
// NOTE: this receiver is initialized immediately, not lazily.
235-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
235+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
236236
func (client *Client) AcceptSessionForQueue(ctx context.Context, queueName string, sessionID string, options *SessionReceiverOptions) (*SessionReceiver, error) {
237237
id, cleanupOnClose := client.getCleanupForCloseable()
238238
sessionReceiver, err := newSessionReceiver(
@@ -259,7 +259,7 @@ func (client *Client) AcceptSessionForQueue(ctx context.Context, queueName strin
259259

260260
// AcceptSessionForSubscription accepts a session from a subscription with a specific session ID.
261261
// NOTE: this receiver is initialized immediately, not lazily.
262-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
262+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
263263
func (client *Client) AcceptSessionForSubscription(ctx context.Context, topicName string, subscriptionName string, sessionID string, options *SessionReceiverOptions) (*SessionReceiver, error) {
264264
id, cleanupOnClose := client.getCleanupForCloseable()
265265
sessionReceiver, err := newSessionReceiver(

sdk/messaging/azservicebus/receiver.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ type ReceiveMessagesOptions struct {
186186

187187
// ReceiveMessages receives a fixed number of messages, up to numMessages.
188188
// This function will block until at least one message is received or until the ctx is cancelled.
189-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
189+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
190190
func (r *Receiver) ReceiveMessages(ctx context.Context, maxMessages int, options *ReceiveMessagesOptions) ([]*ReceivedMessage, error) {
191191
r.mu.Lock()
192192
isReceiving := r.receiving
@@ -216,7 +216,7 @@ type ReceiveDeferredMessagesOptions struct {
216216
}
217217

218218
// ReceiveDeferredMessages receives messages that were deferred using `Receiver.DeferMessage`.
219-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
219+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
220220
func (r *Receiver) ReceiveDeferredMessages(ctx context.Context, sequenceNumbers []int64, options *ReceiveDeferredMessagesOptions) ([]*ReceivedMessage, error) {
221221
var receivedMessages []*ReceivedMessage
222222

@@ -251,12 +251,14 @@ type PeekMessagesOptions struct {
251251
//
252252
// The Receiver stores the last peeked sequence number internally, and will use it as the
253253
// start location for the next PeekMessages() call. You can override this behavior by passing an
254-
// explicit sequence number in PeekMessagesOptions.FromSequenceNumber.
254+
// explicit sequence number in [azservicebus.PeekMessagesOptions.FromSequenceNumber].
255255
//
256-
// Messages that are peeked do not have lock tokens, so settlement methods
257-
// like CompleteMessage, AbandonMessage, DeferMessage or DeadLetterMessage
258-
// will not work with them.
259-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
256+
// Messages that are peeked are not locked, so settlement methods like [Receiver.CompleteMessage],
257+
// [Receiver.AbandonMessage], [Receiver.DeferMessage] or [Receiver.DeadLetterMessage] will not work with them.
258+
//
259+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
260+
//
261+
// For more information about peeking/message-browsing see https://aka.ms/azsdk/servicebus/message-browsing
260262
func (r *Receiver) PeekMessages(ctx context.Context, maxMessageCount int, options *PeekMessagesOptions) ([]*ReceivedMessage, error) {
261263
var receivedMessages []*ReceivedMessage
262264

@@ -298,7 +300,7 @@ type RenewMessageLockOptions struct {
298300
}
299301

300302
// RenewMessageLock renews the lock on a message, updating the `LockedUntil` field on `msg`.
301-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
303+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
302304
func (r *Receiver) RenewMessageLock(ctx context.Context, msg *ReceivedMessage, options *RenewMessageLockOptions) error {
303305
err := r.amqpLinks.Retry(ctx, EventReceiver, "renewMessageLock", func(ctx context.Context, linksWithVersion *internal.LinksWithID, args *utils.RetryFnArgs) error {
304306
newExpirationTime, err := internal.RenewLocks(ctx, linksWithVersion.RPC, msg.RawAMQPMessage.linkName, []amqp.UUID{
@@ -328,7 +330,7 @@ func (r *Receiver) Close(ctx context.Context) error {
328330

329331
// CompleteMessage completes a message, deleting it from the queue or subscription.
330332
// This function can only be used when the Receiver has been opened with ReceiveModePeekLock.
331-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
333+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
332334
func (r *Receiver) CompleteMessage(ctx context.Context, message *ReceivedMessage, options *CompleteMessageOptions) error {
333335
return r.settler.CompleteMessage(ctx, message, options)
334336
}
@@ -337,15 +339,15 @@ func (r *Receiver) CompleteMessage(ctx context.Context, message *ReceivedMessage
337339
// This will increment its delivery count, and potentially cause it to be dead-lettered
338340
// depending on your queue or subscription's configuration.
339341
// This function can only be used when the Receiver has been opened with `ReceiveModePeekLock`.
340-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
342+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
341343
func (r *Receiver) AbandonMessage(ctx context.Context, message *ReceivedMessage, options *AbandonMessageOptions) error {
342344
return r.settler.AbandonMessage(ctx, message, options)
343345
}
344346

345347
// DeferMessage will cause a message to be deferred. Deferred messages can be received using
346348
// `Receiver.ReceiveDeferredMessages`.
347349
// This function can only be used when the Receiver has been opened with `ReceiveModePeekLock`.
348-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
350+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
349351
func (r *Receiver) DeferMessage(ctx context.Context, message *ReceivedMessage, options *DeferMessageOptions) error {
350352
return r.settler.DeferMessage(ctx, message, options)
351353
}
@@ -354,7 +356,7 @@ func (r *Receiver) DeferMessage(ctx context.Context, message *ReceivedMessage, o
354356
// queue or subscription. To receive these messages create a receiver with `Client.NewReceiverForQueue()`
355357
// or `Client.NewReceiverForSubscription()` using the `ReceiverOptions.SubQueue` option.
356358
// This function can only be used when the Receiver has been opened with `ReceiveModePeekLock`.
357-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
359+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
358360
func (r *Receiver) DeadLetterMessage(ctx context.Context, message *ReceivedMessage, options *DeadLetterOptions) error {
359361
return r.settler.DeadLetterMessage(ctx, message, options)
360362
}

sdk/messaging/azservicebus/sender.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ type SendMessageBatchOptions struct {
9090
}
9191

9292
// SendMessageBatch sends a MessageBatch to a queue or topic.
93-
// Message batches can be created using `Sender.NewMessageBatch`.
94-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
93+
// Message batches can be created using [Sender.NewMessageBatch].
94+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
9595
func (s *Sender) SendMessageBatch(ctx context.Context, batch *MessageBatch, options *SendMessageBatchOptions) error {
9696
err := s.links.Retry(ctx, EventSender, "SendMessageBatch", func(ctx context.Context, lwid *internal.LinksWithID, args *utils.RetryFnArgs) error {
9797
return lwid.Sender.Send(ctx, batch.toAMQPMessage(), nil)
@@ -108,7 +108,7 @@ type ScheduleMessagesOptions struct {
108108
// ScheduleMessages schedules a slice of Messages to appear on Service Bus Queue/Subscription at a later time.
109109
// Returns the sequence numbers of the messages that were scheduled. Messages that haven't been
110110
// delivered can be cancelled using `Receiver.CancelScheduleMessage(s)`
111-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
111+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
112112
func (s *Sender) ScheduleMessages(ctx context.Context, messages []*Message, scheduledEnqueueTime time.Time, options *ScheduleMessagesOptions) ([]int64, error) {
113113
return scheduleMessages(ctx, s.links, s.retryOptions, messages, scheduledEnqueueTime)
114114
}
@@ -121,7 +121,7 @@ type ScheduleAMQPAnnotatedMessagesOptions struct {
121121
// ScheduleAMQPAnnotatedMessages schedules a slice of Messages to appear on Service Bus Queue/Subscription at a later time.
122122
// Returns the sequence numbers of the messages that were scheduled. Messages that haven't been
123123
// delivered can be cancelled using `Receiver.CancelScheduleMessage(s)`
124-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
124+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
125125
func (s *Sender) ScheduleAMQPAnnotatedMessages(ctx context.Context, messages []*AMQPAnnotatedMessage, scheduledEnqueueTime time.Time, options *ScheduleAMQPAnnotatedMessagesOptions) ([]int64, error) {
126126
return scheduleMessages(ctx, s.links, s.retryOptions, messages, scheduledEnqueueTime)
127127
}
@@ -156,7 +156,7 @@ type CancelScheduledMessagesOptions struct {
156156
}
157157

158158
// CancelScheduledMessages cancels multiple messages that were scheduled.
159-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
159+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
160160
func (s *Sender) CancelScheduledMessages(ctx context.Context, sequenceNumbers []int64, options *CancelScheduledMessagesOptions) error {
161161
err := s.links.Retry(ctx, EventSender, "CancelScheduledMessages", func(ctx context.Context, lwv *internal.LinksWithID, args *utils.RetryFnArgs) error {
162162
return internal.CancelScheduledMessages(ctx, lwv.RPC, lwv.Sender.LinkName(), sequenceNumbers)

sdk/messaging/azservicebus/session_receiver.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,29 @@ func (r *SessionReceiver) newLink(ctx context.Context, session amqpwrap.AMQPSess
134134

135135
// ReceiveMessages receives a fixed number of messages, up to maxMessages.
136136
// This function will block until at least one message is received or until the ctx is cancelled.
137-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
137+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
138138
func (r *SessionReceiver) ReceiveMessages(ctx context.Context, maxMessages int, options *ReceiveMessagesOptions) ([]*ReceivedMessage, error) {
139139
return r.inner.ReceiveMessages(ctx, maxMessages, options)
140140
}
141141

142142
// ReceiveDeferredMessages receives messages that were deferred using `Receiver.DeferMessage`.
143-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
143+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
144144
func (r *SessionReceiver) ReceiveDeferredMessages(ctx context.Context, sequenceNumbers []int64, options *ReceiveDeferredMessagesOptions) ([]*ReceivedMessage, error) {
145145
return r.inner.ReceiveDeferredMessages(ctx, sequenceNumbers, options)
146146
}
147147

148148
// PeekMessages will peek messages without locking or deleting messages.
149-
// Messages that are peeked do not have lock tokens, so settlement methods
150-
// like CompleteMessage, AbandonMessage, DeferMessage or DeadLetterMessage
151-
// will not work with them.
152-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
149+
//
150+
// The SessionReceiver stores the last peeked sequence number internally, and will use it as the
151+
// start location for the next PeekMessages() call. You can override this behavior by passing an
152+
// explicit sequence number in [azservicebus.PeekMessagesOptions.FromSequenceNumber].
153+
//
154+
// Messages that are peeked are not locked, so settlement methods like [SessionReceiver.CompleteMessage],
155+
// [SessionReceiver.AbandonMessage], [SessionReceiver.DeferMessage] or [SessionReceiver.DeadLetterMessage] will not work with them.
156+
//
157+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
158+
//
159+
// For more information about peeking/message-browsing see https://aka.ms/azsdk/servicebus/message-browsing
153160
func (r *SessionReceiver) PeekMessages(ctx context.Context, maxMessageCount int, options *PeekMessagesOptions) ([]*ReceivedMessage, error) {
154161
return r.inner.PeekMessages(ctx, maxMessageCount, options)
155162
}
@@ -160,30 +167,30 @@ func (r *SessionReceiver) Close(ctx context.Context) error {
160167
}
161168

162169
// CompleteMessage completes a message, deleting it from the queue or subscription.
163-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
170+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
164171
func (r *SessionReceiver) CompleteMessage(ctx context.Context, message *ReceivedMessage, options *CompleteMessageOptions) error {
165172
return r.inner.CompleteMessage(ctx, message, options)
166173
}
167174

168175
// AbandonMessage will cause a message to be returned to the queue or subscription.
169176
// This will increment its delivery count, and potentially cause it to be dead lettered
170177
// depending on your queue or subscription's configuration.
171-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
178+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
172179
func (r *SessionReceiver) AbandonMessage(ctx context.Context, message *ReceivedMessage, options *AbandonMessageOptions) error {
173180
return r.inner.AbandonMessage(ctx, message, options)
174181
}
175182

176183
// DeferMessage will cause a message to be deferred. Deferred messages
177184
// can be received using `Receiver.ReceiveDeferredMessages`.
178-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
185+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
179186
func (r *SessionReceiver) DeferMessage(ctx context.Context, message *ReceivedMessage, options *DeferMessageOptions) error {
180187
return r.inner.DeferMessage(ctx, message, options)
181188
}
182189

183190
// DeadLetterMessage settles a message by moving it to the dead letter queue for a
184191
// queue or subscription. To receive these messages create a receiver with `Client.NewReceiverForQueue()`
185192
// or `Client.NewReceiverForSubscription()` using the `ReceiverOptions.SubQueue` option.
186-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
193+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
187194
func (r *SessionReceiver) DeadLetterMessage(ctx context.Context, message *ReceivedMessage, options *DeadLetterOptions) error {
188195
return r.inner.DeadLetterMessage(ctx, message, options)
189196
}
@@ -207,7 +214,7 @@ type GetSessionStateOptions struct {
207214
}
208215

209216
// GetSessionState retrieves state associated with the session.
210-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
217+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
211218
func (sr *SessionReceiver) GetSessionState(ctx context.Context, options *GetSessionStateOptions) ([]byte, error) {
212219
var sessionState []byte
213220

@@ -232,7 +239,7 @@ type SetSessionStateOptions struct {
232239

233240
// SetSessionState sets the state associated with the session.
234241
// Pass nil for the state parameter to clear the stored session state.
235-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
242+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
236243
func (sr *SessionReceiver) SetSessionState(ctx context.Context, state []byte, options *SetSessionStateOptions) error {
237244
err := sr.inner.amqpLinks.Retry(ctx, EventReceiver, "SetSessionState", func(ctx context.Context, lwv *internal.LinksWithID, args *utils.RetryFnArgs) error {
238245
return internal.SetSessionState(ctx, lwv.RPC, lwv.Receiver.LinkName(), sr.SessionID(), state)
@@ -248,7 +255,7 @@ type RenewSessionLockOptions struct {
248255

249256
// RenewSessionLock renews this session's lock. The new expiration time is available
250257
// using `LockedUntil`.
251-
// If the operation fails it can return an *azservicebus.Error type if the failure is actionable.
258+
// If the operation fails it can return an [*azservicebus.Error] type if the failure is actionable.
252259
func (sr *SessionReceiver) RenewSessionLock(ctx context.Context, options *RenewSessionLockOptions) error {
253260
err := sr.inner.amqpLinks.Retry(ctx, EventReceiver, "RenewSessionLock", func(ctx context.Context, lwv *internal.LinksWithID, args *utils.RetryFnArgs) error {
254261
newLockedUntil, err := internal.RenewSessionLock(ctx, lwv.RPC, lwv.Receiver.LinkName(), *sr.sessionID)

0 commit comments

Comments
 (0)