artemiscloud / activemq-artemis-operator

Apache License 2.0
69 stars 63 forks source link

Bridge transformers not being applied #938

Closed teksuo closed 5 months ago

teksuo commented 5 months ago

Hi there!

I am trying to achieve this configuration which is working in a classical ActiveMQ Artemis using the ActiveMQArtemis CRD and brokerProperties field, but so far it has been impossible:

<bridges>
      <bridge name="my-bridge">
          <queue-name>my-queue</queue-name>
          <forwarding-address>my-queue</forwarding-address>
          <transformer>
              <class-name>org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer</class-name>
              <property key="my-key" value=my-value/>
          </transformer>
    (...)

What I have tried using brokerProperties:

- 'bridgeConfigurations.my-bridge.transformer.class-name=org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer'
- 'bridgeConfigurations.my-bridge.transformer.property[0].key=my-key'
- 'bridgeConfigurations.my-bridge.transformer.property[0].value=my-value'
- 'bridgeConfigurations.my-bridge.transformer.class-name=org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer'
- 'bridgeConfigurations.my-bridge.transformer.properties[0].key=my-key'
- 'bridgeConfigurations.my-bridge.transformer.properties[0].value=my-value'
- 'bridgeConfigurations.my-bridge.transformer.class-name=org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer'   
- 'bridgeConfigurations.my-bridge.transformer.my-key=my-value'
- 'bridgeConfigurations.my-bridge.transformer.class-name=org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer'   
- 'bridgeConfigurations.my-bridge.transformer.property.my-key=my-value'

And some other combination I no longer remember...

Just for the record, the connector is properly configured and the staticConnector ref is also properly parsed and linked using:

- 'bridgeConfigurations.my-bridge.staticConnectors=my-connector-name'

Other properties I'm using:

- 'bridgeConfigurations.my-bridge.retryInterval=1000'
- 'bridgeConfigurations.my-bridge.reconnectAttempts=1'
- 'bridgeConfigurations.my-bridge.useDuplicateDetection=true'
- 'bridgeConfigurations.my-bridge.user=<>'
- 'bridgeConfigurations.my-bridge.password=<>'

Is this a bug? is this just not implemented? I can see nothing related to transformers in the doc or the issues, so I suspect the latter may be the case. If so, is there any plan to support his in the near future? This is a must for us in order to adopt this operator.

Thanks in advance!

[!TIP] Vote this issue reacting with :+1: or :-1:

teksuo commented 5 months ago

After digging a little bit in the ConfigurationImplTest and BridgeConfigurationTest I tried the following syntax, sadly without any luck:

- 'bridgeConfigurations.my-bridge.transformerConfiguration.class-name=org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer'   
- 'bridgeConfigurations.my-bridge.transformerConfiguration.properties.my-key=my-value'
gtully commented 5 months ago

can you check the CR.Status to see the errors that are reported back from the broker attempting to apply the properties to the config objects.

properties are typically camelCase, and the properties map needs to be passed as a comma list string k=v,k2=v2 b/c the properties object is not exposed via setters/getters.

- 'bridgeConfigurations.my-bridge.transformerConfiguration.className=org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer'   
- 'bridgeConfigurations.my-bridge.transformerConfiguration.properties=my-key=my-value,my-other-header=some-other-value'

that should do it.

gtully commented 5 months ago

I added some verification in an upstream test on the broker, see: https://github.com/apache/activemq-artemis/commit/efdcc56519923ef4dd952b2c23b08b8aba275c0c

Please revert if there is still any difficulty.