You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/aac/java-mwa-guide.md
+44-43Lines changed: 44 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,7 +150,7 @@ This approach ensures that the main application remains responsive and can handl
150
150
151
151
-*Implement message retry and removal.*Implement a mechanism to retry processing of queued messages that can't be processed successfully. If failures persist, these messages should be removed from the queue. For example, Azure Service Bus has built-in retry and dead letter queue features.
152
152
153
-
- *Configure idempotent message processing.* The logic that processes messages from the queue must be idempotent to handle cases where a message might be processed more than once. In Spring Boot, you can use `@StreamListener` or `@KafkaListener` with a unique message identifier to prevent duplicate processing. Or you can organize the business process o operate in a functional approach with Spring Cloud Stream, where the `consume` method is defined in a way that produces the same result when it is executed repeatedly.
153
+
- *Configure idempotent message processing.* The logic that processes messages from the queue must be idempotent to handle cases where a message might be processed more than once. In Spring Boot, you can use `@StreamListener` or `@KafkaListener` with a unique message identifier to prevent duplicate processing. Or you can organize the business process o operate in a functional approach with Spring Cloud Stream, where the `consume` method is defined in a way that produces the same result when it is executed repeatedly. Read [Spring Cloud Stream with Azure Service Bus](/azure/developer/java/spring-framework/configure-spring-cloud-stream-binder-java-app-with-service-bus?tabs=use-a-service-bus-queue) for further list of settings that manage the behavior of how messages are consumed.
154
154
155
155
- *Manage changes to the experience.* Asynchronous processing can lead to tasks not being immediately completed. Users should be made aware when their task is still being processed to set correct expectations and avoid confusion. Use visual cues or messages to indicate that a task is in progress. Give users the option to receive notifications when their task is done, such as an email or push notification.
156
156
@@ -190,7 +190,7 @@ To implement the Competing Consumers pattern, follow these recommendations:
190
190
191
191
For example, the reference implementation uses the CompetingConsumers pattern on a stateless service running in AzureContainerApp to process the email delivery requests from an AzureServiceBus queue.
192
192
193
-
The processor logs message processing details, aiding in troubleshooting and monitoring. It captures deserialization errors and provides insights needed when debugging the process. The service scales at the container level, allowing for efficient handling of message spikes based on queue length.
193
+
The processor logs message processing details, aiding in troubleshooting and monitoring. It captures deserialization errors and provides insights needed when debugging the process. The service scales at the container level, allowing for efficient handling of message spikes based on queue length (*see following code*).
194
194
195
195
```java
196
196
@Configuration
@@ -234,49 +234,50 @@ public class EmailProcessor {
234
234
:::column-end:::
235
235
:::row-end:::
236
236
237
-
Implement the [Health Endpoint Monitoring pattern](/azure/architecture/patterns/health-endpoint-monitoring) in the main app code and decoupled service code to track the health of application endpoints. Orchestrators like Azure Kubernetes Service or Azure Container Apps can poll these endpoints to verify service health and restart unhealthy instances. ASP.NET Core apps can add dedicated [health check middleware](/aspnet/core/host-and-deploy/health-checks) to efficiently serve endpoint health data and key dependencies. To implement the Health Endpoint Monitoring pattern, follow these recommendations:
238
-
239
-
-*Implement health checks.* Use [ASP.NET Core health checks middleware](/aspnet/core/host-and-deploy/health-checks) to provide health check endpoints.
240
-
241
-
-*Validate dependencies.* Ensure that your health checks validate the availability of key dependencies, such as the database, storage, and messaging system. The non-Microsoft package, [AspNetCore.Diagnostics.HealthChecks](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks), can implement health check dependency checks for many common app dependencies.
242
-
243
-
For example, the reference implementation uses ASP.NET Core health check middleware to expose health check endpoints, using the `AddHealthChecks()` method on the `builder.Services` object. The code validates the availability of key dependencies, Azure Blob Storage, and Azure Service Bus Queue with the `AddAzureBlobStorage()` and `AddAzureServiceBusQueue()` methods, which are part of the `AspNetCore.Diagnostics.HealthChecks` package. Azure Container Apps allows configuration of [health probes](/azure/container-apps/health-probes) that are monitored to gauge whether apps are healthy or in need of recycling.
244
-
245
-
```C#
246
-
// Add health checks, including health checks for Azure services that are used by this service.
247
-
// The Blob Storage and Service Bus health checks are provided by AspNetCore.Diagnostics.HealthChecks
248
-
// (a popular open source project) rather than by Microsoft. https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks
249
-
builder.Services.AddHealthChecks()
250
-
.AddAzureBlobStorage(options=>
251
-
{
252
-
// AddAzureBlobStorage will use the BlobServiceClient registered in DI
-*ConfigureAzureresources.*ConfiguretheAzureresourcetousetheapp's health check URLs to confirm liveness and readiness. For example, the reference implementation uses Bicep to configure the health check URLs to confirm the liveness and readiness of the Azure resource. A liveness probe to hit the `/health` endpoint every 10 seconds after an initial delay of 2 seconds.
237
+
Implement the [Health Endpoint Monitoring pattern](/azure/architecture/patterns/health-endpoint-monitoring) in the main app code and decoupled service code to track the health of application endpoints. Orchestrators like Azure Kubernetes Service or Azure Container Apps can poll these endpoints to verify service health and restart unhealthy instances. Spring Boot provides built-in support for health checks with Spring Boot Actuator, which can expose health check endpoints for key dependencies like databases, message brokers, and storage systems. To implement the Health Endpoint Monitoring pattern, follow these recommendations:
238
+
239
+
-*Implement Health Checks.* Use Spring Boot Actuator to provide health check endpoints. Spring Boot Actuator exposes an endpoint `/actuator/health` that includes built-in health indicators and custom checks for various dependencies.
240
+
- To enable the health endpoint, add the `spring-boot-starter-actuator` dependency in your `pom.xml` or `build.gradle` file.
- *Validate dependencies.* Spring Boot Actuator includes health indicators for various dependencies like databases, message brokers (e.g., RabbitMQ or Kafka), and storage services.
255
+
256
+
- To validate the availability of Azure services such as Azure Blob Storage or Azure Service Bus, use community plugins like **Spring Cloud Azure** or **Micrometer** integrations, which provide health indicators for these services.
257
+
- If custom checks are needed, you can implement them by creating a custom `HealthIndicator` bean.
// Implement health check logic (pinging or connecting to the service)
275
+
return true; // Placeholder, implement actual logic
276
+
}
274
277
}
275
-
initialDelaySeconds: 2
276
-
periodSeconds: 10
277
-
}
278
-
]
279
-
```
278
+
```
279
+
280
+
- *Configure Azure resources.* Configure the Azure resource to use the app's health check URLs to confirm liveness and readiness. For example you can use Terraform to use the health check URLs to confirm the liveness and readiness of apps deployed to Azure Container Apps. Read [Health probes in Azure Container Apps](azure/container-apps/health-probes) to learn more.
0 commit comments