camel-kafka-connector icon indicating copy to clipboard operation
camel-kafka-connector copied to clipboard

[0.11.5] RabbitMQ Source Connector JSON config ends up converting kebab-case to camelCase

Open dshma opened this issue 1 year ago • 7 comments

Hi,

We've been trying to configure the x-queue-type argument/option in the following manner:

... 
"camel.component.rabbitmq.args[queue.x-queue-type]": "quorum",
...

As a result, we end up with a camel cased argument for the corresponding queue - xQueueType, which makes it a classic queue. It works fine with other special characters (eg. snake_case).

Haven't found anything related or suspicious on the surface (neither in the current repository nor in the kafka connect) for quite some time, thus would appreciate your input.

P.S. I understand that 0.11.5 is no longer supported so I really wouldn't want you spending time troubleshooting this if it appears to be an issue, it's more like whether this is something known and there is something we could do rather than forking and customizing it ourselves.

Thanks!

dshma avatar Dec 03 '23 01:12 dshma

cc: @oscerd

dshma avatar Dec 10 '23 15:12 dshma

Looking at how this is done in the related version https://github.com/apache/camel/blob/camel-3.11.5/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java#L160

I think it's not feasible to use the args parameter, you need to bind a Map to the Camel registry and in that version is probably not really well supported in ckc. I could try to check if we can do something in 4.x, but in that version we are leveraging spring-rabbitmq and the old rabbitmq component has been removed. So it won't be the same.

oscerd avatar Dec 11 '23 10:12 oscerd

Thanks for your answer, Andrea.

I think it's not feasible to use the args parameter

- Not sure I understand this, the above config translates into a corresponding queue, but with a truncated camel cased argument for some reason. If i set it to queue.x_queue_type, for example, it'll create the queue with the exact same argument without any modifications.

dshma avatar Dec 20 '23 11:12 dshma

I'm saying that doing this in a Kamelet (which will be used to generate the connector in this project), won't be possible at first sight. I guess it will require a different notation, but I cannot say that because the Rabbitmq component has been removed in favor of spring-rabbitmq in Camel core project. This will require more time.

oscerd avatar Dec 20 '23 11:12 oscerd

Okay, gotcha, I guess I'll discard the ticket then, it's not really worth the investment of time, other than out curiosity perhaps. Thank you!

dshma avatar Dec 20 '23 16:12 dshma

Just for tracking purpose I'll leave this open for the spring rabbitmq connector

oscerd avatar Dec 20 '23 16:12 oscerd

Hello there,

Had recently a chance to debug the issue and came across the following place:

camel/core/camel-util/src/main/java/org/apache/camel/util/StringHelper:dashToCamelCase

    /**
     * Converts the string from dash format into camel case (hello-great-world -> helloGreatWorld)
     *
     * @param  text the string
     * @return      the string camel cased
     */
    public static String dashToCamelCase(String text) {
        if (text == null) {
            return null;
        }
        int length = text.length();
        if (length == 0) {
            return text;
        }
        if (text.indexOf('-') == -1) {
            return text;
        }

        // there is at least 1 dash so the capacity can be shorter
        StringBuilder sb = new StringBuilder(length - 1);
        boolean upper = false;
        for (int i = 0; i < length; i++) {
            char c = text.charAt(i);
            if (c == '-') {
                upper = true;
            } else {
                if (upper) {
                    c = Character.toUpperCase(c);
                }
                sb.append(c);
                upper = false;
            }
        }
        return sb.toString();
    }

This is what trims dashes for the property and format mentioned above: "camel.component.rabbitmq.args[queue.x-queue-type]": "quorum"

We've applied a temporal fix that doesn't execute the logic within the method for the specific property, but this might be smth to keep in mind in newer versions.

fyi: @oscerd

dshma avatar Feb 02 '24 23:02 dshma

closing old version tickets

davsclaus avatar May 06 '24 17:05 davsclaus