I have tried the same but I didn't work. The same works fine and forwards the
message to all the broker If I supply the IP static list before startting
the BE server. BUt when I add dynamically by calling "addNetworkConnector"
it didn't work. Do you have any same programs for this case. So I am 
pasting my code

public class BrokerMain
{
    public static void main(String[] args)
    {
        final BrokerService broker = new BrokerService();;
        Runnable doRun = new Runnable(){
            public void run()
             {
                try
                {
                
                    broker.setBrokerName("FE-Test");
                    broker.addConnector(new URI("tcp://localhost:61616"));
                    thrdBroker.setBrokerName("BEServer");                    
                    thrdBroker.setPersistent(false);
                    thrdBroker.setUseJmx(false);
                    thrdBroker.start();
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
        };
        Thread thrd = new Thread(doRun);
        thrd.start();
        ProducerTool publisher = new ProducerTool();
        while( !broker.isStarted() );

        BufferedReader waiter = new BufferedReader(new
InputStreamReader(System.in));
        String input = null;
        try
        {
            System.out.println("Following Commands are supported");
            System.out.println("Publish Messages => 1");
            System.out.println("Add N/W Connector => 2");
            System.out.println("Stop Broker => 3");
            int opCode = -1;
            boolean isStopped = false;
            while( !isStopped && ( input = waiter.readLine()) != null )
            {
                opCode = Integer.parseInt(input);
                switch( opCode )
                {
                    case 1:
                        {
                            ProducerTool.runTool( args, publisher);
                        }
                        break;
                    case 2:
                        {
                            System.out.println("Enter Broker IPAddress and
Port (Ex:10.10.8.212:6333) :");
                            String ipAddress = waiter.readLine();
                            if( ipAddress != null && ipAddress.length() > 0
)
                            {
                               
broker.addNetworkConnector("static:(tcp://"+ipAddress+")");                     
          
                            }
                        }
                        break;
                    case 3:
                        {
                            isStopped = true;
                        }
                        break;
                    default:
                }

            }
        } catch (IOException e)
        {
            e.printStackTrace();
        } catch (Exception e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                broker.stop();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    }
}
-- 
View this message in context: 
http://www.nabble.com/broker-static-dynamic-IP-list-tf2009183.html#a5536541
Sent from the ActiveMQ - User forum at Nabble.com.

Reply via email to