title: How to handle Activemq's max frame size exception with failover transport
body: <p>I am developing an application that uses activemq to exchange messages, some so big that I want to cancel then. </p>
  
  <p>We work with the activemq failover transport with two ActiveMQ instances (master/slave). The broker itself has the 100mb framesize limit for messages.</p>
  
  <p>The problem is: if I try to send a message bigger than 100mb the ActiveMQ server will shutdown the connection. At this point, the failover transport will try to reconnect and send the message again, creating an infinite loop. </p>
  
  <p>The client logs the following: </p>
  
  <pre><code>2017-01-05 09:19:11.910  WARN 14680 --- [0.1:61616@57025] o.a.a.t.failover.FailoverTransport       : Transport (tcp://localhost:61616) failed , attempting to automatically reconnect: {}
  
  java.io.EOFException: null
      at java.io.DataInputStream.readInt(DataInputStream.java:392) ~[na:1.8.0_91]
      at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:267) ~[activemq-client-5.13.4.jar:5.13.4]
      at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240) ~[activemq-client-5.13.4.jar:5.13.4]
      at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232) ~[activemq-client-5.13.4.jar:5.13.4]
      at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215) ~[activemq-client-5.13.4.jar:5.13.4]
      at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
  
  2017-01-05 09:19:11.921  INFO 14680 --- [ActiveMQ Task-1] o.a.a.t.failover.FailoverTransport       : Successfully reconnected to tcp://localhost:61616
  2017-01-05 09:19:11.923  WARN 14680 --- [0.1:61616@57026] o.a.a.t.failover.FailoverTransport       : Transport (tcp://localhost:61616) failed , attempting to automatically reconnect: {}
  
  java.io.EOFException: null
      at java.io.DataInputStream.readInt(DataInputStream.java:392) ~[na:1.8.0_91]
      at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:267) ~[activemq-client-5.13.4.jar:5.13.4]
      at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240) ~[activemq-client-5.13.4.jar:5.13.4]
      at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232) ~[activemq-client-5.13.4.jar:5.13.4]
      at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215) ~[activemq-client-5.13.4.jar:5.13.4]
      at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
  </code></pre>
  
  <p>While activeMQ instance logs:</p>
  
  <pre><code>2017-01-05 09:19:11,909 | WARN  | Transport Connection to: tcp://127.0.0.1:57025 failed: java.io.IOException: Frame size of 363 MB larger than max allowed 100 MB | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ Transport: tcp:///127.0.0.1:57025@61616
  2017-01-05 09:19:11,922 | WARN  | Transport Connection to: tcp://127.0.0.1:57026 failed: java.io.IOException: Frame size of 363 MB larger than max allowed 100 MB | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ Transport: tcp:///127.0.0.1:57026@61616
  </code></pre>
  
  <p>I tried to setup a TransportListener to verify if I can capture this case, but I just receive a transportInterupted event, without any classifier. </p>
  
  <p>I read the documentation about the failover transport (<a href="http://activemq.apache.org/failover-transport-reference.html" rel="noreferrer">http://activemq.apache.org/failover-transport-reference.html</a>) and maybe I can use the maxReconnectAttempts, but I understand I will have several drawbacks in more common situations (like the server unavailable for a while).</p>
  
  <p>How can I detect this kind of situation and avoid the infinite connection loop between the client and server?</p>