Announcement Announcement Module
Collapse
No announcement yet.
ShutdownNotifierComponent shutdowncause how to set back to null value Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ShutdownNotifierComponent shutdowncause how to set back to null value

    I have a question regarding this ShutdownNotifierComponent

    there is this field in the ShutdownNotifierComponent.class file


    /**
    * When this value is null, the component is in an "open"
    * state. When non-null, the component is in "closed" state, and
    * this value indicates the circumstances of the shutdown.
    */
    public volatile ShutdownSignalException _shutdownCause = null;

    if I get an AlreadyClosedException due to a rabbitmq server crash, there is no way that I can set this _shutdownCause to null

    I need to reconnect to rabbitmq and for that I overrided the method
    prepareConnection(Connection con) from SingleConnectionFactory like this (the very simple case) :

    @Override
    protected void prepareConnection(Connection con) throws IOException {
    con.addShutdownListener(new ShutdownListener(){
    @Override
    public void shutdownCompleted(final ShutdownSignalException cause) {
    initConnection();
    }
    });

    initConnection is the method from SingleConnectionFactory and a new connection is provided with all necessary but there is only one problem, the connection provided is AMQConnection which is ShutdownNotifierComponent and that connection will have the _shutdownCause not null,as there was a previous error so when the code needs to use this new connection provided by initConnection the isOpen() method from ShutdownNotifierComponent will return false as the _shutdownCause is not null and it seems there is no way that I can reuse the whole thing, I have to reconstruct everything from rabbitadmin to rabbittemplate, readd my listeners and redeclare all of the queues

    Any advice is helpful , I am thinking to post an issue to spring amqp team.
    }

  • #2
    I also need something like this any help would be useful

    I dont see initConnection re initializing the channels.

    @Override
    protected void prepareConnection(final Connection con) throws IOException {
    con.addShutdownListener(new ShutdownListener() {
    @Override
    public void shutdownCompleted(ShutdownSignalException e) {
    resetConnection();
    try {
    AMQConnection amqConnection = (AMQConnection) con;
    amqConnection._shutdownCause = null;
    initConnection();
    } catch (IOException e1) {
    e1.printStackTrace();
    }

    }
    });
    super.prepareConnection(con);
    }

    Comment


    • #3
      Can someone please reply to this, whats the easiest way achieve retries?

      Comment

      Working...
      X