Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS fault tolerant asynchronous publisher

In our architecture JMS publisher may continue to work (and generate new messages) even if connection with local network is lost. Is it possible to make publisher server tolerant to network or broker outages with JMS:

  1. publish call may not block application, even if broker is not available;
  2. published messages (during outage) must be delivered after network connection is restored;

As far as I understand it can be done with embedded (local) broker on each publishing machine. If it's the only way, are there any non obvious problems with that topology - performance, maintenance, etc? Will the local broker be tolerant to outages by itself?

like image 553
Shcheklein Avatar asked Oct 11 '22 15:10

Shcheklein


1 Answers

I've not tried this but it seems like you could use local failover to reduce impedance: With ActiveMQ you can configure a failover transport:

failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false

To try and draw this:

client +---> primary: network broker <-------+
       |                                     |
       +---> secondary: embedded broker -----+

Here primary would be your network broker, and your secondary broker would be the locally embedded broker with a bridge to the primary broker. This seems like it would work well when the client publishes allot; I'm not sure if this would be any better for subscribes then the solution put forward by @Biju: illustrated below:

client +---> secondary: embedded broker ------> primary: network broker 

For example here is my embedded broker (which is usually non-persistent).

<bean id="activeMQBroker" class="org.apache.activemq.broker.BrokerService">
    <property name="transportConnectors">
        <list>
                <bean id="brokerConnection" class="org.apache.activemq.broker.TransportConnector">
                    <property name="connectUri">
                        <bean id="brokerURI" class="java.net.URI">
                            <constructor-arg value="tcp://localhost:61616" />
                        </bean>
                    </property>
                </bean>
        </list>
    </property>

    <property name="persistent" value="true" />
</bean>
like image 109
Justin Avatar answered Oct 15 '22 10:10

Justin