<div dir="ltr">Hello All<br><br>I was wondering if any one has had much success using Lyra<br><a href="https://github.com/jhalterman/lyra">https://github.com/jhalterman/lyra</a><br><br>From my testing so far it appears to do exactly what it says it will do However<br><br>My problem is that when I try to use the recovered consumer the same shutdown exception is thrown that cause the recovery in the first place.<br>My simple test case is to kill the connection using the web management console  after sending a number of messages.<br><br>There must be something here I am not understand correctly.<br>What I would expect is that after the connection and consumer is recovered any un acked messages would be republished but no the forced disconnect that caused the recovery in the first place.<br><br>Is there a way to over come this or is forcefully killing the connection not a valid recovery test case ?<br><br>Here is test code<br><br><br>import com.rabbitmq.client.Channel;<br>import com.rabbitmq.client.ConnectionFactory;<br>import com.rabbitmq.client.QueueingConsumer;<br>import net.jodah.lyra.ConnectionOptions;<br>import net.jodah.lyra.Connections;<br>import net.jodah.lyra.config.Config;<br>import net.jodah.lyra.config.ConfigurableConnection;<br>import net.jodah.lyra.config.RecoveryPolicies;<br><br><br>public class RecoveryTest {<br>     <br>    private static RecoveryTest test;<br><br>    private String EXCHANGE_NAME = "ORDER_UPDATES";<br>    private String EXCHANGE_HOST = "localhost";<br>    private String EXCHANGE_USER = "recover";<br>    private String EXCHANGE_PASS = "recover";<br>    private String QUEUE = "TEST_UPDATES";<br>    private String TOPIC = "*.#";<br><br>    private final Config config = new Config().withRecoveryPolicy(RecoveryPolicies.recoverAlways());;<br>    private ConnectionOptions options;<br>    private Channel channel;<br>    private ConnectionFactory factory;<br>    private ConfigurableConnection RecoveryConnection;<br>    private QueueingConsumer consumer;<br>    <br>      public static void main(String[] args) throws Exception  {<br>          test = new RecoveryTest();<br>          test.run();<br>      }<br>    <br>      public RecoveryTest() throws Exception {<br>          <br>            options = new ConnectionOptions().withAddresses(EXCHANGE_HOST);      <br>            factory = options.getConnectionFactory();<br>            factory.setUsername(EXCHANGE_USER);<br>            factory.setPassword(EXCHANGE_PASS);<br>            RecoveryConnection = Connections.create(options, config);<br>            channel = RecoveryConnection.createChannel();<br>            channel.queueDeclare(QUEUE, true, false, false, null);<br>            channel.queueBind(QUEUE, EXCHANGE_NAME, TOPIC);<br>            <br>            consumer = new QueueingConsumer(channel);<br>            boolean autoAck = true;<br>            channel.basicConsume(QUEUE, autoAck, consumer);<br>      }<br><br>      <br>      public void run() { <br>       QueueingConsumer.Delivery delivery = null;   <br>       System.out.println("Starting Test Run");<br>       while(true){           <br>           try {              <br>               delivery = consumer.nextDelivery();<br>           } catch (Exception ex) {<br>                 System.out.println("Somthing went wrong ..." + ex.getLocalizedMessage());<br>           }     <br>           byte [] msg = delivery.getBody();<br>           System.out.println(String.valueOf(new String(msg)));<br>           try {<br>               System.out.println("Lets take a rest");<br>               Thread.sleep(8000);<br>           } catch (InterruptedException ex) {<br>              System.out.println("We have been intrupted");<br>           }<br>             <br>       }<br>     } <br>      <br>    <br>}<br><br><br>[main] INFO net.jodah.lyra.internal.ConnectionHandler - Creating connection cxn-1 to [localhost]<br>[main] INFO net.jodah.lyra.internal.ConnectionHandler - Created connection cxn-1 to amqp://127.0.0.1:5672/<br>[main] INFO net.jodah.lyra.internal.ConnectionHandler - Created channel-1 on cxn-1<br>[main] INFO net.jodah.lyra.internal.ChannelHandler - Created consumer-amq.ctag-vUb0yGdYSY3Cq6eJEARsvA of TEST_UPDATES via channel-1 on cxn-1<br>Starting Test Run<br>hello<br>Lets take a rest<br>hello<br>Lets take a rest<br>hello again <br>Lets take a rest<br>This is a new message <br>Lets take a rest<br>[AMQP Connection 127.0.0.1:5672] ERROR net.jodah.lyra.internal.ChannelHandler - Channel channel-1 on cxn-1 was closed unexpectedly<br>Somthing went wrong ...connection error; reason: {#method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - Closed via management plugin, class-id=0, method-id=0), null, ""}<br>This is a new message <br>Lets take a rest<br>[AMQP Connection 127.0.0.1:5672] ERROR net.jodah.lyra.internal.ConnectionHandler - Connection cxn-1 was closed unexpectedly<br>[lyra-recovery-1] INFO net.jodah.lyra.internal.ConnectionHandler - Recovering connection cxn-1 to [localhost]<br>[lyra-recovery-1] INFO net.jodah.lyra.internal.ConnectionHandler - Recovered connection cxn-1 to amqp://127.0.0.1:5672/<br>[lyra-recovery-1] INFO net.jodah.lyra.internal.ConnectionHandler - Recovering queue binding from ORDER_UPDATES to TEST_UPDATES with *.# via cxn-1<br>[lyra-recovery-1] INFO net.jodah.lyra.internal.ChannelHandler - Recovering channel-1 on cxn-1<br>[lyra-recovery-1] INFO net.jodah.lyra.internal.ChannelHandler - Recovered channel-1 on cxn-1<br>[lyra-recovery-1] INFO net.jodah.lyra.internal.ChannelHandler - Recovering consumer-amq.ctag-vUb0yGdYSY3Cq6eJEARsvA of TEST_UPDATES via channel-1 on cxn-1<br>Somthing went wrong ...connection error; reason: {#method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - Closed via management plugin, class-id=0, method-id=0), null, ""}<br>This is a new message <br>Lets take a rest<br>Somthing went wrong ...connection error; reason: {#method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - Closed via management plugin, class-id=0, method-id=0), null, ""}<br>This is a new message <br><br>loop for ever ...... <br><br><br><br><br><br><br><br><br></div>