Platform SDK Java 8.5 API Reference

com.genesyslab.platform.management.protocol
Class MessageServerProtocol

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
              extended by com.genesyslab.platform.management.protocol.MessageServerProtocol
All Implemented Interfaces:
AsyncChannel, AsyncChannelOperations, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport, InputChannel, InterceptorSupport, LogMessageFilterSupport, MessageReceiver, MessageReceiverManagement, OutputChannel, Protocol, ProtocolDescriptionSupport, Receiver, ReceiverManagement, RequestChannel, MessageServerProtocolHandshakeOptions

@ProtocolDescription.Tag(sdkName="Management",
                         protocolName="MessageServer")
public class MessageServerProtocol
extends ClientChannel
implements MessageServerProtocolHandshakeOptions

Use a MessageServerProtocol object to establish communication between a client application and Genesys Message Server.

Here is a sample of how to establish communication with Message Server:

 MessageServerProtocol msgProtocol =
   new MessageServerProtocol(
     new Endpoint(
       msgEPName,
       msgHost,
       msgPort));
 msgProtocol.setClientName(clientName);
 msgProtocol.setClientId(clientDbid);
 msgProtocol.setClientType(clientType);
 msgProtocol.setClientHost(clientHost);
 msgProtocol.open();
 

Sample code for sending log message to the Message Server:

 RequestLogMessage request = RequestLogMessage.create();
 request.setEntryId(30302);
 request.setEntryText("alarm from test app");
 request.setEntryCategory(LogCategory.Application);
 request.setLevel(LogLevel.Alarm);
 msgProtocol.send(request);
 

When you are finished communicating with the server, you can close the channel like this:

 msgProtocol.close();
 

Note: Starting from Platform SDK 8.5.0 version, main protocol channel classes (including MessageServerProtocol) are no longer "final".
It helps with applications unit testing. At the same time it opens access and allows to override protocols internal protected staff from custom child classes.
Changes or extensions of the protocols functionality in child classes must be done very carefully with clear understanding of affected components and functionality.
Also, protected PSDK methods and elements are not a part of public API, and may be a subject for changes without special notice. So, application, which uses or overrides internal/protected staff, may have compatibility issues on PSDK update.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.ClientChannel
ClientChannel.BasicClientHandshakeStep, ClientChannel.ClientHandshakeStep, ClientChannel.RegistrationHandler, ClientChannel.SimpleRegistrationHandler
 
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
MessageServerProtocol()
          Creates a new MessageServerProtocol object.
MessageServerProtocol(Endpoint endpoint)
          Creates a new MessageServerProtocol object.
MessageServerProtocol(Endpoint endpoint, long timeout)
          Creates a new MessageServerProtocol object.
 
Method Summary
protected  Connection createConnection(Endpoint endpoint)
           
 java.lang.String getClientHost()
          Returns client host.
 int getClientId()
          Gets identification number of log records' source.
By design it is DBID of client CME application.
 java.lang.String getClientName()
          Returns the Message Server client name for connection handshake procedure.
 int getClientType()
          Returns type of application to be used in the logs.
protected  void onOpen()
          This method is called when channel is opened and just about to call event handler.
protected  void onReceiveMessage(Message message)
          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.
 void setClientHost(java.lang.String host)
          Sets client host to pass to server.
This value will be automatically attached to LogMessage before send if message does not declare own value.
 void setClientId(int clientId)
          Deprecated.  
 void setClientId(java.lang.Integer clientId)
          Sets identification number of log records' source.
By design it is DBID of client CME application.
This value will be automatically attached to all LogMessages before send if it is not null.
 void setClientName(java.lang.String clientName)
          Sets the Message Server client name for connection handshake procedure.
 void setClientType(int clientType)
          Sets type of application to be used in the logs.
 
Methods inherited from class com.genesyslab.platform.commons.protocol.ClientChannel
beginClose, beginOpen, beginRequest, close, close, closeAsync, closeAsync, disableConnectionOperations, doBeginRequest, doBeginRequest, doRequest, endRequest, endRequest, fireUnsolicitedEvents, getCopyResponse, getInvoker, getOpenTimeoutException, getReferenceBuilder, onUnexpectedHandshakeMessage, open, openAsync, openAsync, request, request, requestAsync, requestAsync, setAddressResolver, setAddressResolverParams, setAddressResolverParams, setCopyResponse, setEndpoint, setHandshakeFinished, setHandshakePhase, setHandshakeUnsolicitedEventsPassLimit, setRegistrationHandler, setState, submitRegMessage, throwOnUnReferenceableRequest
 
Methods inherited from class com.genesyslab.platform.commons.protocol.DuplexChannel
addListener, applyConfiguration, cancelCloseTimeout, cancelOpenTimeout, clearInput, close, closeAsync, createChannelClosedEvent, 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

MessageServerProtocol

public MessageServerProtocol()
Creates a new MessageServerProtocol object.


MessageServerProtocol

public MessageServerProtocol(Endpoint endpoint)
Creates a new MessageServerProtocol object.

Parameters:
endpoint - The endpoint (server) you wish to connect to.

MessageServerProtocol

public MessageServerProtocol(Endpoint endpoint,
                             long timeout)
Creates a new MessageServerProtocol object.

Parameters:
endpoint - The endpoint (server) you wish to connect to.
timeout - default channel timeout.
Method Detail

getClientId

public int getClientId()
Gets identification number of log records' source.
By design it is DBID of client CME application.

Specified by:
getClientId in interface MessageServerProtocolHandshakeOptions
Returns:
ClientId or 0 if it is not set

setClientId

public void setClientId(int clientId)
Deprecated. 

See Also:
setClientId(Integer)

setClientId

public void setClientId(java.lang.Integer clientId)
Sets identification number of log records' source.
By design it is DBID of client CME application.
This value will be automatically attached to all LogMessages before send if it is not null.

Specified by:
setClientId in interface MessageServerProtocolHandshakeOptions
Parameters:
clientId - client identification number

getClientName

public java.lang.String getClientName()
Returns the Message Server client name for connection handshake procedure. Usually it represents client application name.

Specified by:
getClientName in interface MessageServerProtocolHandshakeOptions
Returns:
client name
See Also:
setClientName(String)

setClientName

public void setClientName(java.lang.String clientName)
Sets the Message Server client name for connection handshake procedure. Usually it represents client application name.

Specified by:
setClientName in interface MessageServerProtocolHandshakeOptions
Parameters:
clientName - client name

getClientType

public int getClientType()
Returns type of application to be used in the logs.

Specified by:
getClientType in interface MessageServerProtocolHandshakeOptions
Returns:
application type
See Also:
setClientType(int)

setClientType

public void setClientType(int clientType)
Sets type of application to be used in the logs.

Specified by:
setClientType in interface MessageServerProtocolHandshakeOptions
Parameters:
clientType - application type

getClientHost

public java.lang.String getClientHost()
Returns client host.

Specified by:
getClientHost in interface MessageServerProtocolHandshakeOptions
Returns:
client host
See Also:
setClientHost(String), RequestLogMessage.setClientHost(String)

setClientHost

public void setClientHost(java.lang.String host)
Sets client host to pass to server.
This value will be automatically attached to LogMessage before send if message does not declare own value.

Specified by:
setClientHost in interface MessageServerProtocolHandshakeOptions
Parameters:
host - client host
See Also:
RequestLogMessage.setClientHost(String)

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 ClientChannel
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 message)
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 ClientChannel
Parameters:
message - received message

createConnection

protected Connection createConnection(Endpoint endpoint)
Overrides:
createConnection in class DuplexChannel

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 ClientChannel
Throws:
ProtocolException - if there are problems during post open operations (e.g. registration)

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.