{"record":{"id":"52cfc0efe0daee93","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-async-send-message","errorCode":null,"errorMessage":"Failed to async send message","messagePattern":"Failed to async send message","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/mq/MqProducerManager.java","lineNumber":119,"sourceCode":"\t\t\tfor (MqMessage message : messages) {\n\t\t\t\tCompletableFuture<SendReceipt> future = producer.sendAsync(buildMessage(message));\n\t\t\t\tfutures.add(future);\n\t\t\t}\n\n\t\t\tfor (CompletableFuture<SendReceipt> future : futures) {\n\t\t\t\ttry {\n\t\t\t\t\tSendReceipt sendReceipt = future.get(mqConfigProperties.getSendMessageTimeoutMs(),\n\t\t\t\t\t\t\tTimeUnit.MILLISECONDS);\n\t\t\t\t\tcallback.onSuccess(SendResult.builder().messageId(sendReceipt.getMessageId().toString()).build());\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tcallback.onError(e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tlog.error(\"Failed to async send message\", e);\n\t\t\tthrow new RuntimeException(\"Failed to async send message\", e);\n\t\t}\n\t}\n\n\t/**\n\t * Sends messages asynchronously with success and error handlers\n\t * @param producer MQ producer instance\n\t * @param messages List of messages to be sent\n\t * @param onSuccess Success handler\n\t * @param onError Error handler\n\t */\n\tpublic void sendAsync(Producer producer, List<MqMessage> messages, Consumer<SendResult> onSuccess,\n\t\t\tConsumer<Throwable> onError) {\n\t\tsendAsync(producer, messages, new SendCallback() {\n\t\t\t@Override\n\t\t\tpublic void onSuccess(SendResult sendResult) {\n\t\t\t\tif (onSuccess != null) {\n\t\t\t\t\tonSuccess.accept(sendResult);\n\t\t\t\t}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/mq/MqProducerManager.java#L101-L137","documentation":"Outer catch of MqProducerManager.sendAsync: building messages or submitting async sends failed before futures completed (e.g. producer closed, serialization error). The error is logged and rethrown after invoking callback.onError for individual future failures.","triggerScenarios":"Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/mq/MqProducerManager.java:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the Producer lifecycle is started before sendAsync","Inspect the logged cause; per-message failures already invoke callback.onError","Retry failed messages; make callbacks idempotent"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}