alibaba/spring-ai-alibaba · error · RuntimeException

Failed to async send message

Error message

Failed to async send message

What it means

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.

Solutions

  1. Ensure the Producer lifecycle is started before sendAsync
  2. Inspect the logged cause; per-message failures already invoke callback.onError
  3. Retry failed messages; make callbacks idempotent
Defensive patterns

Strategy: retry

When it happens

Trigger: 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.

Common situations: See trigger scenarios.


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/52cfc0efe0daee93. Report an issue: GitHub.

Appendix: source

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

			for (MqMessage message : messages) {
				CompletableFuture<SendReceipt> future = producer.sendAsync(buildMessage(message));
				futures.add(future);
			}

			for (CompletableFuture<SendReceipt> future : futures) {
				try {
					SendReceipt sendReceipt = future.get(mqConfigProperties.getSendMessageTimeoutMs(),
							TimeUnit.MILLISECONDS);
					callback.onSuccess(SendResult.builder().messageId(sendReceipt.getMessageId().toString()).build());
				}
				catch (Exception e) {
					callback.onError(e);
				}
			}
		}
		catch (Exception e) {
			log.error("Failed to async send message", e);
			throw new RuntimeException("Failed to async send message", e);
		}
	}

	/**
	 * Sends messages asynchronously with success and error handlers
	 * @param producer MQ producer instance
	 * @param messages List of messages to be sent
	 * @param onSuccess Success handler
	 * @param onError Error handler
	 */
	public void sendAsync(Producer producer, List<MqMessage> messages, Consumer<SendResult> onSuccess,
			Consumer<Throwable> onError) {
		sendAsync(producer, messages, new SendCallback() {
			@Override
			public void onSuccess(SendResult sendResult) {
				if (onSuccess != null) {
					onSuccess.accept(sendResult);
				}

View on GitHub (pinned to f82da0b50f)