0
votes

Problem statement: There are two Queues in two different brokers. Each Queue has one Consumer to it. The producer is dropping messages on the first Queue. We would want to send a copy of message to the second Queue. For visualization

                   Producer
                         |

Broker1 --> Queue1 --> Consumer1
                       | (copy)
Broker2 --> Queue2 --> Consumer2 (consumes same message as Consumer1 but is independent of Consumer1)

The ask is

  1. Only 1 queue is created in each broker. I have achieved the above with 4 Queues but looking for more optimized solution.
  2. Prefer no topics to be used.
  3. To be done only through activemq provided configuration.

What have I done till now: I managed to do the above with 4 queues. In Broker1, Queue1 forwarding a copy to a Virtual Destination Queue. Also, sending the messages in Virtual Destination to broker 2 through network connector.

    <destinationInterceptors>
        <virtualDestinationInterceptor>
            <virtualDestinations>
                <compositeQueue name="Queue1" forwardOnly="false">
                    <forwardTo>
                        <queue physicalName="IntermediateQueue"/>
                    </forwardTo>
                </compositeQueue>
            </virtualDestinations>
        </virtualDestinationInterceptor>
    </destinationInterceptors>

    
    <networkConnectors>
     <networkConnector 
        name="Q:broker1->broker2" 
        uri="static:(tcp://localhost:31616)" 
        duplex="false" 
        staticBridge="true">
        <staticallyIncludedDestinations>
            <queue physicalName="IntermediateQueue"/>
        </staticallyIncludedDestinations>
     </networkConnector>
 </networkConnectors>
 

In Broker2, forwarding all messages received in the intermediate Queue to the actual destination queue.

    <destinationInterceptors>
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <compositeQueue name="IntermediateQueue">
            <forwardTo>
              <queue physicalName="FinalDestinationQueue" />
            </forwardTo>
          </compositeQueue>
        </virtualDestinations>
      </virtualDestinationInterceptor>
    </destinationInterceptors> 

Appreciate any help, as going through activemq documentation and forums didn't yield an optimized answer to this problem.

1

1 Answers

0
votes

You are essentially re-creating pub+sub and then adding in a transmission-queue pattern for multi-broker integration. There are valid use cases to do this and your approach is valid and within the intended design of Composite Destinations and Network Connectors. The trade-off in this approach is the heavy administration and configuration management that is required.

I understand you prefer to not use topics. However, you may consider looking at Virtual Topics1 which solve this problem in an elegant way and allows you to add new consumers dynamically and without having to modify the broker configuration.

Producer send to Topic:

topic://VT.ORDER.EVENT

Consumer(s) read from special named Queues

clientA: queue://VQ.CLIENTA.VT.ORDER.EVENT

clientB: queue://VQ.CLIENTB.VT.ORDER.EVENT

ref: Virtual Topics