diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index 36c1049af441..a1e68bd07238 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -13,6 +13,7 @@ import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.BinaryData; import com.azure.core.util.FluxUtil; import com.azure.messaging.eventgrid.namespaces.implementation.EventGridReceiverClientImpl; @@ -71,7 +72,7 @@ public final class EventGridReceiverAsyncClient { * * You can add these to a request with {@link RequestOptions#addQueryParam} *
Response Body Schema
- * + * *{@code
* {
* value (Required): [
@@ -119,7 +120,7 @@ Mono> receiveWithResponse(String topicName, String eventSub
* along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
* will no longer be available to be received by any consumer.
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -127,9 +128,9 @@ Mono> receiveWithResponse(String topicName, String eventSub
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -187,7 +188,7 @@ Mono> acknowledgeWithResponse(String topicName, String even
*
* You can add these to a request with {@link RequestOptions#addQueryParam}
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -195,9 +196,9 @@ Mono> acknowledgeWithResponse(String topicName, String even
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -246,7 +247,7 @@ Mono> releaseWithResponse(String topicName, String eventSub
* with other failed lock tokens with their corresponding error information. Successfully rejected events will be
* dead-lettered and can no longer be received by a consumer.
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -254,9 +255,9 @@ Mono> releaseWithResponse(String topicName, String eventSub
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -305,7 +306,7 @@ Mono> rejectWithResponse(String topicName, String eventSubs
* along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
* ensure that the associated event is only available to the consumer that holds the renewed lock.
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -313,9 +314,9 @@ Mono> rejectWithResponse(String topicName, String eventSubs
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -368,7 +369,7 @@ Mono> renewLocksWithResponse(String topicName, String event
* @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
* server approximately waits for the availability of an event and responds to the request. If an event is
* available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
- * seconds. If not specified, the default value is 60 seconds.
+ * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
@@ -385,12 +386,49 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) {
requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
}
if (maxWaitTime != null) {
- requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
+ return receiveWithResponse(maxEvents, maxWaitTime, new RequestOptions()).map(Response::getValue);
}
return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ReceiveResult.class));
}
+ /**
+ * Receive a batch of Cloud Events from a subscription.
+ *
+ * @param maxEvents Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not
+ * specified, the default value is 1.
+ * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
+ * server approximately waits for the availability of an event and responds to the request. If an event is
+ * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
+ * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return details of the Receive operation response on successful completion of {@link Mono} along with
+ * {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> receiveWithResponse(Integer maxEvents, Duration maxWaitTime,
+ RequestOptions requestOptions) {
+ if (maxEvents != null) {
+ requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
+ }
+ if (maxWaitTime != null) {
+ // Ensure the http client timeout is longer than the maxWaitTime
+ EventGridReceiverClient.addTimeoutToContext(requestOptions, maxWaitTime);
+ requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
+ } else {
+ // Extend the timeout with a buffer past the default maxWaitTime.
+ EventGridReceiverClient.addTimeoutToContext(requestOptions, Duration.ofSeconds(65));
+ }
+ return receiveWithResponse(topicName, subscriptionName, requestOptions)
+ .map(response -> new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class)));
+ }
+
/**
* Receive a Cloud Event from a subscription. This method will wait 60 seconds for a response.
*
@@ -404,7 +442,6 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono receive() {
- // Generated convenience method for receiveWithResponse
RequestOptions requestOptions = new RequestOptions();
return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ReceiveResult.class));
@@ -426,7 +463,6 @@ public Mono receive() {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono acknowledge(List lockTokens) {
- // Generated convenience method for acknowledgeWithResponse
RequestOptions requestOptions = new RequestOptions();
AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -434,6 +470,31 @@ public Mono acknowledge(List lockTokens) {
.map(protocolMethodData -> protocolMethodData.toObject(AcknowledgeResult.class));
}
+ /**
+ * Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens,
+ * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
+ * will no longer be available to be received by any consumer.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Acknowledge operation on successful completion of {@link Mono} along with
+ * {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> acknowledgeWithResponse(List lockTokens,
+ RequestOptions requestOptions) {
+ AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ return acknowledgeWithResponse(topicName, subscriptionName, request, requestOptions)
+ .map(response -> new SimpleResponse<>(response, response.getValue().toObject(AcknowledgeResult.class)));
+ }
+
/**
* Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
* with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -451,7 +512,6 @@ public Mono acknowledge(List lockTokens) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono release(List lockTokens, ReleaseDelay releaseDelay) {
- // Generated convenience method for releaseWithResponse
RequestOptions requestOptions = new RequestOptions();
ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -462,6 +522,34 @@ public Mono release(List lockTokens, ReleaseDelay release
.map(protocolMethodData -> protocolMethodData.toObject(ReleaseResult.class));
}
+ /**
+ * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
+ * with other failed lock tokens with their corresponding error information. Successfully released events can be
+ * received by consumers.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param releaseDelay Release cloud events with the specified delay in seconds.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Release operation on successful completion of {@link Mono} along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> releaseWithResponse(List lockTokens, ReleaseDelay releaseDelay,
+ RequestOptions requestOptions) {
+ ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ if (releaseDelay != null) {
+ requestOptions.addQueryParam("releaseDelayInSeconds", releaseDelay.toString(), false);
+ }
+ return releaseWithResponse(topicName, subscriptionName, request, requestOptions)
+ .map(response -> new SimpleResponse<>(response, response.getValue().toObject(ReleaseResult.class)));
+ }
+
/**
* Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
* with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -478,7 +566,6 @@ public Mono release(List lockTokens, ReleaseDelay release
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono release(List lockTokens) {
- // Generated convenience method for releaseWithResponse
RequestOptions requestOptions = new RequestOptions();
ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -502,7 +589,6 @@ public Mono release(List lockTokens) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono reject(List lockTokens) {
- // Generated convenience method for rejectWithResponse
RequestOptions requestOptions = new RequestOptions();
RejectRequest requestObj = new RejectRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -510,6 +596,29 @@ public Mono reject(List lockTokens) {
.map(protocolMethodData -> protocolMethodData.toObject(RejectResult.class));
}
+ /**
+ * Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along
+ * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
+ * dead-lettered and can no longer be received by a consumer.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Reject operation on successful completion of {@link Mono} along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> rejectWithResponse(List lockTokens, RequestOptions requestOptions) {
+ RejectRequest requestObj = new RejectRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ return rejectWithResponse(topicName, subscriptionName, request, requestOptions)
+ .map(response -> new SimpleResponse<>(response, response.getValue().toObject(RejectResult.class)));
+ }
+
/**
* Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
* along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
@@ -526,7 +635,6 @@ public Mono reject(List lockTokens) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono renewLocks(List lockTokens) {
- // Generated convenience method for renewLocksWithResponse
RequestOptions requestOptions = new RequestOptions();
RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -534,6 +642,32 @@ public Mono renewLocks(List lockTokens) {
.map(protocolMethodData -> protocolMethodData.toObject(RenewLocksResult.class));
}
+ /**
+ * Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
+ * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
+ * ensure that the associated event is only available to the consumer that holds the renewed lock.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the RenewLock operation on successful completion of {@link Mono} along with
+ * {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> renewLocksWithResponse(List lockTokens,
+ RequestOptions requestOptions) {
+ RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ return renewLocksWithResponse(topicName, subscriptionName, request, requestOptions)
+ .map(protocolMethodData -> new SimpleResponse<>(protocolMethodData,
+ protocolMethodData.getValue().toObject(RenewLocksResult.class)));
+ }
+
/**
* Gets the topicName for this client.
*
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
index 8e236a4aae4b..9a0bf9eabfef 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
@@ -13,7 +13,9 @@
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
+import com.azure.core.util.Context;
import com.azure.messaging.eventgrid.namespaces.implementation.EventGridReceiverClientImpl;
import com.azure.messaging.eventgrid.namespaces.implementation.models.AcknowledgeRequest;
import com.azure.messaging.eventgrid.namespaces.implementation.models.RejectRequest;
@@ -69,7 +71,7 @@ public final class EventGridReceiverClient {
*
* You can add these to a request with {@link RequestOptions#addQueryParam}
* Response Body Schema
- *
+ *
* {@code
* {
* value (Required): [
@@ -116,7 +118,7 @@ Response receiveWithResponse(String topicName, String eventSubscript
* along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
* will no longer be available to be received by any consumer.
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -124,9 +126,9 @@ Response receiveWithResponse(String topicName, String eventSubscript
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -183,7 +185,7 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
*
* You can add these to a request with {@link RequestOptions#addQueryParam}
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -191,9 +193,9 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -241,7 +243,7 @@ Response releaseWithResponse(String topicName, String eventSubscript
* with other failed lock tokens with their corresponding error information. Successfully rejected events will be
* dead-lettered and can no longer be received by a consumer.
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -249,9 +251,9 @@ Response releaseWithResponse(String topicName, String eventSubscript
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -299,7 +301,7 @@ Response rejectWithResponse(String topicName, String eventSubscripti
* along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
* ensure that the associated event is only available to the consumer that holds the renewed lock.
* Request Body Schema
- *
+ *
* {@code
* {
* lockTokens (Required): [
@@ -307,9 +309,9 @@ Response rejectWithResponse(String topicName, String eventSubscripti
* ]
* }
* }
- *
+ *
* Response Body Schema
- *
+ *
* {@code
* {
* failedLockTokens (Required): [
@@ -361,7 +363,7 @@ Response renewLocksWithResponse(String topicName, String eventSubscr
* @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
* server approximately waits for the availability of an event and responds to the request. If an event is
* available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
- * seconds. If not specified, the default value is 60 seconds.
+ * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
@@ -372,18 +374,53 @@ Response renewLocksWithResponse(String topicName, String eventSubscr
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) {
- // Generated convenience method for receiveWithResponse
RequestOptions requestOptions = new RequestOptions();
if (maxEvents != null) {
requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
}
if (maxWaitTime != null) {
- requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
+ return receiveWithResponse(maxEvents, maxWaitTime, new RequestOptions()).getValue();
}
return receiveWithResponse(topicName, subscriptionName, requestOptions).getValue()
.toObject(ReceiveResult.class);
}
+ /**
+ * Receive a batch of Cloud Events from a subscription.
+ *
+ * @param maxEvents Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not
+ * specified, the default value is 1.
+ * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
+ * server approximately waits for the availability of an event and responds to the request. If an event is
+ * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
+ * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return details of the Receive operation response along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response receiveWithResponse(Integer maxEvents, Duration maxWaitTime,
+ RequestOptions requestOptions) {
+ if (maxEvents != null) {
+ requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
+ }
+ if (maxWaitTime != null) {
+ // Ensure the http client timeout is longer than the maxWaitTime
+ addTimeoutToContext(requestOptions, maxWaitTime);
+ requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
+ } else {
+ // Extend the timeout with a buffer past the default maxWaitTime.
+ addTimeoutToContext(requestOptions, Duration.ofSeconds(65));
+ }
+ Response response = receiveWithResponse(topicName, subscriptionName, requestOptions);
+ return new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class));
+ }
+
/**
* Receive a Cloud Event from a subscription. This method will wait 60 seconds for a response.
*
@@ -397,7 +434,6 @@ public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ReceiveResult receive() {
- // Generated convenience method for receiveWithResponse
RequestOptions requestOptions = new RequestOptions();
return receiveWithResponse(topicName, subscriptionName, requestOptions).getValue()
.toObject(ReceiveResult.class);
@@ -419,7 +455,6 @@ public ReceiveResult receive() {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public AcknowledgeResult acknowledge(List lockTokens) {
- // Generated convenience method for acknowledgeWithResponse
RequestOptions requestOptions = new RequestOptions();
AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -427,6 +462,29 @@ public AcknowledgeResult acknowledge(List lockTokens) {
.toObject(AcknowledgeResult.class);
}
+ /**
+ * Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens,
+ * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
+ * will no longer be available to be received by any consumer.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Acknowledge operation along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response acknowledgeWithResponse(List lockTokens, RequestOptions requestOptions) {
+ AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ Response response = acknowledgeWithResponse(topicName, subscriptionName, request, requestOptions);
+ return new SimpleResponse<>(response, response.getValue().toObject(AcknowledgeResult.class));
+ }
+
/**
* Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
* with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -444,7 +502,6 @@ public AcknowledgeResult acknowledge(List lockTokens) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ReleaseResult release(List lockTokens, ReleaseDelay releaseDelay) {
- // Generated convenience method for releaseWithResponse
RequestOptions requestOptions = new RequestOptions();
ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -455,6 +512,34 @@ public ReleaseResult release(List lockTokens, ReleaseDelay releaseDelay)
.toObject(ReleaseResult.class);
}
+ /**
+ * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
+ * with other failed lock tokens with their corresponding error information. Successfully released events can be
+ * received by consumers.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param releaseDelay Release cloud events with the specified delay in seconds.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Release operation along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response releaseWithResponse(List lockTokens, ReleaseDelay releaseDelay,
+ RequestOptions requestOptions) {
+ ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ if (releaseDelay != null) {
+ requestOptions.addQueryParam("releaseDelayInSeconds", releaseDelay.toString(), false);
+ }
+ Response response = releaseWithResponse(topicName, subscriptionName, request, requestOptions);
+ return new SimpleResponse<>(response, response.getValue().toObject(ReleaseResult.class));
+ }
+
/**
* Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
* with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -471,7 +556,6 @@ public ReleaseResult release(List lockTokens, ReleaseDelay releaseDelay)
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ReleaseResult release(List lockTokens) {
- // Generated convenience method for releaseWithResponse
RequestOptions requestOptions = new RequestOptions();
ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -495,7 +579,6 @@ public ReleaseResult release(List lockTokens) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public RejectResult reject(List lockTokens) {
- // Generated convenience method for rejectWithResponse
RequestOptions requestOptions = new RequestOptions();
RejectRequest requestObj = new RejectRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -503,6 +586,29 @@ public RejectResult reject(List lockTokens) {
.toObject(RejectResult.class);
}
+ /**
+ * Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along
+ * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
+ * dead-lettered and can no longer be received by a consumer.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Reject operation along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response rejectWithResponse(List lockTokens, RequestOptions requestOptions) {
+ RejectRequest requestObj = new RejectRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ Response response = rejectWithResponse(topicName, subscriptionName, request, requestOptions);
+ return new SimpleResponse<>(response, response.getValue().toObject(RejectResult.class));
+ }
+
/**
* Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
* along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
@@ -519,7 +625,6 @@ public RejectResult reject(List lockTokens) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public RenewLocksResult renewLocks(List lockTokens) {
- // Generated convenience method for renewLocksWithResponse
RequestOptions requestOptions = new RequestOptions();
RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens);
BinaryData request = BinaryData.fromObject(requestObj);
@@ -527,6 +632,29 @@ public RenewLocksResult renewLocks(List lockTokens) {
.toObject(RenewLocksResult.class);
}
+ /**
+ * Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
+ * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
+ * ensure that the associated event is only available to the consumer that holds the renewed lock.
+ *
+ * @param lockTokens Array of lock tokens.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the RenewLock operation along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response renewLocksWithResponse(List lockTokens, RequestOptions requestOptions) {
+ RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens);
+ BinaryData request = BinaryData.fromObject(requestObj);
+ Response response = renewLocksWithResponse(topicName, subscriptionName, request, requestOptions);
+ return new SimpleResponse<>(response, response.getValue().toObject(RenewLocksResult.class));
+ }
+
/**
* Gets the topicName for this client.
*
@@ -544,4 +672,21 @@ public String getTopicName() {
public String getSubscriptionName() {
return subscriptionName;
}
+
+ /**
+ * Adds a timeout (maxWaitTime) to a context.
+ *
+ * @param requestOptions The request options to update.
+ * @param timeout The timeout to add.
+ * @return The updated context.
+ */
+ static void addTimeoutToContext(RequestOptions requestOptions, Duration timeout) {
+ Context context = requestOptions.getContext();
+ if (context == null) {
+ context = new Context("azure-response-timeout", timeout.plusSeconds(5));
+ } else {
+ context = context.addData("azure-response-timeout", timeout.plusSeconds(5));
+ }
+ requestOptions.setContext(context);
+ }
}
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
index 25768f7118be..f67577e06f60 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
@@ -13,6 +13,7 @@
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.messaging.eventgrid.namespaces.implementation.EventGridSenderClientImpl;
import java.util.List;
@@ -138,11 +139,30 @@ Mono> sendEventsWithResponse(String topicName, BinaryData e
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono send(CloudEvent event) {
- // Generated convenience method for sendWithResponse
RequestOptions requestOptions = new RequestOptions();
return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).then();
}
+ /**
+ * Publish a single Cloud Event to a namespace topic.
+ *
+ * @param event Single Cloud Event being published.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Publish operation on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> sendWithResponse(CloudEvent event, RequestOptions requestOptions) {
+ return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).map(response -> {
+ return new SimpleResponse<>(response, null);
+ });
+ }
+
/**
* Publish a batch of Cloud Events to a namespace topic.
*
@@ -157,11 +177,30 @@ public Mono send(CloudEvent event) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono send(List events) {
- // Generated convenience method for sendEventsWithResponse
RequestOptions requestOptions = new RequestOptions();
return sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions).then();
}
+ /**
+ * Publish a batch of Cloud Events to a namespace topic.
+ *
+ * @param events Array of Cloud Events being published.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the result of the Publish operation on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> sendWithResponse(List events, RequestOptions requestOptions) {
+ return sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions).map(response -> {
+ return new SimpleResponse<>(response, null);
+ });
+ }
+
/**
* Gets the topicName for this client.
*
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java
index f1407dadab37..ccdbbf691bf9 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java
@@ -13,6 +13,7 @@
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.messaging.eventgrid.namespaces.implementation.EventGridSenderClientImpl;
import java.util.List;
@@ -135,11 +136,29 @@ Response sendEventsWithResponse(String topicName, BinaryData events,
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void send(CloudEvent event) {
- // Generated convenience method for sendWithResponse
RequestOptions requestOptions = new RequestOptions();
sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions);
}
+ /**
+ * Publish a single Cloud Event to a namespace topic.
+ *
+ * @param event Array of Cloud Events being published.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @return The {@link Response} of the send operation.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response sendWithResponse(CloudEvent event, RequestOptions requestOptions) {
+ Response response = sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions);
+ return new SimpleResponse<>(response, null);
+ }
+
/**
* Publish a batch of Cloud Events to a namespace topic.
*
@@ -153,11 +172,30 @@ public void send(CloudEvent event) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void send(List events) {
- // Generated convenience method for sendEventsWithResponse
RequestOptions requestOptions = new RequestOptions();
sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions);
}
+ /**
+ * Publish a batch of Cloud Events to a namespace topic.
+ *
+ * @param events Array of Cloud Events being published.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @return The {@link Response} of the send operation.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response sendWithResponse(List events, RequestOptions requestOptions) {
+ Response response
+ = sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions);
+ return new SimpleResponse<>(response, null);
+ }
+
/**
* Gets the topicName for this client.
*
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java
index 7ab2569ffb6a..8b701f1dfb35 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java
@@ -16,7 +16,6 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class EventGridAsyncClientTests extends EventGridClientTestBase {
@Override
@@ -43,18 +42,14 @@ void send() {
EventGridSenderAsyncClient client = buildSenderAsyncClient();
- client.send(getCloudEvent())
- .as(StepVerifier::create)
- .verifyComplete();
+ client.send(getCloudEvent()).as(StepVerifier::create).verifyComplete();
}
@Test
void sendBatch() {
EventGridSenderAsyncClient client = buildSenderAsyncClient();
- client.send(Arrays.asList(getCloudEvent(), getCloudEvent()))
- .as(StepVerifier::create)
- .verifyComplete();
+ client.send(Arrays.asList(getCloudEvent(), getCloudEvent())).as(StepVerifier::create).verifyComplete();
}
@Test
@@ -79,37 +74,30 @@ void acknowledgeBatch() {
EventGridReceiverAsyncClient client = buildReceiverAsyncClient();
EventGridSenderAsyncClient senderClient = buildSenderAsyncClient();
- senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10)))
- .flatMap(receiveResult -> {
- return client.acknowledge(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
- })
- .as(StepVerifier::create)
- .assertNext(receiveResult -> {
- assertNotNull(receiveResult);
- assertTrue(receiveResult.getFailedLockTokens().isEmpty());
- assertFalse(receiveResult.getSucceededLockTokens().isEmpty());
- })
- .verifyComplete();
+ senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> {
+ return client
+ .acknowledge(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ }).as(StepVerifier::create).assertNext(receiveResult -> {
+ assertNotNull(receiveResult);
+ assertTrue(receiveResult.getFailedLockTokens().isEmpty());
+ assertFalse(receiveResult.getSucceededLockTokens().isEmpty());
+ }).verifyComplete();
}
-
@Test
void releaseBatch() {
EventGridReceiverAsyncClient client = buildReceiverAsyncClient();
EventGridSenderAsyncClient senderClient = buildSenderAsyncClient();
- senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10)))
- .flatMap(receiveResult -> {
- return client.release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
- })
- .as(StepVerifier::create)
- .assertNext(result -> {
- assertNotNull(result);
- assertTrue(result.getFailedLockTokens().isEmpty());
- assertFalse(result.getSucceededLockTokens().isEmpty());
- })
- .verifyComplete();
+ senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> {
+ return client
+ .release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ }).as(StepVerifier::create).assertNext(result -> {
+ assertNotNull(result);
+ assertTrue(result.getFailedLockTokens().isEmpty());
+ assertFalse(result.getSucceededLockTokens().isEmpty());
+ }).verifyComplete();
}
@Test
@@ -118,18 +106,14 @@ void releaseBatchWithDelay() {
EventGridReceiverAsyncClient client = buildReceiverAsyncClient();
EventGridSenderAsyncClient senderClient = buildSenderAsyncClient();
- senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10)))
- .flatMap(receiveResult -> {
- return client.release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()), ReleaseDelay.TEN_SECONDS);
- })
- .as(StepVerifier::create)
- .assertNext(result -> {
- assertNotNull(result);
- assertTrue(result.getFailedLockTokens().isEmpty());
- assertFalse(result.getSucceededLockTokens().isEmpty());
- })
- .verifyComplete();
-
+ senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> {
+ return client.release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()),
+ ReleaseDelay.TEN_SECONDS);
+ }).as(StepVerifier::create).assertNext(result -> {
+ assertNotNull(result);
+ assertTrue(result.getFailedLockTokens().isEmpty());
+ assertFalse(result.getSucceededLockTokens().isEmpty());
+ }).verifyComplete();
}
@@ -139,17 +123,13 @@ void rejectBatch() {
EventGridReceiverAsyncClient client = buildReceiverAsyncClient();
EventGridSenderAsyncClient senderClient = buildSenderAsyncClient();
- senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10)))
- .flatMap(receiveResult -> {
- return client.reject(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
- })
- .as(StepVerifier::create)
- .assertNext(result -> {
- assertNotNull(result);
- assertTrue(result.getFailedLockTokens().isEmpty());
- assertFalse(result.getSucceededLockTokens().isEmpty());
- })
- .verifyComplete();
+ senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> {
+ return client.reject(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ }).as(StepVerifier::create).assertNext(result -> {
+ assertNotNull(result);
+ assertTrue(result.getFailedLockTokens().isEmpty());
+ assertFalse(result.getSucceededLockTokens().isEmpty());
+ }).verifyComplete();
}
@Test
@@ -158,16 +138,13 @@ void renewBatch() {
EventGridReceiverAsyncClient client = buildReceiverAsyncClient();
EventGridSenderAsyncClient senderClient = buildSenderAsyncClient();
- senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10)))
- .flatMap(receiveResult -> {
- return client.renewLocks(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
- })
- .as(StepVerifier::create)
- .assertNext(result -> {
- assertNotNull(result);
- assertTrue(result.getFailedLockTokens().isEmpty());
- assertFalse(result.getSucceededLockTokens().isEmpty());
- })
- .verifyComplete();
+ senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> {
+ return client
+ .renewLocks(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ }).as(StepVerifier::create).assertNext(result -> {
+ assertNotNull(result);
+ assertTrue(result.getFailedLockTokens().isEmpty());
+ assertFalse(result.getSucceededLockTokens().isEmpty());
+ }).verifyComplete();
}
}
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java
index 93d8d7194f4f..43960812b445 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java
@@ -40,13 +40,14 @@ public class EventGridClientTestBase extends TestProxyTestBase {
static final String DUMMY_CHANNEL_NAME = "dummy-channel";
- public static final String TOPIC_NAME = Configuration.getGlobalConfiguration().get(EVENTGRID_TOPIC_NAME, "testtopic1");
- public static final String EVENT_SUBSCRIPTION_NAME = Configuration.getGlobalConfiguration().get(EVENTGRID_EVENT_SUBSCRIPTION_NAME, "testsubscription1");
+ public static final String TOPIC_NAME
+ = Configuration.getGlobalConfiguration().get(EVENTGRID_TOPIC_NAME, "testtopic1");
+ public static final String EVENT_SUBSCRIPTION_NAME
+ = Configuration.getGlobalConfiguration().get(EVENTGRID_EVENT_SUBSCRIPTION_NAME, "testsubscription1");
EventGridReceiverClientBuilder receiverBuilder;
EventGridSenderClientBuilder senderBuilder;
-
protected void makeBuilders(boolean sync) {
receiverBuilder = buildReceiverClientBuilder();
senderBuilder = buildSenderClientBuilder();
@@ -59,17 +60,12 @@ protected void makeBuilders(boolean sync) {
}
if (interceptorManager.isRecordMode()) {
- receiverBuilder.addPolicy(interceptorManager.getRecordPolicy())
- .retryPolicy(new RetryPolicy());
- senderBuilder.addPolicy(interceptorManager.getRecordPolicy())
- .retryPolicy(new RetryPolicy());
+ receiverBuilder.addPolicy(interceptorManager.getRecordPolicy()).retryPolicy(new RetryPolicy());
+ senderBuilder.addPolicy(interceptorManager.getRecordPolicy()).retryPolicy(new RetryPolicy());
}
setupSanitizers();
}
-
-
-
@Override
protected void afterTest() {
StepVerifier.resetDefaultTimeout();
@@ -86,8 +82,7 @@ void setupSanitizers() {
}
EventGridReceiverClientBuilder buildReceiverClientBuilder() {
- return new EventGridReceiverClientBuilder()
- .httpClient(HttpClient.createDefault())
+ return new EventGridReceiverClientBuilder().httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions())
.subscriptionName(EVENT_SUBSCRIPTION_NAME)
.topicName(TOPIC_NAME)
@@ -95,8 +90,7 @@ EventGridReceiverClientBuilder buildReceiverClientBuilder() {
}
EventGridSenderClientBuilder buildSenderClientBuilder() {
- return new EventGridSenderClientBuilder()
- .httpClient(HttpClient.createDefault())
+ return new EventGridSenderClientBuilder().httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions())
.topicName(TOPIC_NAME)
.endpoint(getTopicEndpoint(EVENTGRID_ENDPOINT));
@@ -134,21 +128,19 @@ CloudEvent getCloudEvent() {
put("Field2", "Value2");
put("Field3", "Value3");
}
- }), CloudEventDataFormat.JSON, "application/json")
- .setSubject("Test")
- .setTime(testResourceNamer.now())
- .setId(testResourceNamer.randomUuid());
+ }), CloudEventDataFormat.JSON, "application/json").setSubject("Test")
+ .setTime(testResourceNamer.now())
+ .setId(testResourceNamer.randomUuid());
}
CloudEvent getCloudEvent(int i) {
return new CloudEvent("/microsoft/testEvent", "Microsoft.MockPublisher.TestEvent",
BinaryData.fromObject(new TestData().setName("Hello " + i)), CloudEventDataFormat.JSON, null)
- .setSubject("Test " + i)
- .setTime(testResourceNamer.now())
- .setId(testResourceNamer.randomUuid());
+ .setSubject("Test " + i)
+ .setTime(testResourceNamer.now())
+ .setId(testResourceNamer.randomUuid());
}
-
String getEndpoint(String liveEnvName) {
if (interceptorManager.isPlaybackMode()) {
return DUMMY_ENDPOINT;
@@ -177,8 +169,8 @@ AzureKeyCredential getKey(String liveEnvName) {
}
HttpClient buildAssertingClient(HttpClient httpClient, boolean sync) {
- AssertingHttpClientBuilder builder = new AssertingHttpClientBuilder(httpClient)
- .skipRequest((ignored1, ignored2) -> false);
+ AssertingHttpClientBuilder builder
+ = new AssertingHttpClientBuilder(httpClient).skipRequest((ignored1, ignored2) -> false);
if (sync) {
builder.assertSync();
} else {
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java
index 3c32d13fb21d..da9a960e03c9 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java
@@ -41,7 +41,6 @@ EventGridSenderClient buildSenderClient() {
return senderBuilder.credential(getKey(EVENTGRID_KEY)).buildClient();
}
-
@Test
void send() {
EventGridSenderClient client = buildSenderClient();
@@ -71,7 +70,8 @@ void acknowledgeBatch() {
senderClient.send(getCloudEvent());
ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10));
- AcknowledgeResult acknowledgeResult = client.acknowledge(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ AcknowledgeResult acknowledgeResult = client.acknowledge(
+ Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
assertNotNull(acknowledgeResult);
assertFalse(acknowledgeResult.getSucceededLockTokens().isEmpty());
}
@@ -83,7 +83,8 @@ void releaseBatch() {
senderClient.send(getCloudEvent());
ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10));
- ReleaseResult releaseResult = client.release(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ ReleaseResult releaseResult = client
+ .release(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
assertNotNull(releaseResult);
assertFalse(releaseResult.getSucceededLockTokens().isEmpty());
}
@@ -94,7 +95,9 @@ void releaseBatchWithDelay() {
EventGridReceiverClient client = buildReceiverClient();
senderClient.send(getCloudEvent());
ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10));
- ReleaseResult releaseResult = client.release(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()), ReleaseDelay.TEN_SECONDS);
+ ReleaseResult releaseResult = client.release(
+ Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()),
+ ReleaseDelay.TEN_SECONDS);
assertNotNull(releaseResult);
assertFalse(releaseResult.getSucceededLockTokens().isEmpty());
}
@@ -105,7 +108,8 @@ void rejectBatch() {
EventGridReceiverClient client = buildReceiverClient();
senderClient.send(getCloudEvent());
ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10));
- RejectResult rejectResult = client.reject(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ RejectResult rejectResult = client
+ .reject(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
assertNotNull(rejectResult);
assertFalse(rejectResult.getSucceededLockTokens().isEmpty());
}
@@ -116,7 +120,8 @@ void renewBatchOfEvents() {
EventGridReceiverClient client = buildReceiverClient();
senderClient.send(getCloudEvent());
ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10));
- RenewLocksResult renewResult = client.renewLocks(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
+ RenewLocksResult renewResult = client.renewLocks(
+ Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()));
assertNotNull(renewResult);
assertFalse(renewResult.getSucceededLockTokens().isEmpty());
}