| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.ComponentModel; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Messaging.ServiceBus |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// The set of options that can be specified when creating a <see cref="ServiceBusSessionReceiver"/> |
| | 11 | | /// to configure its behavior. |
| | 12 | | /// </summary> |
| | 13 | | public class ServiceBusSessionReceiverOptions |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// The number of messages that will be eagerly requested from Queues or Subscriptions and queued locally withou |
| | 17 | | /// whether the receiver is actively receiving, intended to help maximize throughput by allowing the receiver to |
| | 18 | | /// from a local cache rather than waiting on a service request. |
| | 19 | | /// </summary> |
| | 20 | | public int PrefetchCount |
| | 21 | | { |
| | 22 | | get |
| | 23 | | { |
| 14 | 24 | | return _prefetchCount; |
| | 25 | | } |
| | 26 | | set |
| | 27 | | { |
| 0 | 28 | | Argument.AssertAtLeast(value, 0, nameof(PrefetchCount)); |
| 0 | 29 | | _prefetchCount = value; |
| 0 | 30 | | } |
| | 31 | | } |
| | 32 | | private int _prefetchCount = 0; |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// The <see cref="ReceiveMode"/> used to specify how messages are received. Defaults to PeekLock mode. |
| | 36 | | /// </summary> |
| 0 | 37 | | public ReceiveMode ReceiveMode { get; set; } = ReceiveMode.PeekLock; |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// An optional session ID to scope the <see cref="ServiceBusSessionReceiver"/> to. If left blank, |
| | 41 | | /// the next available session returned from the service will be used. |
| | 42 | | /// </summary> |
| 0 | 43 | | public string SessionId { get; set; } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Determines whether the specified <see cref="System.Object" /> is equal to this instance. |
| | 47 | | /// </summary> |
| | 48 | | /// |
| | 49 | | /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> |
| | 50 | | /// |
| | 51 | | /// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c> |
| | 52 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 53 | | public override bool Equals(object obj) => base.Equals(obj); |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Returns a hash code for this instance. |
| | 57 | | /// </summary> |
| | 58 | | /// |
| | 59 | | /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a ha |
| | 60 | | /// |
| | 61 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 62 | | public override int GetHashCode() => base.GetHashCode(); |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// Converts the instance to string representation. |
| | 66 | | /// </summary> |
| | 67 | | /// |
| | 68 | | /// <returns>A <see cref="System.String" /> that represents this instance.</returns> |
| | 69 | | /// |
| | 70 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 71 | | public override string ToString() => base.ToString(); |
| | 72 | |
|
| | 73 | | internal ServiceBusReceiverOptions ToReceiverOptions() => |
| 14 | 74 | | new ServiceBusReceiverOptions() |
| 14 | 75 | | { |
| 14 | 76 | | ReceiveMode = ReceiveMode, |
| 14 | 77 | | PrefetchCount = PrefetchCount |
| 14 | 78 | | }; |
| | 79 | | } |
| | 80 | | } |