Hi

USE CASE:--
1.We have one app which run in two server DP1 AND DP2
2.Both DP1 and DP2 using embedded EmbeddedActiveMQ.java API to run apache
activemq artemis.
3.if i  start  DP1 1st then it is become live server and  DP2 become
 backup and vice versa
4.Now i shutdown DP1  then  DP2 should live  and as i start DP1 it beahve
as backup  till DP2 not fail.
5.in this case of artemis after fail of DP1,   DP2 is not behaving as live
server. because after failover of  DP1 , DP2 is not get activate .i am
checking  like this and always traped into loop nver come out from the loop.

 while
(!jmsServer.getActiveMQServer().waitForActivation(30L,TimeUnit.SECONDS)) {
            Thread.sleep(100);

        }
6.API using for live and backup  server

        if (isCurrentServerLive){
            ReplicatedPolicyConfiguration haPolicy = new
ReplicatedPolicyConfiguration();
            haPolicy.setGroupName("bsm-back-up-group");
            haPolicy.setInitialReplicationSyncTimeout(120000);
            haPolicy.setCheckForLiveServer(true);  // Critical for failover
detection
            haPolicy.setQuorumSize(1);  // Minimum nodes required
            configuration.setHAPolicyConfiguration(haPolicy);
         }else{
            ReplicaPolicyConfiguration haPolicy = new
ReplicaPolicyConfiguration();
            haPolicy.setGroupName("bsm-back-up-group");
            haPolicy.setInitialReplicationSyncTimeout(120000);
            haPolicy.setRestartBackup(false);  // Don't restart when live
exists
            haPolicy.setAllowFailBack(true);  // Allow primary to resume
            configuration.setHAPolicyConfiguration(haPolicy);;

          }


7.even listern is also not getting  call , listner implemation  in backup
side
public void  registerListener(boolean isCurrentServerLive) {
        LOG.info("kutt registerListener "+(!isCurrentServerLive?"back going
to register Listner":"live server not going to register"));
        if (!isCurrentServerLive) {
            final ActiveMQServer artemisServer =
jmsServer.getActiveMQServer();
            LOG.info(" registerListener done");
            artemisServer.registerActivateCallback(new ActivateCallback()

            {
                @Override
                public void preActivate() {

                    LOG.info(" registerListener preActivate() called");
                }

                @Override
                public void deActivate() {
                    LOG.info(" registerListener deActivate() called");
                }

                @Override
                public void activationComplete() {
                    LOG.info(" registerListener activationComplete()
called");
                }


                @Override
                public void activated() {
                    LOG.info(" registerListener activated() called");


                    // Below changes to check if the live bus is really
active.
                    // read the server state initially see the last interval
                    // loop of 2 times of interval
                    // wait of interval for 1 second
                    // read the state and see if the state changes
                    // if there is change then without changing the live
bus then restart
                    // if there is no change then update the live server
and then restart
                    try {
                        long busState = busData.getServerState();
                        int maxChecks = 10;
                        boolean isLiveBusActive = false;

                        synchronized (this) {
                            while (!isLiveBusActive && (maxChecks > 0)) {
                                wait(1000L);

                                isLiveBusActive = (busState !=
busData.getServerState());
                                LOG.info(" listerner called now on failover
 with state of backup"+isLiveBusActive);
                                maxChecks--;
                            }
                        }

                        if (!isLiveBusActive)
                            busData.setLiveServer(socket);
                    } catch (Exception e) {
                        LOG.info("Failed to update live server after backup
server got activated", e);
                    }

                    LOG.info("restarting backup server before clients fail
over");
                     try{
                     HornetQRunner.main(new String[]{"strat"});
                     }catch(Exception e){
                         LOG.info("faled to satrt");
                    }

                    // Throwing IllegalStateException to make sure the
calling old jmsserver doesn't finish it's failover
                    // since it had been stopped and a new one has been
started,
                    throw new IllegalStateException("Need to restart
instead of activation");
                }
            });
        }

    }




i need your suggestion to make it work . and thanks in advance for your
help.

its very urgent  our dead line is very near

Thanks
Niraj

Reply via email to