Author Topic: Disconnected  (Read 3141 times)

Offline Ali

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 0
  • Haunted by Genesys
    • My Web Site
Disconnected
« on: February 11, 2015, 10:00:52 AM »
Hi all,

I would like to learn your opinions on how to detect TServer disconnect (or communication failure with TServer) for Protocol Management Service Implementation.

Using the following code segment, I get connected to the TServer:


[code]

this.ctiServerConfiguration = new TServerConfiguration(
EventCollectorConfig.getInstance().getConf().getCTI()
.getAppName());
this.ctiServerConfiguration.setUseAddp(true);
this.ctiServerConfiguration.setAddpServerTimeout(10);
this.ctiServerConfiguration.setAddpClientTimeout(10);
this.ctiServerConfiguration.setClientName("EVENT_AGG_SERV");
               
              URI ctiURI = null;

try {
ctiURI = new URI("tcp://"
+ EventCollectorConfig.getInstance().getConf().getCTI()
.getHost()
+ ":"
+ EventCollectorConfig.getInstance().getConf().getCTI()
.getPort());
this.ctiServerConfiguration.setUri(ctiURI);
} catch (URISyntaxException e) {
throw e;
}

this.pmsi = new ProtocolManagementServiceImpl();
this.pmsi.register(this.ctiServerConfiguration);

// Initialize event broker
mEventBrokerService = BrokerServiceFactory.CreateEventBroker(pmsi

mEventBrokerService.activate();

// Open connection with T-Server:
try {
this.pmsi.getProtocol(
EventCollectorConfig.getInstance().getConf().getCTI()
.getAppName()).open();
logger.info("[GenesysAsynchEventReceiver][Open][Event Broker Service is active and open]");

} catch (ProtocolException e) {
throw e;
} catch (IllegalStateException e) {
throw e;
} catch (InterruptedException e) {
throw e;
} catch (Exception e)
{
throw e;
}[/code]


Thank you in advance.

Regards,

Ali

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Re: Disconnected
« Reply #1 on: February 12, 2015, 04:28:50 PM »
Since you are using ProtocolManagementServiceImpl you can add a ChannelListener to it.

a ChannelListener must implement

public interface ChannelListener extends Listener {

public abstract void onChannelOpened(EventObject eventobject);

public abstract void onChannelClosed(ChannelClosedEvent channelclosedevent);

public abstract void onChannelError(ChannelErrorEvent channelerrorevent);
}

this.pmsi.addChannelListener(channelListener);

that should alert you of some disconnections.

You can also catch exceptions when making request to the TServer, which sometimes mean that the protocol is disconnected.

try {
this.tServerProtocol.send(request);
return uniqueId;
}
catch (ProtocolException protocolException)
{
if ("Connection is not opened".equals(protocolException.getMessage())) {
//YOU ARE DISCONNECTED
}
}

Also listen to the EventLinkDisconnected event.

Offline Ali

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 0
  • Haunted by Genesys
    • My Web Site
Re: Disconnected
« Reply #2 on: February 13, 2015, 01:08:57 PM »
Dear gstkein,

Thank you very much. This is what I am looking for.

Cheers,

Ali