artemiscloud / activemq-artemis-operator

Apache License 2.0
64 stars 62 forks source link

Need to setup Core bridge #925

Closed gnaveen33 closed 4 months ago

gnaveen33 commented 4 months ago

Hi Team,

Can you please help me on how to setup corebrige in artemis MQ. I see an option called createBridge in JMX api call , with that we have created a bridge by giving bridge name , sourcequeue, forwarding address(destination queue) , filter string and other strings. I could see a bridge created but when i tested that using Jmeter tool using JMS publisher and JMS subscriber, messaging produced to source queue but not forwarded to destination queue and also i could see consumer count on destination queue. Used different Filter string like "type='3'" , "JMSType='text'", "Priority ='4'"but nothing worked. Could you please help us here.

Also, should i need to enable bridging in config file ?

gaohoward commented 4 months ago

If you need a static core bridge you just need to configure the core bridge in the CR. Can you share your core bridge configuration? Also check the broker pod's log and see if there is any error/warn log messages.

gnaveen33 commented 4 months ago

Hi @gaohoward ,

Is that possible to share the sample config for this core bridge? Meanwhile will check the internal config and share you .

gnaveen33 commented 4 months ago

Hi @gaohoward ,

We are getting below error when we try to start the broker pod,

2024-05-10 09:12:35,767 ERROR [org.apache.activemq.artemis.core.server] AMQ224000: Failure in initialisation java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "connectorNames" is null at org.apache.activemq.artemis.core.config.impl.ConfigurationImpl.getTransportConfigurations(ConfigurationImpl.java:2442) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.cluster.ClusterManager.deployBridge(ClusterManager.java:436) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.deployBridge(ActiveMQServerImpl.java:2983) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.recoverStoredBridges(ActiveMQServerImpl.java:4338) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.initialisePart2(ActiveMQServerImpl.java:3510) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation.run(LiveOnlyActivation.java:78) [artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:720) [artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:610) [artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.integration.FileBroker.start(FileBroker.java:66) [artemis-cli-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.cli.commands.Run.execute(Run.java:130) [artemis-cli-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.cli.Artemis.internalExecute(Artemis.java:219) [artemis-cli-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:165) [artemis-cli-2.31.0.jar:2.31.0] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at org.apache.activemq.artemis.boot.Artemis.execute(Artemis.java:144) [artemis-boot.jar:2.31.0] at org.apache.activemq.artemis.boot.Artemis.main(Artemis.java:61) [artemis-boot.jar:2.31.0]

gaohoward commented 4 months ago

I guess your core bridge is not properly configured, you need to config a correct connector to point to your target broker. Here is a example

  connectors:
  - name: target-connector
    port: 51515
    host: artemis-broker2-ss-0.artemis-broker2-hdls-svc.default.svc.cluster.local
  brokerProperties:
  - "queueConfigurations.sourceQueue.name=sourceQueue"
  - "queueConfigurations.sourceQueue.address=sourceQueue"
  - "queueConfigurations.sourceQueue.routingType=ANYCAST"
  - "bridgeConfigurations.bridge1.queueName=sourceQueue"
  - "bridgeConfigurations.bridge1.forwardingAddress=targetAddress"
  - "bridgeConfigurations.bridge1.ha=false"
  - "bridgeConfigurations.bridge1.reconnectAttempts=-1"
  - "bridgeConfigurations.bridge1.useDuplicateDetection=true"
  - "bridgeConfigurations.bridge1.user=admin"
  - "bridgeConfigurations.bridge1.password=admin"
  - "bridgeConfigurations.bridge1.staticConnectors=target-connector"
gnaveen33 commented 4 months ago

Thanks for the input @gaohoward.

We are also trying to configure diverts to forward messages to an address within our broker. We could see messages being copied to the target address in case of non-exclusive diverts (We left the filter field empty while executing createDivert). When we tried to filter the messages, we couldn't see the messages getting routed to the target. Could you please help us on how to provide filter strings while we execute createDivert operation.

gnaveen33 commented 4 months ago

Also, can you please confirm on below info,

Bridges are used for forwarding messages to a remote broker, while Diverts are used for forwarding messages within a broker.

gaohoward commented 4 months ago

Also, can you please confirm on below info,

Bridges are used for forwarding messages to a remote broker, while Diverts are used for forwarding messages within a broker.

Yes that's true. Note the core bridges only works with artemis broker. For example you can't use it to connect to another broker like rabbit mq.

gaohoward commented 4 months ago

Thanks for the input @gaohoward.

We are also trying to configure diverts to forward messages to an address within our broker. We could see messages being copied to the target address in case of non-exclusive diverts (We left the filter field empty while executing createDivert). When we tried to filter the messages, we couldn't see the messages getting routed to the target. Could you please help us on how to provide filter strings while we execute createDivert operation.

Here is the doc about the filter string expression: https://github.com/apache/activemq-artemis/blob/main/docs/user-manual/filter-expressions.adoc most of the time the issue is related to filter string not correctly crafted. Can you share your filter string?

gnaveen33 commented 4 months ago

@gaohoward , Thanks for your info.

gnaveen33 commented 4 months ago

Now we used createDivert option to test divert settings, we got below error when we restart the pod,

2024-05-17 12:59:06,242 ERROR [org.apache.activemq.artemis.core.server] AMQ224000: Failure in initialisation java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) ~[?:?] at org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository.getMatch(HierarchicalObjectRepository.java:229) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.recoverStoredDiverts(ActiveMQServerImpl.java:4325) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.deployDiverts(ActiveMQServerImpl.java:4310) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.initialisePart2(ActiveMQServerImpl.java:3470) ~[artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation.run(LiveOnlyActivation.java:78) [artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:720) [artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:610) [artemis-server-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.integration.FileBroker.start(FileBroker.java:66) [artemis-cli-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.cli.commands.Run.execute(Run.java:130) [artemis-cli-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.cli.Artemis.internalExecute(Artemis.java:219) [artemis-cli-2.31.0.jar:2.31.0] at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:165) [artemis-cli-2.31.0.jar:2.31.0] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at org.apache.activemq.artemis.boot.Artemis.execute(Artemis.java:144) [artemis-boot.jar:2.31.0] at org.apache.activemq.artemis.boot.Artemis.main(Artemis.java:61) [artemis-boot.jar:2.31.0]

gaohoward commented 4 months ago

It suggests that the divert's address is null. Can you check your divert configuration?

gnaveen33 commented 4 months ago

@gaohoward Thanks for the information.