Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.protocol
Class ClientChannel

java.lang.Object
  extended by com.genesyslab.platform.commons.protocol.AbstractChannel
      extended by com.genesyslab.platform.commons.protocol.DuplexChannel
          extended by com.genesyslab.platform.commons.protocol.ClientChannel
All Implemented Interfaces:
AsyncChannel, AsyncChannelOperations, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport, InputChannel, InterceptorSupport, LogMessageFilterSupport, MessageReceiver, MessageReceiverManagement, OutputChannel, Protocol, ProtocolDescriptionSupport, Receiver, ReceiverManagement, RequestChannel
Direct Known Subclasses:
ConfServerProtocol, ExternalServiceProtocol, InteractionServerProtocol, LcaUdpHeartbeatInternalProtocol, LocalControlAgentProtocol, MessageServerProtocol, OutboundServerProtocol, RoutingServerProtocol, SolutionControlServerProtocol, StatServerProtocol, TServerProtocol, UrsCustomProtocol, WebmediaChannel

public class ClientChannel
extends DuplexChannel
implements Protocol

ClientChannel is the parent class of all of the Protocol classes used for client applications in the Platform SDK, such as TServerProtocol and ConfServerProtocol.



For Genesys internal use only.


Nested Class Summary
protected  class ClientChannel.BasicClientHandshakeStep
          Abstract class with common or some default logic for client handshake steps.
protected static interface ClientChannel.ClientHandshakeStep
          Interface representing client side step of a protocol handshake procedure.
protected static interface ClientChannel.RegistrationHandler
          Deprecated.  
protected  class ClientChannel.SimpleRegistrationHandler
          Deprecated.  
 
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
AbstractChannel.AsyncErrorNotifier
 
Field Summary
 
Fields inherited from class com.genesyslab.platform.commons.protocol.DuplexChannel
messageFilter
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver
DEF_INPUT_SIZE
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
 
Constructor Summary
ClientChannel(Endpoint endpoint, ProtocolFactory protocolFactory, ReferenceBuilder refBuilder)
           
ClientChannel(Endpoint endpoint, ProtocolFactory protocolFactory, ReferenceBuilder refBuilder, long timeout)
           
 
Method Summary
 void beginClose()
          Closes channel asynchronously.
 void beginOpen()
          Begins channel opening asynchronously.
 RequestFuture beginRequest(Message message)
          Starts request and exits.
 void close(boolean force)
          Closes channel synchronously.
 void close(long timeout)
          Closes channel synchronously.
 java.util.concurrent.Future<ChannelClosedEvent> closeAsync()
          Close the channel asynchronously.
<A> void
closeAsync(long timeout, CompletionHandler<ChannelClosedEvent,A> handler, A attachment)
          Open channel asynchronously.
 ConnectionOperations disableConnectionOperations()
          Disable connection operations.
protected  MessageCorrelator.MessageEntry doBeginRequest(Message message)
          Deprecated.  
protected
<A> MessageCorrelator.MessageEntry
doBeginRequest(Message message, A attachment, CompletionHandler<Message,? super A> handler, long timeout)
           
protected  Message doRequest(Message message, long timeout)
           
 Message endRequest(RequestFuture future)
          Tries to finish request started with beginRequest().
 Message endRequest(RequestFuture future, long timeout)
          Tries to finish request started with beginRequest(Message).
 void fireUnsolicitedEvents()
           
 boolean getCopyResponse()
          Is response to request() copied to receive queue.
 AsyncInvoker getInvoker()
          Deprecated. For internal use only!
protected  ProtocolException getOpenTimeoutException(long timeout)
          Creates open timeout exception and logs it.
 ReferenceBuilder getReferenceBuilder()
           
protected  void onOpen()
          This method is called when channel is opened and just about to call event handler.
protected  void onReceiveMessage(Message msg)
          Gives to subclass a chance to perform some operations on incoming message arrival before delivering it to connection user code.
protected  void onSend(Message message)
          Gives to subclass a chance to modify message before sending it to remote party.
protected  void onUnexpectedHandshakeMessage(Message request, Message response, java.util.Queue<Message> msgsBuffer)
          Event handler for unexpected messages on handshake procedure, which are not accepted by the RegistrationHandler, but not caused handshake exception.
Registration handler allows custom handling of such kind of messages in specific protocols.
Particular protocol may override this method and, taking into account things like: response message type request message type current result messages queue state ... do add response message to the result queue do nothing to skip response message throw ProtocolException to break handshake procedure throw RegistrationException to break handshake procedure and stop WarmStandbyService (if it exists) After successful handshake procedure finish, messages from the result messages queue will be passed to the MessageHandler.
 void open(long timeout)
          Opens the channel by opening underlying connection including protocol specific handshake procedure using specified protocol timeout value.
Timeout can be set to following values: positive value - time in ms.
 java.util.concurrent.Future<ChannelOpenedEvent> openAsync(java.lang.Long timeout)
          Method is asynchronous.
<A> void
openAsync(long timeout, CompletionHandler<java.util.EventObject,A> handler, A attachment)
          Open channel asynchronously.
 Message request(Message message)
          This synchronous method sends the specified request to the server, and waits for a response from the server for the length of the timeout property.
 Message request(Message message, long timeout)
          This synchronous method sends the specified request to the server and waits for a response from the server for the length of the specified timeout value.
<A> void
requestAsync(Message message, A attachment, CompletionHandler<Message,? super A> handler)
          Starts request and exits.
<A> void
requestAsync(Message request, A attachment, CompletionHandler<Message,? super A> handler, long timeout)
          Starts request and exits.
 void setAddressResolver(SocketAddressResolver resolver)
          Sets custom SocketAddress resolver reference.
 void setAddressResolverParams(java.util.Map<java.lang.String,java.lang.Object> parameters)
          Sets parameters for SocketAddress resolver.
 void setAddressResolverParams(java.lang.String parameters)
          Sets parameters for SocketAddress resolver.
 void setCopyResponse(boolean copyResponse)
          Is response to request() copied to receive queue.
 void setEndpoint(Endpoint endpoint)
          Sets channel endpoint.
protected  void setHandshakeFinished(java.lang.Throwable exception)
           
protected  void setHandshakePhase(ClientChannel.ClientHandshakeStep handshakeStart)
          Initializes.
 void setHandshakeUnsolicitedEventsPassLimit(int maxNum)
          Deprecated. 
protected  void setRegistrationHandler(ClientChannel.RegistrationHandler handler)
          Deprecated.  
protected  void setState(ChannelState newState, ConnectionClosedEvent closedEvent)
           
protected  Message submitRegMessage(Message regMessage)
          Deprecated.  
protected  void throwOnUnReferenceableRequest(Message request)
           
 
Methods inherited from class com.genesyslab.platform.commons.protocol.DuplexChannel
addListener, applyConfiguration, cancelCloseTimeout, cancelOpenTimeout, clearInput, close, closeAsync, createChannelClosedEvent, createConnection, createConnectionClosedEvent, doBeginClose, doClose, doSend, downgradeConnection, getDefaultRestriction, getEnpointPrefixInfo, getInputSize, getInterceptor, getLocalEndPoint, getLocalEndpointInfo, getLogMessageFilter, getProtocolDescription, getProtocolFactory, getProtocolId, getRemoteEndPoint, getTimeoutException, initPackager, isMessageAllowed, notifyWithObject, onClose, onFireClosed, onFireErrorEvent, onFireOpened, open, openAsync, openAsync, processClose, processCloseAll, receive, receive, receivedMessage, releaseReceivers, removeListener, resetReceiver, resumeReading, send, setConnectionInvoker, setExternalTransport, setInputSize, setLogMessageFilter, setMessageHandler, setProtocolData, setReceiver, startUpgradeConnection, stopReading, toString, triggerWithObject, upgradeConnection, waitForObject
 
Methods inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
addChannelListener, configure, connectionContext, copyTLSSettings, fireClosed, fireErrorEvent, fireErrorEvent, generateChannelId, getChannelId, getConfiguration, getDefaultInvoker, getEndpoint, getListenerHelper, getServerContext, getState, getStateMods, getTimeout, internal, onSetEndpoint, releaseDefaultInvoker, removeChannelListener, setConfiguration, setInvoker, setServerContext, setState, setTimeout, throwNotClosed, throwNotOpened, throwNotOpenedOnClose, throwNotOpenedOnSend, throwNull, throwNullEndpoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Protocol
getProtocolId
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.InputChannel
setMessageHandler
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.MessageReceiver
receive, receive
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Receiver
clearInput, getInputSize, releaseReceivers, setInputSize
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.OutputChannel
addListener, removeListener, send
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Channel
close, getTimeout, open, setTimeout
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncChannel
getState
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ChannelListenerSupport
addChannelListener, removeChannelListener
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.InterceptorSupport
getInterceptor
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.MessageReceiverManagement
setReceiver
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ReceiverManagement
resetReceiver
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConfigurationSupport
configure, getConfiguration
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.EndpointSupport
getEndpoint
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ProtocolDescriptionSupport
getProtocolDescription
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncInvokerSupport
setInvoker
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConnectionInvokerSupport
setConnectionInvoker
 

Constructor Detail

ClientChannel

public ClientChannel(Endpoint endpoint,
                     ProtocolFactory protocolFactory,
                     ReferenceBuilder refBuilder,
                     long timeout)

ClientChannel

public ClientChannel(Endpoint endpoint,
                     ProtocolFactory protocolFactory,
                     ReferenceBuilder refBuilder)
Method Detail

request

public Message request(Message message)
                throws ProtocolException,
                       java.lang.IllegalStateException
This synchronous method sends the specified request to the server, and waits for a response from the server for the length of the timeout property.

Here is a sample of how to use the request() method.


 Message response =
     interactionServerProtocol.request(requestAgentLogin);
 
The time to wait for a response is configured during channel creation or by using the setTimeout() method. This request() method only waits for messages with a reference ID, so if the message doesn't support referencing then a null value is returned immediately.

Because this method will not return events for a request that does not include the ReferenceId attribute, it is better to use the send() method for those requests.

Specified by:
request in interface RequestChannel
Parameters:
message - the request to be sent to the server.
Returns:
Response message or null in the following cases:
  • No response message was received within the configured timeout.
  • The connection was closed before receiving any response message.
  • The connection is closed but the channel state was still considered Open when the message was tried to be sent.
  • Unsolicited message as response.
Throws:
java.lang.IllegalArgumentException - if request message is null, message belongs to other protocol
ChannelClosedOnSendException - If channel is not in the Opened state.
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
ChannelClosedOnRequestException - If channel has been closed before an answer is received. You can check Throwable.getCause() to find out the reason why channel has been closed.
java.lang.IllegalStateException - if channel is not in an appropriate state (e.g. closed)
See Also:
request(Message, long)

request

public Message request(Message message,
                       long timeout)
                throws ProtocolException
This synchronous method sends the specified request to the server and waits for a response from the server for the length of the specified timeout value. See request(Message).

Specified by:
request in interface RequestChannel
Parameters:
message - the request to be sent to the server.
timeout - time to waitResponse for response.
Returns:
Response message or null in the following cases:
  • No response message was received within the configured timeout.
  • The connection was closed before receiving any response message.
  • The connection is closed but the channel state was still considered Open when the message was tried to be sent.
  • Unsolicited message as response.
Throws:
java.lang.IllegalArgumentException - if request message is null, message belongs to other protocol.
ChannelClosedOnSendException - if channel is not in the Opened state.
ChannelClosedOnRequestException - If channel has been closed before an answer is received. You can check Throwable.getCause() to find out the reason why channel has been closed.
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.

beginRequest

public RequestFuture beginRequest(Message message)
                           throws ProtocolException
Starts request and exits. To waitResponse for request result you can use either returned RequestFuture or endRequest(RequestFuture) method.

Specified by:
beginRequest in interface RequestChannel
Parameters:
message - message to request with.
Returns:
future object which allow to get result of the request.
Throws:
java.lang.IllegalArgumentException - if request message is null, message belongs to other protocol
RequestUnReferenceableException - if argument message is not instance of Referenceable.
ChannelClosedOnSendException - if channel is not in the Opened state.
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
See Also:
AbstractChannel.setTimeout(long), requestAsync(Message, Object, CompletionHandler), endRequest(RequestFuture)

requestAsync

public <A> void requestAsync(Message message,
                             A attachment,
                             CompletionHandler<Message,? super A> handler)
                  throws ProtocolException
Starts request and exits. Server response, cancellation or timeout notification will be delivered to the specified callback.

Specified by:
requestAsync in interface RequestChannel
Type Parameters:
A - user callback attachment parameter type.
Parameters:
message - message to request with.
attachment - user defined parameter for the "callback".
handler - user defined "callback" interface for notification about server response.
Throws:
java.lang.IllegalArgumentException - if result message is null.
RequestUnReferenceableException - if argument message is not instance of Referenceable.
java.lang.IllegalArgumentException - if callback is not null, but protocol has no positive timeout set.
ChannelClosedOnSendException - if channel is not in the Opened state.
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
See Also:
AbstractChannel.setTimeout(long), requestAsync(Message, Object, CompletionHandler, long)

requestAsync

public <A> void requestAsync(Message request,
                             A attachment,
                             CompletionHandler<Message,? super A> handler,
                             long timeout)
                  throws ProtocolException,
                         java.lang.IllegalStateException
Starts request and exits. Server response, cancellation or timeout notification will be delivered to the specified callback.

Specified by:
requestAsync in interface RequestChannel
Type Parameters:
A - user callback attachment parameter type.
Parameters:
request - message to request with.
attachment - user defined parameter for the "callback".
handler - user defined "callback" interface for notification about server response.
timeout - timeout waiting for server response before request invalidation.
Throws:
java.lang.IllegalArgumentException - if request message is null
RequestUnReferenceableException - if argument message is not instance of Referenceable
java.lang.IllegalArgumentException - if callback is not null, but provided timeout is not positive value, message belongs to other protocol
ChannelClosedOnSendException - if channel is not in the Opened state.
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.IllegalStateException - if channel is in inappropriate state to execute the request

endRequest

public Message endRequest(RequestFuture future)
                   throws ProtocolException
Tries to finish request started with beginRequest().

Specified by:
endRequest in interface RequestChannel
Parameters:
future - future object obtained from beginRequest()
Returns:
Response message or null in the following cases:
  • No response message was received within the configured timeout.
  • The connection was closed before receiving any response message.
  • The connection is closed but the channel state was still considered Open when the message was tried to be sent.
  • Unsolicited message as response.
Throws:
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
ChannelClosedOnRequestException - ​If channel has been closed before an answer is received. You can check Throwable.getCause() to find out the reason why channel has been closed.
See Also:
beginRequest(Message)

endRequest

public Message endRequest(RequestFuture future,
                          long timeout)
                   throws ProtocolException
Tries to finish request started with beginRequest(Message).

Specified by:
endRequest in interface RequestChannel
Parameters:
future - future object obtained from beginRequest(Message).
timeout - timeout to waitResponse for response.
Returns:
Response message or null in the following cases:
  • No response message was received within the configured timeout.
  • The connection was closed before receiving any response message.
  • The connection is closed but the channel state was still considered Open when the message was tried to be sent.
  • Unsolicited message as response.
Throws:
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
ChannelClosedOnRequestException - ​If channel has been closed before an answer is received. You can check Throwable.getCause() to find out the reason why channel has been closed.
See Also:
request(Message, long)

setState

protected void setState(ChannelState newState,
                        ConnectionClosedEvent closedEvent)
Overrides:
setState in class DuplexChannel

doBeginRequest

@Deprecated
protected final MessageCorrelator.MessageEntry doBeginRequest(Message message)
                                                       throws ProtocolException
Deprecated. 

Throws:
ProtocolException
See Also:
doBeginRequest(Message, Object, CompletionHandler, long)

doBeginRequest

protected final <A> MessageCorrelator.MessageEntry doBeginRequest(Message message,
                                                                  A attachment,
                                                                  CompletionHandler<Message,? super A> handler,
                                                                  long timeout)
                                                       throws ProtocolException
Throws:
ProtocolException

doRequest

protected Message doRequest(Message message,
                            long timeout)
                     throws ProtocolException
Throws:
ProtocolException

getCopyResponse

public boolean getCopyResponse()
Description copied from interface: RequestChannel
Is response to request() copied to receive queue.

Specified by:
getCopyResponse in interface RequestChannel
Returns:
true if response goes to receive queue

setCopyResponse

public void setCopyResponse(boolean copyResponse)
Description copied from interface: RequestChannel
Is response to request() copied to receive queue.

Specified by:
setCopyResponse in interface RequestChannel
Parameters:
copyResponse - true if response goes to receive queue

setHandshakeUnsolicitedEventsPassLimit

@Deprecated
public void setHandshakeUnsolicitedEventsPassLimit(int maxNum)
Deprecated. 


onUnexpectedHandshakeMessage

protected void onUnexpectedHandshakeMessage(Message request,
                                            Message response,
                                            java.util.Queue<Message> msgsBuffer)
                                     throws ProtocolException
Event handler for unexpected messages on handshake procedure, which are not accepted by the RegistrationHandler, but not caused handshake exception.
Registration handler allows custom handling of such kind of messages in specific protocols.
Particular protocol may override this method and, taking into account things like:do After successful handshake procedure finish, messages from the result messages queue will be passed to the MessageHandler.

Parameters:
request - the registration request
response - the unexpected message
msgsBuffer - the result messages queue
Throws:
RegistrationException
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.

getReferenceBuilder

public ReferenceBuilder getReferenceBuilder()
Specified by:
getReferenceBuilder in interface Protocol

throwOnUnReferenceableRequest

protected void throwOnUnReferenceableRequest(Message request)

setEndpoint

public void setEndpoint(Endpoint endpoint)
Description copied from class: AbstractChannel
Sets channel endpoint.

Specified by:
setEndpoint in interface EndpointSupport
Overrides:
setEndpoint in class AbstractChannel
Parameters:
endpoint - endpoint
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.

setAddressResolver

public void setAddressResolver(SocketAddressResolver resolver)
                        throws ChannelNotClosedException
Sets custom SocketAddress resolver reference.

Parameters:
resolver - reference to custom implementation of SocketAddress resolver.
Throws:
ChannelNotClosedException - if channel is not in Closed state.
See Also:
setAddressResolverParams(String), setAddressResolverParams(Map), DefaultSocketAddressResolver

setAddressResolverParams

public void setAddressResolverParams(java.lang.String parameters)
                              throws ProtocolSecurityException,
                                     java.lang.IllegalArgumentException
Sets parameters for SocketAddress resolver.

Parameters:
parameters - parameters to be passed to the SocketAddress resolver with resolution request.
Throws:
ChannelNotClosedException - if channel is not in Closed state.
ProtocolSecurityException - if protocol failed to instantiate custom address resolver by given class name.
java.lang.IllegalArgumentException - in case of parsing exception of the given parameters string.
See Also:
setAddressResolver(SocketAddressResolver), DefaultSocketAddressResolver.setResolver(SocketAddressResolver)

setAddressResolverParams

public void setAddressResolverParams(java.util.Map<java.lang.String,java.lang.Object> parameters)
                              throws ChannelNotClosedException,
                                     ProtocolSecurityException,
                                     java.lang.IllegalArgumentException
Sets parameters for SocketAddress resolver.

Parameters:
parameters - parameters to be passed to the SocketAddress resolver with resolution request.
Throws:
ChannelNotClosedException - if channel is not in Closed state.
ProtocolSecurityException - if protocol failed to instantiate custom address resolver by given class name.
java.lang.IllegalArgumentException - if parameters value is null or contains invalid value with the resolver override keys.
See Also:
setAddressResolver(SocketAddressResolver), DefaultSocketAddressResolver.setResolver(SocketAddressResolver)

open

public void open(long timeout)
          throws RegistrationException,
                 ProtocolException,
                 ChannelNotClosedException,
                 java.lang.InterruptedException
Description copied from class: DuplexChannel
Opens the channel by opening underlying connection including protocol specific handshake procedure using specified protocol timeout value.
Timeout can be set to following values:

Specified by:
open in interface Channel
Overrides:
open in class DuplexChannel
Parameters:
timeout - time to waitResponse for the connection
Throws:
ProtocolSecurityException - if any security problems occurs on a channel
ProtocolIOException - will thrown if connection IO exception occurs
ProtocolTimeoutException - if channel wasn't opened for the specified time
ChannelEmergencyClosedException - if channel was closed while opening
RegistrationException - if there is an error related to registration procedure like server error about wrong client name, user password, etc
RegistrationTimeoutException - if connection to server was established but handshake procedure has timed out
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.IllegalArgumentException - when channel endpoint is not assigned
ChannelNotClosedException - if channel is not in Closed state
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.
java.lang.InterruptedException - in case the open operation was interrupted.
See Also:
DuplexChannel.open()

beginOpen

public void beginOpen()
               throws ProtocolException
Description copied from class: DuplexChannel
Begins channel opening asynchronously.

Specified by:
beginOpen in interface AsyncChannel
Overrides:
beginOpen in class DuplexChannel
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.
ProtocolException - in case of problems establishing connection

openAsync

public java.util.concurrent.Future<ChannelOpenedEvent> openAsync(java.lang.Long timeout)
Description copied from class: DuplexChannel
Method is asynchronous. It will start connection sequence and return. Whether connection is established on return is not specified.

Overrides:
openAsync in class DuplexChannel
Parameters:
timeout - it specifies channel opening timeout in milliseconds.
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.

openAsync

public <A> void openAsync(long timeout,
                          CompletionHandler<java.util.EventObject,A> handler,
                          A attachment)
Description copied from interface: AsyncChannelOperations
Open channel asynchronously.

Specified by:
openAsync in interface AsyncChannelOperations
Overrides:
openAsync in class DuplexChannel
Parameters:
timeout - operation timeout in milliseconds. Timeout will cancel the opening.
handler - success/fail result handling.

close

public void close(boolean force)
           throws ProtocolException,
                  java.lang.InterruptedException,
                  java.lang.IllegalStateException
Description copied from class: DuplexChannel
Closes channel synchronously.

Overrides:
close in class DuplexChannel
Parameters:
force - if this flag is true then sending messages from queue will be canceled and channel will be closed immediately
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.
ProtocolTimeoutException - if channel wasn't closed for the specified time (when force == false)
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - in case the close operation was interrupted.
java.lang.IllegalStateException - Exception will not be thrown in current implementation even if the channel is closed.

close

public void close(long timeout)
           throws ProtocolException,
                  java.lang.InterruptedException,
                  java.lang.IllegalStateException
Description copied from class: DuplexChannel
Closes channel synchronously.

Specified by:
close in interface Channel
Overrides:
close in class DuplexChannel
Parameters:
timeout - time in milliseconds
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.
ProtocolTimeoutException - if channel wasn't closed for the specified time
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - in case the close operation was interrupted.
java.lang.IllegalStateException - exception will not be thrown in current implementation.

beginClose

public void beginClose()
                throws java.lang.IllegalStateException
Description copied from class: DuplexChannel
Closes channel asynchronously.

Specified by:
beginClose in interface AsyncChannel
Overrides:
beginClose in class DuplexChannel
Throws:
java.lang.IllegalStateException - Exception will not be thrown in current implementation even if the channel is closed.

closeAsync

public <A> void closeAsync(long timeout,
                           CompletionHandler<ChannelClosedEvent,A> handler,
                           A attachment)
Description copied from interface: AsyncChannelOperations
Open channel asynchronously.

Specified by:
closeAsync in interface AsyncChannelOperations
Overrides:
closeAsync in class DuplexChannel
Parameters:
timeout - operation timeout in milliseconds. Timeout do not cancel the closing and do not close forcly the channel.
handler - success/fail result handling.
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.

closeAsync

public java.util.concurrent.Future<ChannelClosedEvent> closeAsync()
Description copied from class: DuplexChannel
Close the channel asynchronously.

Note: It hasn't related with the channel timeout. Use the future.get() with a timeout instead.

Overrides:
closeAsync in class DuplexChannel
Throws:
DisabledMethodException - if it the method disableConnectionOperations has been called before. And channel's open/close operations can't be called directly.

onOpen

protected void onOpen()
               throws ProtocolException
Description copied from class: DuplexChannel
This method is called when channel is opened and just about to call event handler. You usually will need to add some logic here and call super.onOpen() at the end of your method. Please note, that calling super.onOpen() on the thread other then open() was called will most probably result in deadlock for some scenarios (like calling close() inside of onChannelOpened())

Overrides:
onOpen in class DuplexChannel
Throws:
ProtocolException - if there are problems during post open operations (e.g. registration)

onSend

protected void onSend(Message message)
               throws ProtocolException
Description copied from class: DuplexChannel
Gives to subclass a chance to modify message before sending it to remote party.

Overrides:
onSend in class DuplexChannel
Parameters:
message - Message to modify
Throws:
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.

onReceiveMessage

protected void onReceiveMessage(Message msg)
Description copied from class: DuplexChannel
Gives to subclass a chance to perform some operations on incoming message arrival before delivering it to connection user code. We don't use AsyncInvoker here, because the message handling in this class probably doesn't worth it - this method is quick and shouldn't load connection thread too much. But if this method is overridden in some classes and contains some long-running logic, consider using AsyncInvoker

Overrides:
onReceiveMessage in class DuplexChannel
Parameters:
msg - received message

setRegistrationHandler

@Deprecated
protected void setRegistrationHandler(ClientChannel.RegistrationHandler handler)
Deprecated. 

Sets registration handler. This method can have side effects if called after superclass' open() and is not thread safe. Intended usage is in overridden open() method like following:
 public void open(long timeout)
 {
     setRegistrationHandler(new MyHandler());
     super.open(timeout);
 }
 

Parameters:
handler - registration handler
See Also:
ClientChannel.ClientHandshakeStep, ClientChannel.BasicClientHandshakeStep, setHandshakePhase(ClientHandshakeStep)

setHandshakePhase

protected void setHandshakePhase(ClientChannel.ClientHandshakeStep handshakeStart)
Initializes. This method can have side effects if called after superclass' open() and is not thread safe.

Parameters:
handshakeStart - registration procedure entry point.
See Also:
ClientChannel.ClientHandshakeStep, ClientChannel.BasicClientHandshakeStep

setHandshakeFinished

protected void setHandshakeFinished(java.lang.Throwable exception)

fireUnsolicitedEvents

public void fireUnsolicitedEvents()

submitRegMessage

@Deprecated
protected Message submitRegMessage(Message regMessage)
                            throws ProtocolException,
                                   java.lang.InterruptedException
Deprecated. 

This method supports the most of the scenarios for client registration. But in some edge cases it probably should be overridden. One such example is server doesn't reply on registration messages. Please note, that registration message can be null in some rare cases. That means we don't send anything but rather wait for message from server.

Parameters:
regMessage - registration message (from RegistrationHandler)
Returns:
Response message or null in the following cases:
  • No response message was received within the configured timeout.
  • The connection was closed before receiving any response message.
  • The connection is closed but the channel state was still considered Open when the message was tried to be sent.
  • Unsolicited message as response.
Throws:
ProtocolException - in the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - thread is interrupted waiting for response.

getOpenTimeoutException

protected ProtocolException getOpenTimeoutException(long timeout)
Creates open timeout exception and logs it.

Overrides:
getOpenTimeoutException in class DuplexChannel
Parameters:
timeout - timeout was used to wait
Returns:
timeout exception

disableConnectionOperations

public ConnectionOperations disableConnectionOperations()
Disable connection operations.

It disable all open operation in the channel through the channel. After call of the method there is only one possibility to open the channel through the returned AsyncOpen implementation. The method can be called once. The following calls will throw DisabledMethodException

Returns:
interface that provide exclusive connections operations API.
Throws:
DisabledMethodException - if it has been called before.

getInvoker

@Deprecated
public AsyncInvoker getInvoker()
Deprecated. For internal use only!

For internal use only!

Overrides:
getInvoker in class AbstractChannel
Returns:
channel invoker

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.