From: <pb...@ru...> - 2004-12-17 16:00:53
|
Hi, I have modified the "org/openorb/event/examples/push/PushServer.java" file to have more than one URI to a "OmniEvents" eventchannel. If the first one (primary) is down, the supplier will put the events to the second (secondary) eventchannel. But while running the program if the primary is down the supplier is trying to connect to the primary and throwing exception. It is not at all trying to connect to the secondary eventchannel. Can someone tell me what am I doing wrong in the code. Here is the code: PushServer.java /* * Copyright (C) The Community OpenORB Project. All rights reserved. * * This software is published under the terms of The OpenORB Community Software * License version 1.0, a copy of which has been included with this distribution * in the LICENSE.txt file. */ package org.openorb.event.examples.push; /** * PushServer example implementation * * @author Jerome Daniel * @author Olivier Modica */ public class PushServer { public static void main( String[] args ) { org.omg.CORBA.Object obj = null; org.omg.CosEventChannelAdmin.EventChannel canal = null; org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init( args, null ); org.omg.PortableServer.POA rootPOA = null; try { obj = orb.resolve_initial_references( "RootPOA" ); } catch ( org.omg.CORBA.ORBPackage.InvalidName ex ) { ex.printStackTrace(); System.exit( 1 ); } rootPOA = org.omg.PortableServer.POAHelper.narrow( obj ); try { rootPOA.the_POAManager().activate(); } catch ( java.lang.Exception ex ) { System.out.println( "Internal error..." ); ex.printStackTrace(); } System.out.println( "Event Service example" ); System.out.println( "Push model / server side" ); String evtchan = "corbaloc:iiop:10.10.10.4:9008,iiop:10.10.10.4:9009/Kernel"; try { //obj = orb.string_to_object( "corbaname:rir: #COS/EventService/EventChannelFactory" ); obj = orb.string_to_object( evtchan ); } catch ( org.omg.CORBA.BAD_PARAM ex ) { System.out.println( "The EventChannel cannot be found." + ex.getMessage() ); System.out.println( "Check if the Event and Naming servers are running." ); ex.printStackTrace(); System.exit( -1 ); } if ( obj == null ) { System.out.println( "The EventChannel reference is incorrect." ); System.out.println( "Check if the Event and Naming servers are running." ); System.exit( -1 ); } try { //canal = org.openorb.event.EventChannelFactoryHelper.narrow( obj ).create_channel( "ExampleChannel" ); canal = org.omg.CosEventChannelAdmin.EventChannelHelper.narrow( obj ); } //catch ( org.openorb.event.NameAlreadyUsed ex ) catch ( Exception ex ) { ex.printStackTrace(); try { canal = org.openorb.event.EventChannelFactoryHelper.narrow ( obj ).join_channel( evtchan ); } catch ( java.lang.Throwable error ) { error.printStackTrace(); System.exit( -1 ); } } org.omg.CosEventChannelAdmin.SupplierAdmin supplierAdmin = canal.for_suppliers(); org.omg.CosEventChannelAdmin.ProxyPushConsumer consumer = supplierAdmin.obtain_push_consumer(); MyPushSupplier supplier = new MyPushSupplier( orb, consumer ); //orb.connect( supplier ); try { consumer.connect_push_supplier( supplier._this( orb ) ); } catch ( java.lang.Exception ex_connect ) { System.out.println( "Unable to connect to consumer" ); ex_connect.printStackTrace(); } Thread t = new Thread( supplier ); t.start(); orb.run(); } } Pratip Biswas RUBIX Information Technologies, Inc. http://www.rubixinfotech.com This document has been scanned by TrendMicro ScanMail (RIT Email Server) |