Dhairya-007 opened a new pull request, #30048:
URL: https://github.com/apache/camel/pull/30048
## Problem
`MNSUtils` lets an exchange override both the operation and the topic,
checking an exchange property first and then a message header:
```java
public static String resolveOperation(MNSEndpoint endpoint, Exchange
exchange) {
String operation = exchange.getProperty(MNSProperties.OPERATION,
String.class);
if (ObjectHelper.isEmpty(operation)) {
operation = exchange.getIn().getHeader(MNSProperties.OPERATION,
String.class);
}
if (ObjectHelper.isEmpty(operation)) {
operation = endpoint.resolveOperation();
}
```
`resolveTopicName` does the same with `MNSProperties.TOPIC_NAME`.
Both names are only declared in `MNSProperties`:
```java
public static final String OPERATION = "CamelAlibabaMnsOperation";
public static final String QUEUE_NAME = "CamelAlibabaMnsQueueName";
public static final String TOPIC_NAME = "CamelAlibabaMnsTopicName";
public static final String REQUEST_ID = "CamelAlibabaMnsRequestId";
```
That class carries no `@Metadata` and is not what the endpoint names as its
headers class:
```java
headersClass = MNSHeaders.class)
```
So `CamelAlibabaMnsOperation` and `CamelAlibabaMnsTopicName` are missing
from `alibaba-mns.json`, from the catalog and from the component's header
table, although they play exactly the role the ten documented `MNSHeaders`
entries do - and `operation` is the option that decides what the producer does
at all.
## Fix
Declare the two as documented header constants in `MNSHeaders`, note in the
description that the exchange property of the same name wins, and have
`MNSProperties` reuse those values so each string stays defined once:
```java
/** Also read as a message header; see {@link MNSHeaders#OPERATION}. */
public static final String OPERATION = MNSHeaders.OPERATION;
```
`MNSUtils` now reads the header through `MNSHeaders` and the property
through `MNSProperties`, which is what each lookup means. The strings are
unchanged, so no route behaves differently.
The regenerated `alibaba-mns.json` files are included. They also pick up
four `consumer`-labelled headers that were annotated but absent from the
committed file, because the generated file had not been regenerated since they
were added.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]