Skip to content

Commit 33362b5

Browse files
authored
Javadocs update 2 (Azure#17826)
* Update documentation for message batch, messages, and processor client. * Adding links to options. * Add transaction code snippets. * Adding sender, receiver, and session client documentation. * Fix docs naming * Update to getSubject -> getLabel * Change to getFirstData()
1 parent 276c40e commit 33362b5

21 files changed

+749
-577
lines changed

sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusMessage.java

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.azure.core.util.Context;
1616
import com.azure.core.util.logging.ClientLogger;
1717

18+
import java.nio.charset.StandardCharsets;
1819
import java.time.Duration;
1920
import java.time.OffsetDateTime;
2021
import java.time.ZoneOffset;
@@ -36,10 +37,12 @@
3637
* in the <a href="https://docs.microsoft.com/azure/service-bus-messaging/service-bus-messages-payloads">product
3738
* documentation</a>.
3839
*
40+
* @see ServiceBusReceivedMessage
3941
* @see ServiceBusMessageBatch
4042
* @see ServiceBusSenderAsyncClient#sendMessage(ServiceBusMessage)
4143
* @see ServiceBusSenderClient#sendMessage(ServiceBusMessage)
42-
* @see BinaryData
44+
* @see <a href="https://docs.microsoft.com/azure/service-bus-messaging/service-bus-messages-payloads">Service Bus
45+
* message payloads</a>
4346
* @see <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-complete-v1.0-os.pdf">AMQP 1.0 specification
4447
* </a>
4548
*/
@@ -65,9 +68,9 @@ public ServiceBusMessage(byte[] body) {
6568
}
6669

6770
/**
68-
* Creates a {@link ServiceBusMessage} with a {@link java.nio.charset.StandardCharsets#UTF_8 UTF_8} encoded body.
71+
* Creates a {@link ServiceBusMessage} with a {@link StandardCharsets#UTF_8 UTF-8} encoded body.
6972
*
70-
* @param body The content of the Service bus message.
73+
* @param body The content of the Service Bus message.
7174
*
7275
* @throws NullPointerException if {@code body} is null.
7376
*/
@@ -200,15 +203,6 @@ public ServiceBusMessage(ServiceBusReceivedMessage receivedMessage) {
200203
this.context = Context.NONE;
201204
}
202205

203-
/**
204-
* Gets the {@link AmqpAnnotatedMessage}.
205-
*
206-
* @return The raw AMQP message.
207-
*/
208-
public AmqpAnnotatedMessage getRawAmqpMessage() {
209-
return amqpAnnotatedMessage;
210-
}
211-
212206
/**
213207
* Gets the set of free-form {@link ServiceBusMessage} properties which may be used for passing metadata associated
214208
* with the {@link ServiceBusMessage} during Service Bus operations. A common use-case for {@code
@@ -222,17 +216,16 @@ public Map<String, Object> getApplicationProperties() {
222216
}
223217

224218
/**
225-
* Gets the actual payload/data wrapped by the {@link ServiceBusMessage}.
219+
* Gets the actual payload wrapped by the {@link ServiceBusMessage}.
226220
*
227221
* <p>The {@link BinaryData} wraps byte array and is an abstraction over many different ways it can be represented.
228-
* It provides many convenience API including APIs to serialize/deserialize object.
229-
* <p>
230-
* If the means for deserializing the raw data is not apparent to consumers, a common technique is to make use of
231-
* {@link #getApplicationProperties()} when creating the event, to associate serialization hints as an aid to
232-
* consumers who wish to deserialize the binary data.
233-
* </p>
222+
* It provides convenience APIs to serialize/deserialize the object.</p>
223+
*
224+
* <p>If the means for deserializing the raw data is not apparent to consumers, a common technique is to make use
225+
* of {@link #getApplicationProperties()} when creating the event, to associate serialization hints as an aid to
226+
* consumers who wish to deserialize the binary data.</p>
234227
*
235-
* @return A byte array representing the data.
228+
* @return Binary data representing the payload.
236229
*/
237230
public BinaryData getBody() {
238231
final AmqpMessageBodyType type = amqpAnnotatedMessage.getBody().getBodyType();
@@ -252,6 +245,10 @@ public BinaryData getBody() {
252245
/**
253246
* Gets the content type of the message.
254247
*
248+
* <p>
249+
* Optionally describes the payload of the message, with a descriptor following the format of RFC2045, Section 5,
250+
* for example "application/json".
251+
* </p>
255252
* @return The content type of the {@link ServiceBusMessage}.
256253
*/
257254
public String getContentType() {
@@ -282,7 +279,7 @@ public ServiceBusMessage setContentType(String contentType) {
282279
* reflecting the MessageId of a message that is being replied to.
283280
* </p>
284281
*
285-
* @return correlation id of this message
282+
* @return The correlation id of this message.
286283
* @see <a href="https://docs.microsoft.com/azure/service-bus-messaging/service-bus-messages-payloads?#message-routing-and-correlation">Message
287284
* Routing and Correlation</a>
288285
*/
@@ -346,8 +343,7 @@ public ServiceBusMessage setSubject(String subject) {
346343
* identifier is a free-form string and can reflect a GUID or an identifier derived from the application context. If
347344
* enabled, the
348345
* <a href="https://docs.microsoft.com/azure/service-bus-messaging/duplicate-detection">duplicate detection</a>
349-
* feature identifies and removes second and further submissions of messages with the same {@link #getMessageId()
350-
* message id}.
346+
* feature identifies and removes second and further submissions of messages with the same {@code messageId}.
351347
* </p>
352348
*
353349
* @return Id of the {@link ServiceBusMessage}.
@@ -415,6 +411,15 @@ public ServiceBusMessage setPartitionKey(String partitionKey) {
415411
return this;
416412
}
417413

414+
/**
415+
* Gets the {@link AmqpAnnotatedMessage}.
416+
*
417+
* @return The raw AMQP message.
418+
*/
419+
public AmqpAnnotatedMessage getRawAmqpMessage() {
420+
return amqpAnnotatedMessage;
421+
}
422+
418423
/**
419424
* Gets the address of an entity to send replies to.
420425
* <p>

sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusMessageBatch.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,27 @@ public final class ServiceBusMessageBatch {
4949
}
5050

5151
/**
52-
* Gets the number of {@link ServiceBusMessage events} in the batch.
52+
* Gets the number of {@link ServiceBusMessage messages} in the batch.
5353
*
54-
* @return The number of {@link ServiceBusMessage events} in the batch.
54+
* @return The number of {@link ServiceBusMessage messages} in the batch.
5555
*/
5656
public int getCount() {
5757
return serviceBusMessageList.size();
5858
}
5959

6060
/**
61-
* Gets the maximum size, in bytes, of the {@link ServiceBusMessageBatch}.
61+
* Gets the maximum size, in bytes, of the {@link ServiceBusMessageBatch batch}.
6262
*
63-
* @return The maximum size, in bytes, of the {@link ServiceBusMessageBatch}.
63+
* @return The maximum size, in bytes, of the {@link ServiceBusMessageBatch batch}.
6464
*/
6565
public int getMaxSizeInBytes() {
6666
return maxMessageSize;
6767
}
6868

6969
/**
70-
* Gets the size of the {@link ServiceBusMessageBatch} in bytes.
70+
* Gets the size of the {@link ServiceBusMessageBatch batch} in bytes.
7171
*
72-
* @return the size of the {@link ServiceBusMessageBatch} in bytes.
72+
* @return The size of the {@link ServiceBusMessageBatch batch} in bytes.
7373
*/
7474
public int getSizeInBytes() {
7575
return this.sizeInBytes;

sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusProcessorClient.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.azure.core.util.Context;
88
import com.azure.core.util.logging.ClientLogger;
99
import com.azure.core.util.tracing.ProcessKind;
10+
import com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusProcessorClientBuilder;
11+
import com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionProcessorClientBuilder;
1012
import com.azure.messaging.servicebus.implementation.models.ServiceBusProcessorClientOptions;
1113
import org.reactivestreams.Subscriber;
1214
import org.reactivestreams.Subscription;
@@ -36,19 +38,19 @@
3638
import static com.azure.messaging.servicebus.implementation.ServiceBusConstants.AZ_TRACING_SERVICE_NAME;
3739

3840
/**
39-
* The processor client for processing Service Bus messages. {@link ServiceBusProcessorClient
40-
* ServiceBusProcessorClients} provides a push-based mechanism that invokes the message processing callback when a
41-
* message is received or the error handler when an error occurs when receiving messages. A
42-
* {@link ServiceBusProcessorClient} can be created to process messages for a session-enabled Service Bus entity or
43-
* a non session-enabled Service Bus entity.
41+
* The processor client for processing Service Bus messages. {@link ServiceBusProcessorClient} provides a push-based
42+
* mechanism that invokes the message processing callback when a message is received or the error handler when an error
43+
* occurs when receiving messages. A {@link ServiceBusProcessorClient} can be created to process messages for a
44+
* session-enabled or non session-enabled Service Bus entity. It supports auto-settlement of messages by default.
4445
*
4546
* <p><strong>Create and run a processor</strong></p>
4647
* {@codesnippet com.azure.messaging.servicebus.servicebusprocessorclient#instantiation}
4748
*
4849
* <p><strong>Create and run a session-enabled processor</strong></p>
4950
* {@codesnippet com.azure.messaging.servicebus.servicebusprocessorclient#session-instantiation}
5051
*
51-
* @see ServiceBusClientBuilder
52+
* @see ServiceBusProcessorClientBuilder
53+
* @see ServiceBusSessionProcessorClientBuilder
5254
*/
5355
public final class ServiceBusProcessorClient implements AutoCloseable {
5456

@@ -109,11 +111,15 @@ public final class ServiceBusProcessorClient implements AutoCloseable {
109111

110112
/**
111113
* Starts the processor in the background. When this method is called, the processor will initiate a message
112-
* receiver that will invoke the message handler when new messages are available. This method is idempotent i.e
113-
* calling {@link #start()} again after the processor is already running is a no-op. Calling {@link #start()}
114-
* after calling {@link #stop()} will resume processing messages using the same underlying links or active
115-
* sessions. Calling {@link #start()} after calling {@link #close()} will start the processor with new links and
116-
* a new set of sessions will be processed.
114+
* receiver that will invoke the message handler when new messages are available. This method is idempotent (ie.
115+
* calling {@code start()} again after the processor is already running is a no-op).
116+
* <p>
117+
* Calling {@code start()} after calling {@link #stop() stop()} will resume processing messages using the same
118+
* underlying connection.
119+
* </p>
120+
* <p>
121+
* Calling {@code start()} after calling {@link #close() close()} will start the processor with a new connection.
122+
* </p>
117123
*/
118124
public synchronized void start() {
119125
if (isRunning.getAndSet(true)) {
@@ -174,7 +180,7 @@ public synchronized void close() {
174180
* Returns {@code true} if the processor is running. If the processor is stopped or closed, this method returns
175181
* {@code false}.
176182
*
177-
* @return {@code true} if the processor is running.
183+
* @return {@code true} if the processor is running; {@code false} otherwise.
178184
*/
179185
public synchronized boolean isRunning() {
180186
return isRunning.get();
@@ -208,7 +214,7 @@ public void onNext(ServiceBusMessageContext serviceBusMessageContext) {
208214

209215
processSpanContext =
210216
startProcessTracingSpan(serviceBusMessageContext.getMessage(),
211-
receiverClient.getEntityPath(), receiverClient.getFullyQualifiedNamespace());
217+
receiverClient.getEntityPath(), receiverClient.getFullyQualifiedNamespace());
212218
if (processSpanContext.getData(SPAN_CONTEXT_KEY).isPresent()) {
213219
serviceBusMessageContext.getMessage().addContext(SPAN_CONTEXT_KEY, processSpanContext);
214220
}
@@ -275,7 +281,7 @@ private void endProcessTracingSpan(Context processSpanContext, Signal<Void> sign
275281
}
276282

277283
private Context startProcessTracingSpan(ServiceBusReceivedMessage receivedMessage, String entityPath,
278-
String fullyQualifiedNamespace) {
284+
String fullyQualifiedNamespace) {
279285

280286
Object diagnosticId = receivedMessage.getApplicationProperties().get(DIAGNOSTIC_ID_KEY);
281287
if (diagnosticId == null || !tracerProvider.isEnabled()) {
@@ -297,7 +303,7 @@ private Context startProcessTracingSpan(ServiceBusReceivedMessage receivedMessag
297303
}
298304

299305
private void abandonMessage(ServiceBusMessageContext serviceBusMessageContext,
300-
ServiceBusReceiverAsyncClient receiverClient) {
306+
ServiceBusReceiverAsyncClient receiverClient) {
301307
try {
302308
receiverClient.abandon(serviceBusMessageContext.getMessage()).block();
303309
} catch (Exception exception) {

0 commit comments

Comments
 (0)