This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e11db62d315 CAMEL-27350: camel-alibaba-mns - do not require the 
AccessKey pair when mnsClient is set (#30604)
7e11db62d315 is described below

commit 7e11db62d31505fd6d87dee7ce1655513e2e5767
Author: Saravanakumar Selvaraj <[email protected]>
AuthorDate: Sun Nov 22 18:25:51 2026 +0000

    CAMEL-27350: camel-alibaba-mns - do not require the AccessKey pair when 
mnsClient is set (#30604)
    
    The producer resolved the AccessKey pair for each exchange, in 
MNSUtils.createClientConfigurations, and failed without
    it. With mnsClient set or autowired it does not need the pair, as it sends 
its requests with that client.
    ClientConfigurations now has only the operation, the queue name and the 
topic name, which the producer reads.
    MNSUtils.createClient still resolves the pair when the endpoint creates the 
client.
    
    The text of mnsClient now names accessKey, secretKey and serviceKeys too. 
The upgrade guide has a section on the
    record. A new test sends, publishes and deletes a message with a set client 
and without the pair.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../camel/catalog/components/alibaba-mns.json      |  2 +-
 .../camel/component/alibaba/mns/alibaba-mns.json   |  2 +-
 .../camel/component/alibaba/mns/MNSEndpoint.java   |  6 +-
 .../camel/component/alibaba/mns/MNSUtils.java      |  4 -
 .../alibaba/mns/models/ClientConfigurations.java   |  4 -
 .../alibaba/mns/MNSProducerWithoutKeysTest.java    | 94 ++++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  6 ++
 .../endpoint/dsl/MNSEndpointBuilderFactory.java    | 36 ++++-----
 8 files changed, 123 insertions(+), 31 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-mns.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-mns.json
index b0023a194ecb..58fbbc169c52 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-mns.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-mns.json
@@ -64,7 +64,7 @@
     "exchangePattern": { "index": 11, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "enum", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
     "pollStrategy": { "index": 12, "kind": "parameter", "displayName": "Poll 
Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, 
"autowired": false, "secret": false, "description": "A pluggable 
org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your 
custom implementation to control error handling usually occurred during the po 
[...]
     "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produ [...]
-    "mnsClient": { "index": 14, "kind": "parameter", "displayName": "MNS 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "com.aliyun.mns.client.MNSClient", "deprecated": false, 
"autowired": true, "secret": false, "description": "To use a custom 
com.aliyun.mns.client.MNSClient. When this option is set or autowired, the 
region and accountEndpoint options are not used. The Camel endpoint does not 
close a client that is set or autowired." },
+    "mnsClient": { "index": 14, "kind": "parameter", "displayName": "MNS 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "com.aliyun.mns.client.MNSClient", "deprecated": false, 
"autowired": true, "secret": false, "description": "To use a custom 
com.aliyun.mns.client.MNSClient. When this option is set or autowired, the 
region, accountEndpoint, accessKey, secretKey, and serviceKeys options are not 
used. The Camel endpoint does not close a [...]
     "backoffErrorThreshold": { "index": 15, "kind": "parameter", 
"displayName": "Backoff Error Threshold", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
number of subsequent error polls (failed due some error) that should happen 
before the backoffMultipler should kick-in." },
     "backoffIdleThreshold": { "index": 16, "kind": "parameter", "displayName": 
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "The number of subsequent 
idle polls that should happen before the backoffMultipler should kick-in." },
     "backoffMultiplier": { "index": 17, "kind": "parameter", "displayName": 
"Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "To let the scheduled 
polling consumer backoff if there has been a number of subsequent idles\/errors 
in a row. The multiplier is then the number of polls that will be skipped 
before the next actual attempt is h [...]
diff --git 
a/components/camel-alibaba/camel-alibaba-mns/src/generated/resources/META-INF/org/apache/camel/component/alibaba/mns/alibaba-mns.json
 
b/components/camel-alibaba/camel-alibaba-mns/src/generated/resources/META-INF/org/apache/camel/component/alibaba/mns/alibaba-mns.json
index b0023a194ecb..58fbbc169c52 100644
--- 
a/components/camel-alibaba/camel-alibaba-mns/src/generated/resources/META-INF/org/apache/camel/component/alibaba/mns/alibaba-mns.json
+++ 
b/components/camel-alibaba/camel-alibaba-mns/src/generated/resources/META-INF/org/apache/camel/component/alibaba/mns/alibaba-mns.json
@@ -64,7 +64,7 @@
     "exchangePattern": { "index": 11, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "enum", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
     "pollStrategy": { "index": 12, "kind": "parameter", "displayName": "Poll 
Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, 
"autowired": false, "secret": false, "description": "A pluggable 
org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your 
custom implementation to control error handling usually occurred during the po 
[...]
     "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produ [...]
-    "mnsClient": { "index": 14, "kind": "parameter", "displayName": "MNS 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "com.aliyun.mns.client.MNSClient", "deprecated": false, 
"autowired": true, "secret": false, "description": "To use a custom 
com.aliyun.mns.client.MNSClient. When this option is set or autowired, the 
region and accountEndpoint options are not used. The Camel endpoint does not 
close a client that is set or autowired." },
+    "mnsClient": { "index": 14, "kind": "parameter", "displayName": "MNS 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "com.aliyun.mns.client.MNSClient", "deprecated": false, 
"autowired": true, "secret": false, "description": "To use a custom 
com.aliyun.mns.client.MNSClient. When this option is set or autowired, the 
region, accountEndpoint, accessKey, secretKey, and serviceKeys options are not 
used. The Camel endpoint does not close a [...]
     "backoffErrorThreshold": { "index": 15, "kind": "parameter", 
"displayName": "Backoff Error Threshold", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
number of subsequent error polls (failed due some error) that should happen 
before the backoffMultipler should kick-in." },
     "backoffIdleThreshold": { "index": 16, "kind": "parameter", "displayName": 
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "The number of subsequent 
idle polls that should happen before the backoffMultipler should kick-in." },
     "backoffMultiplier": { "index": 17, "kind": "parameter", "displayName": 
"Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "To let the scheduled 
polling consumer backoff if there has been a number of subsequent idles\/errors 
in a row. The multiplier is then the number of polls that will be skipped 
before the next actual attempt is h [...]
diff --git 
a/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSEndpoint.java
 
b/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSEndpoint.java
index 6b886191cb0a..de10d8e1ee8e 100644
--- 
a/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSEndpoint.java
+++ 
b/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSEndpoint.java
@@ -123,9 +123,9 @@ public class MNSEndpoint extends ScheduledPollEndpoint {
               defaultValue = "1", label = "consumer")
     private int maxMessagesPerPoll = 1;
 
-    @UriParam(description = "To use a custom com.aliyun.mns.client.MNSClient. 
When this option is set or autowired, the region"
-                            + " and accountEndpoint options are not used. The 
Camel endpoint does not close a client that is"
-                            + " set or autowired.",
+    @UriParam(description = "To use a custom com.aliyun.mns.client.MNSClient. 
When this option is set or autowired, the region,"
+                            + " accountEndpoint, accessKey, secretKey, and 
serviceKeys options are not used. The Camel endpoint"
+                            + " does not close a client that is set or 
autowired.",
               displayName = "MNS Client", label = "advanced")
     @Metadata(autowired = true)
     private volatile MNSClient mnsClient;
diff --git 
a/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSUtils.java
 
b/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSUtils.java
index 8174f9d16a48..30217de9409e 100644
--- 
a/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSUtils.java
+++ 
b/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/MNSUtils.java
@@ -72,10 +72,6 @@ public final class MNSUtils {
     public static ClientConfigurations createClientConfigurations(MNSEndpoint 
endpoint, Exchange exchange) {
         return new ClientConfigurations(
                 resolveOperation(endpoint, exchange),
-                resolveAccessKey(endpoint),
-                resolveSecretKey(endpoint),
-                endpoint.getRegion(),
-                endpoint.getAccountEndpoint(),
                 resolveQueueName(endpoint, exchange),
                 resolveTopicName(endpoint, exchange));
     }
diff --git 
a/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/models/ClientConfigurations.java
 
b/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/models/ClientConfigurations.java
index 0d8566469023..4c1eba677339 100644
--- 
a/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/models/ClientConfigurations.java
+++ 
b/components/camel-alibaba/camel-alibaba-mns/src/main/java/org/apache/camel/component/alibaba/mns/models/ClientConfigurations.java
@@ -18,10 +18,6 @@ package org.apache.camel.component.alibaba.mns.models;
 
 public record ClientConfigurations(
         String operation,
-        String accessKey,
-        String secretKey,
-        String region,
-        String accountEndpoint,
         String queueName,
         String topicName) {
 }
diff --git 
a/components/camel-alibaba/camel-alibaba-mns/src/test/java/org/apache/camel/component/alibaba/mns/MNSProducerWithoutKeysTest.java
 
b/components/camel-alibaba/camel-alibaba-mns/src/test/java/org/apache/camel/component/alibaba/mns/MNSProducerWithoutKeysTest.java
new file mode 100644
index 000000000000..47f91adca6b5
--- /dev/null
+++ 
b/components/camel-alibaba/camel-alibaba-mns/src/test/java/org/apache/camel/component/alibaba/mns/MNSProducerWithoutKeysTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.alibaba.mns;
+
+import com.aliyun.mns.client.CloudQueue;
+import com.aliyun.mns.client.CloudTopic;
+import com.aliyun.mns.client.MNSClient;
+import com.aliyun.mns.model.Message;
+import com.aliyun.mns.model.TopicMessage;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.alibaba.mns.constants.MNSHeaders;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class MNSProducerWithoutKeysTest extends CamelTestSupport {
+
+    private final TestConfiguration testConfiguration = new 
TestConfiguration();
+
+    @BindToRegistry("mnsClient")
+    MNSClient mnsClient = mock(MNSClient.class);
+
+    CloudQueue cloudQueue = mock(CloudQueue.class);
+
+    CloudTopic cloudTopic = mock(CloudTopic.class);
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:send")
+                        .to("alibaba-mns:" + 
testConfiguration.getProperty("queue") + "?mnsClient=#mnsClient");
+                from("direct:publish")
+                        .to("alibaba-mns:topic:" + 
testConfiguration.getProperty("topic") + "?mnsClient=#mnsClient");
+                from("direct:delete")
+                        .to("alibaba-mns:" + 
testConfiguration.getProperty("queue")
+                            + "?operation=deleteMessage&mnsClient=#mnsClient");
+            }
+        };
+    }
+
+    @Test
+    void testSendMessage() {
+        
when(mnsClient.getQueueRef(testConfiguration.getProperty("queue"))).thenReturn(cloudQueue);
+
+        Exchange exchange = template.send("direct:send", e -> 
e.getMessage().setBody("hello mns"));
+
+        assertThat(exchange.getException()).isNull();
+        verify(cloudQueue).putMessage(any(Message.class));
+    }
+
+    @Test
+    void testPublishMessage() {
+        
when(mnsClient.getTopicRef(testConfiguration.getProperty("topic"))).thenReturn(cloudTopic);
+
+        Exchange exchange = template.send("direct:publish", e -> 
e.getMessage().setBody("hello topic"));
+
+        assertThat(exchange.getException()).isNull();
+        verify(cloudTopic).publishMessage(any(TopicMessage.class));
+    }
+
+    @Test
+    void testDeleteMessage() throws Exception {
+        
when(mnsClient.getQueueRef(testConfiguration.getProperty("queue"))).thenReturn(cloudQueue);
+
+        Exchange exchange = template.send("direct:delete",
+                e -> e.getMessage().setHeader(MNSHeaders.RECEIPT_HANDLE, 
"receipt-handle-123"));
+
+        assertThat(exchange.getException()).isNull();
+        verify(cloudQueue).deleteMessage("receipt-handle-123");
+    }
+}
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 13affde0c13c..5ead09afc66d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -7229,6 +7229,12 @@ The public method `MNSEndpoint.initClient()` now returns 
the `MNSClient` that th
 requests with, instead of `void`. A call that ignores the result compiles as 
before, but code compiled against an
 earlier version must be recompiled, and a subclass that overrides 
`initClient()` must return the client.
 
+=== camel-alibaba-mns - ClientConfigurations has only the operation, the queue 
name and the topic name
+
+`ClientConfigurations` of `camel-alibaba-mns` no longer has the record 
components `accessKey`, `secretKey`, `region` and
+`accountEndpoint`, which no code read. Code that creates the record, or calls 
one of these four accessors, needs a
+change. The producer no longer needs an AccessKey pair when the `mnsClient` 
option is set or autowired.
+
 === camel-minio - a listed object that cannot be got is skipped
 
 When the consumer lists the bucket, a failure to stat or get one of the listed 
objects (for example access denied, or
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MNSEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MNSEndpointBuilderFactory.java
index c13c5fa929af..e3f7b2af033c 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MNSEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MNSEndpointBuilderFactory.java
@@ -973,9 +973,9 @@ public interface MNSEndpointBuilderFactory {
         }
         /**
          * To use a custom com.aliyun.mns.client.MNSClient. When this option is
-         * set or autowired, the region and accountEndpoint options are not
-         * used. The Camel endpoint does not close a client that is set or
-         * autowired.
+         * set or autowired, the region, accountEndpoint, accessKey, secretKey,
+         * and serviceKeys options are not used. The Camel endpoint does not
+         * close a client that is set or autowired.
          * 
          * The option is a: <code>com.aliyun.mns.client.MNSClient</code> type.
          * 
@@ -990,9 +990,9 @@ public interface MNSEndpointBuilderFactory {
         }
         /**
          * To use a custom com.aliyun.mns.client.MNSClient. When this option is
-         * set or autowired, the region and accountEndpoint options are not
-         * used. The Camel endpoint does not close a client that is set or
-         * autowired.
+         * set or autowired, the region, accountEndpoint, accessKey, secretKey,
+         * and serviceKeys options are not used. The Camel endpoint does not
+         * close a client that is set or autowired.
          * 
          * The option will be converted to a
          * <code>com.aliyun.mns.client.MNSClient</code> type.
@@ -1242,9 +1242,9 @@ public interface MNSEndpointBuilderFactory {
         }
         /**
          * To use a custom com.aliyun.mns.client.MNSClient. When this option is
-         * set or autowired, the region and accountEndpoint options are not
-         * used. The Camel endpoint does not close a client that is set or
-         * autowired.
+         * set or autowired, the region, accountEndpoint, accessKey, secretKey,
+         * and serviceKeys options are not used. The Camel endpoint does not
+         * close a client that is set or autowired.
          * 
          * The option is a: <code>com.aliyun.mns.client.MNSClient</code> type.
          * 
@@ -1259,9 +1259,9 @@ public interface MNSEndpointBuilderFactory {
         }
         /**
          * To use a custom com.aliyun.mns.client.MNSClient. When this option is
-         * set or autowired, the region and accountEndpoint options are not
-         * used. The Camel endpoint does not close a client that is set or
-         * autowired.
+         * set or autowired, the region, accountEndpoint, accessKey, secretKey,
+         * and serviceKeys options are not used. The Camel endpoint does not
+         * close a client that is set or autowired.
          * 
          * The option will be converted to a
          * <code>com.aliyun.mns.client.MNSClient</code> type.
@@ -1469,9 +1469,9 @@ public interface MNSEndpointBuilderFactory {
 
         /**
          * To use a custom com.aliyun.mns.client.MNSClient. When this option is
-         * set or autowired, the region and accountEndpoint options are not
-         * used. The Camel endpoint does not close a client that is set or
-         * autowired.
+         * set or autowired, the region, accountEndpoint, accessKey, secretKey,
+         * and serviceKeys options are not used. The Camel endpoint does not
+         * close a client that is set or autowired.
          * 
          * The option is a: <code>com.aliyun.mns.client.MNSClient</code> type.
          * 
@@ -1486,9 +1486,9 @@ public interface MNSEndpointBuilderFactory {
         }
         /**
          * To use a custom com.aliyun.mns.client.MNSClient. When this option is
-         * set or autowired, the region and accountEndpoint options are not
-         * used. The Camel endpoint does not close a client that is set or
-         * autowired.
+         * set or autowired, the region, accountEndpoint, accessKey, secretKey,
+         * and serviceKeys options are not used. The Camel endpoint does not
+         * close a client that is set or autowired.
          * 
          * The option will be converted to a
          * <code>com.aliyun.mns.client.MNSClient</code> type.

Reply via email to