I see a lot of example code that checks to see if the session == null when an attempt is made to acquire it. But the session always seems to come back with an object, even if the Config is bogus. It is only when sending a message that it seems to find out that it cant connect to RFA. Can someone verify that?
Is there anyway to query the Context or Session for their state?
When I do send a message, whether it be a login or some other message, there is no event sent to my handler to tell me that it cannot connect to RFA. So for example if I purposely change the port to a wrong one, the logging shows there are errors but the event handler never gets any messages. All of my code is modelled after the examples in the API kit.
Here is a portion of my test code in cased that is useful.
@Test(groups={"unit"}) public void testFailToConnect() throws Exception { Logger logger = Logger.getLogger("com.reuters.rfa"); Level level = Level.FINEST; logger.setLevel(level); Handler[] handlers = logger.getHandlers(); if(handlers.length == 0) { Handler handler = new ConsoleHandler(); handler.setLevel(level); logger.addHandler(handler); } // purposely configure it so the port is wrong ConfigDb configProvider = (ConfigDb) getTestConfig(); configProvider.addVariable("Convx.Connections.p2psCon.portNumber", "14001"); Context.initialize(configProvider); try { Session session = Session.acquire("Convx::p2ps"); Assert.assertNotNull(session,"could not acquire session"); EventQueue eventQueue = EventQueue.create("myEventQueue"); OMMConsumer consumer = (OMMConsumer) session.createEventSource(EventSource.OMM_CONSUMER,"myOMMConsumer",true); //Create a OMMPool. OMMPool pool = OMMPool.create(); //Create an OMMEncoder OMMEncoder encoder = pool.acquireEncoder(); OMMMsg ommmsg = encodeLoginReqMsg(pool,encoder); OMMItemIntSpec ommItemIntSpec = new OMMItemIntSpec(); ommItemIntSpec.setMsg(ommmsg); System.out.println(" Sending login request..."); EventHandler eventHandler = new EventHandler(); Handle loginHandle = consumer.registerClient(eventQueue, ommItemIntSpec, eventHandler, null); Thread.sleep(5000); // we need some way to know that the session could not acquire a connection to Reuters. session.release(); } finally { Context.uninitialize(); } }
I have set breakpoints in the processEvent of the event handler (that implements Client) and I don't get any hits.
The log looks like this:
Feb 13, 2017 9:41:07 AM com.reuters.rfa.internal.session.SessionImpl processEventQueueDispatchThreadStarted FINE: com.reuters.rfa.session.Convx.p2ps Session initialization: Dispatch thread "Convx::p2ps Session EventQueueGroup" started Sending login request... Feb 13, 2017 9:41:12 AM com.reuters.rfa.internal.session.ConnectionHandler createConnections FINE: com.reuters.rfa.session.Convx.p2ps Session initialization: acquiring connection "Convx::p2psCon" Feb 13, 2017 9:41:13 AM com.reuters.rfa.internal.connection.ConnectionImpl processConnectionStatusOpenReqMsg FINE: com.reuters.rfa.connection.rssl.Convx.p2psCon Sending CONNECTION_STATUS_MSG, connection name = Convx::p2psCon, status = { state: DOWN, code: NONE, text: "uninitialized"} Feb 13, 2017 9:41:17 AM com.reuters.rfa.internal.connection.ConnectionImpl processConnectionStatusBase FINE: com.reuters.rfa.connection.rssl.Convx.p2psCon Sending CONNECTION_STATUS_MSG, connection name = Convx::p2psCon, status = { state: DOWN, code: NONE, text: "Connection refused: no further information"} Feb 13, 2017 9:41:17 AM com.reuters.rfa.internal.session.SessionImpl cleanup FINE: com.reuters.rfa.session.Convx.p2ps Session cleanup: Deactivating event queues and halting dispatch thread Feb 13, 2017 9:41:17 AM com.reuters.rfa.internal.session.ConnectionHandler sendClosedReqMsg FINE: com.reuters.rfa.session.Convx.p2ps Session cleanup: Releasing connection "Convx::p2psCon"