Class HTTPFabricConnection
Main class which provides API for working with Fabric.
Functional overview
The API methods, which return a remote object got from server side, use callback functions or promises to pass the returned object to a user. If callback function passed to the method it will be called when method completed, otherwise promise will be returned. This callback has the following definition:callback(response, sequenceId, success)Parameter 'response' contains the object returned from server side. Parameter 'sequenceId' contains the sequence identifier of this method call. This sequence identifier is returned by the API method called by a user. Parameter 'success' is set to 'true' if the server response is got. If there is no response from the server then the callback is called after the timeout (30 seconds by default) is expired. In this case 'response' parameter is set to 'null', 'success' parameter is set to 'false'. In case of an exception occurred at server side, 'response' contains the exception object. Method Utilities#isException can be used to check 'response'. If an exception handler is set in HTTPFabricConnection constructor then the exception is passed to this handler too. Promise success callback has the following definition
function(response)where response object contains of the following fields
{ id, // sequence id of request returned, // returned object success, // always true in success response timeouted // always false in success response }Promise error callback has the following definition
function(error)where error object contains of the following fields
{ id, // sequence id of request returned, // returned object, exception in error callback success, // always false in error response timeouted // true if request was time outed }All exception objects has the following signature
{ '@type' : Exception, detailMessage : detailMessage, cause : cause };Here is a user code example.
// Create connection fabricConnection = new HTTPFabricConnection(); fabricConnection.authenticate('user', 'password', 'Quilt').then((response) => { // Login to Fabric fabricConnection.open().then((response) => { // Call API methods var moderator = fabricConnection.getModerator(); var helloId = moderator.lookupComponentByName('Hello', userCallback); var worldId = moderator.lookupComponentByName('World', userCallback); var names = {}; names[helloId] = 'Hello'; names[worldId] = 'World'; function userCallback(response, sequenceId, success) { if (! success) { alert('Timeout expired for call ' + names[sequenceId]); return; } if (Utilities.isException(response)) { alert('Exception for call ' + names[sequenceId] + ': ' + response.detailMessage); return; } alert('Response object for call ' + names[sequenceId] + ': ' + Utilities.encode(response)); } }) });The response object's type for the API method is specified in its documentation. 'Utilities.encode()' method can be used to see all the object fields in JSON representation.
Defined in: <D:\Programs\Neeve\Projects\NeeveBuild\stjsapi/src/main/webapp/js\HTTPFabricConnection.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
HTTPFabricConnection(user, password, exceptionHandler, url)
Creates a connection to Fabric.
|
Method Attributes | Method Name and Description |
---|---|
void |
acknowledgeEvent(event, withSourceData, action, recipientId, eventScope, timeToLive)
Raises the acknowledgement for the specified event.
|
void |
addEventCache(eventFilter, maxSize, thresholdAction)
Adds a new event cache of
maxSize size for the events which
satisfy the specified simple eventFilter . |
void |
bindProducerFor(eventId)
Binds the specified event identifier in Fabric, so that it can then be
raised via this connection.
|
void |
clear()
Clears this connection parameters.
|
void |
close()
Performs logout procedure and closes the connection to Fabric.
|
Constraint.DateRange |
createDateRangeConstraint(rangeName, minValue, maxValue, eventScope)
Creates a new date range constraint for this Fabric connection.
|
Constraint.Domain |
createDomainConstraint(domainName, eventScope)
Creates a new domain constraint for this Fabric connection.
|
EventConsumer |
createEventAsyncConsumer(consumerName, listener, eventFilter, eventSelector, eventScope, noLocal)
Asynchronously creates a new asynchronous event consumer and adds this
consumer to the connection dispatcher.
|
EventConsumer |
createEventConsumer(consumerName, listener, eventFilter, eventSelector, eventScope, noLocal)
Asynchronously creates a new event consumer and adds this consumer to the
connection's dispatcher.
|
EventReceiver |
createEventReceiver(receiverName, eventFilter, eventSelector, eventScope, noLocal, receiver)
Asynchronously creates a new event receiver and adds this receiver to the
connection dispatcher.
|
Constraint.NumericRange |
createNumericRangeConstraint(rangeName, minValue, maxValue, eventScope)
Creates a new numeric range constraint for this Fabric connection.
|
EventConsumer |
createRequestConsumer(consumerName, listener, eventScope)
Asynchronously creates a new request event consumer and adds this consumer
to the connection dispatcher.
|
Accessor.Service |
createServiceAccessor(serviceType, serviceName)
Asynchronously creates a service accessor object which can be used to
access the specified service.
|
Accessor.Service |
createServiceAccessorForNode(nodeName, serviceType, serviceName)
Asynchronously creates a service accessor object which can be used to
access the specified service.
|
Promise |
createSLSession(callback)
Asynchronously creates a semantic language session to the current node of
the connection.
|
Promise |
createSLSessionForNode(nodeName, callback)
Asynchronously creates a semantic language session to the node with the
specified name.
|
void |
Asynchronously creates a new user in Fabric with the specified user object:
{ name, password, description, domain, vCard}.
|
<static> void |
HTTPFabricConnection.createUser(name, password, description, domain, callback, callback)
This method should be considered as deprecated due to its limitations and exists for backward compatibility.
|
void |
dropConsumer(consumerName)
Drops the consumer with the specified name from the dispatcher.
|
void |
dropDateRangeConstraint(rangeName, eventScope)
Drops the specified constraint of this Fabric connection
|
void |
dropDomainConstraint(domainName, eventScope)
Drops the specified domain constraint of this Fabric connection
|
void |
dropEventAsyncConsumer(consumerName)
Drops the asynchronous event consumer with the specified name from the
dispatcher
|
void |
dropEventConsumer(consumerName)
Drops the event consumer with the specified name from the dispatcher
|
void |
dropEventReceiver(receiverName, withoutInvoke)
Drops the receiver with the specified name from the dispatcher
|
void |
dropNumericRangeConstraint(rangeName, eventScope)
Drops the specified constraint of this Fabric connection
|
void |
dropRequestConsumer(consumerName)
Drops the request consumer with the specified name from the dispatcher
|
<static> String |
HTTPFabricConnection.getAcceptorName()
Returns HTTP Acceptor name
|
Security.ClientId |
Returns the client id of this fabric connection
|
void |
getConnectionReopenInterval(connectionReopenInterval)
Returns a time (in milliseconds) between failed connection reopen attempts.
|
Constraint.DateRange |
getDateRangeConstraint(rangeName, eventScope)
Returns the date constraint with the specified name and scope
|
String |
Returns the description of this fabric connection
|
Constraint.Domain |
getDomainConstraint(domainName, eventScope)
Returns the domain constraint with the specified name and scope
|
Accessor.DropBox |
Returns new Accessor.DropBox object which can be used for using dropbox features.
|
EventConsumer |
getEventAsyncConsumer(consumerName)
Finds and returns the asynchronous event consumer with the specified name
|
EventConsumer |
getEventConsumer(consumerName)
Finds and returns the event consumer with the specified name
|
EventDatagramFactory |
Returns new EventDatagramFactory object which is used for creating
events and acknowledgements.
|
EventReceiver |
getEventReceiver(receiverName)
Finds and returns the receiver with the specified name
|
String |
Returns the event scope of the connection.
|
FabricAddress |
Returns the Fabric address of the connection.
|
Accessor.File |
Returns new Accessor.File object which can be used for getting files
base64 content and raising file events.
|
String |
Returns the identifier of http-session generated for this connection.
|
Moderator |
Returns new Moderator object which can be used for getting different
information about the connected Fabric node, its consumer, producers and
so on.
|
String |
getName()
Returns the name of this fabric connection.
|
void |
Returns a time (in milliseconds) how long connection will work without reverse connection.
|
Constraint.NumericRange |
getNumericRangeConstraint(rangeName, eventScope)
Returns the numeric constraint with the specified name and scope
|
<static> Array |
HTTPFabricConnection.getOrganizations()
Returns the organizations list of the Fabric Runtime
|
void |
Returns a number of reconnect attempts that will be made by the Fabric Connection in a case of the remote node disconnection.
|
void |
Returns a time (in milliseconds) between successive reconnect attempts that will be made by the Fabric Connection
in a case of the remote node disconnection.
|
EventConsumer |
getRequestConsumer(consumerName)
Finds and returns the request consumer with the specified name
|
void |
Returns a time (in milliseconds) between unsuccessful requests retries.
|
void |
Returns a count of unsuccessful request retries.
|
void |
getReverseConnectionHoldTimeout(reverseConnectionHoldTimeout)
Returns a time (in milliseconds) how long reverse connection will hold by the server.
|
<static> String |
HTTPFabricConnection.getRuntimeVersion()
Returns the version of the Fabric Runtime
|
SecurityManager |
Returns new SecurityManager object which can be used for managing users,
groups and other security stuff.
|
void |
Returns a time (in milliseconds) how long server connection lost will not reported.
|
int |
Returns the TimeZone Offset of this fabric connection in minutes
|
Accessor.Service |
getServiceAccessor(service)
Asynchronously creates an accessor object to the specified service.
|
Accessor.Service |
getServiceAccessorForNode(nodeName, service)
Asynchronously creates an accessor object to the specified service on the
specified Fabric node.
|
ConnectionStatistics |
Returns fabric conneciton statistics.
|
<static> String |
HTTPFabricConnection.getSysplexDomain()
Returns the Domain of the Fabric Runtime
|
int |
Returns the http timeout.
|
string |
Returns the TimeZone Display Name of this fabric connection in minutes
|
String |
getType()
Returns the type of the connection.
|
String |
getURL()
Returns the URL of the connection.
|
String |
Returns the login name for this connection
|
<static> String |
HTTPFabricConnection.getVersion()
Returns the version of the Javascript API
|
boolean |
Checks if this connection has some bound event identifiers
(see HTTPFabricConnection#bindProducerFor).
|
<static> Promise |
HTTPFabricConnection.initStatics(url)
Asynchronously initializes sysplex domain, runtime version and organizations list.
|
boolean |
isBoundEventId(eventId)
Checks if the specified event identifier is bound in Fabric
(see HTTPFabricConnection#bindProducerFor).
|
boolean |
isOpened()
Returns whether this connection is opened or not.
|
undefined |
Returns if api key authentication should be used or not.
|
String |
Returns a list of all the event identifiers bound in Fabric for this
connection (see HTTPFabricConnection#bindProducerFor).
|
void |
listEventAsyncConsumers(callback)
Asynchronously returns a list of all the event async consumers of this
connection.
|
void |
listEventConsumers(callback)
Asynchronously returns a list of all the event consumers of this
connection.
|
void |
listEventReceivers(callback)
Asynchronously returns a list of all the event receivers of this
connection.
|
<static> void |
HTTPFabricConnection.listOrganizations(callback, url)
Asynchronously gets organizations list.
|
void |
listRequestConsumers(callback)
Asynchronously returns a list of all the request consumers of this
connection.
|
Promise |
open(noReverse)
Asynchronously opens this connection to Fabric.
|
void |
ping(callback)
Keeps the http-connection alive.
|
Promise |
raiseAcknowledgement(event, eventScope, timeToLive)
Raises the specified acknowledgement event.
|
Promise |
raiseAdvisory(event, eventScope)
Raises the specified advisory event.
|
Promise |
raiseDirectRequest(consumerName, request, timeout, callback)
Asynchronously sends the specified request event directly to the specified
request consumer and waits for its reply for
timeout
milliseconds. |
Promise |
raiseEvent(event, eventScope, timeToLive)
Raises the specified event.
|
void |
raiseException(event, eventScope)
Raises the specified exception event.
|
void |
raiseRequest(request, eventScope, distributionStrategy, matchStrategy, timeout, callback)
Asynchronously raises the specified non-direct request event to Fabric and
waits for its acknowledgement for
timeout milliseconds. |
void |
removeEventCache(eventFilter)
Removes the event cache defined by the specified simple event filter.
|
void |
setClientId(clientId)
Sets the client id (see Security.ClientId) for the connection if
it is not opened.
|
void |
setConnectionReopenInterval(connectionReopenInterval)
Sets a time (in milliseconds) between failed connection reopen attempts.
|
void |
setDateRangeConstraint(range)
Updates the date constraint of this Fabric connection with the
specified one.
|
void |
setDescription(description)
Sets the description of the connection if it is not opened.
|
void |
setDomainConstraint(domain)
Updates the domain constraint of this Fabric connection with the specified
one.
|
void |
setEventScope(eventScope)
Sets the event scope of this connection
(see HTTPFabricConnection#getEventScope for possible event scope
values).
|
void |
setLeasePeriod(lease)
Sets the lease period for this connection.
|
void |
setLinkMode(range)
Set the open or close link modes.
|
void |
setName(newName)
Sets the name of the connection if it is not opened.
|
void |
setNoReverseConnectionTimeout(noReverseConnectionTimeout)
Sets a time (in milliseconds) how long connection will work without reverse connection.
|
void |
setNumericRangeConstraint(range)
Updates the numeric constraint of this Fabric connection with the
specified one.
|
void |
setReconnectAttempts(reconnectAttempts)
Sets a number of reconnect attempts that will be made by the Fabric Connection in a case of the remote node disconnection.
|
void |
setReconnectInterval(reconnectInterval)
Sets a time (in milliseconds) between successive reconnect attempts that will be made by the Fabric Connection
in a case of the remote node disconnection.
|
void |
setRetriesInterval(retriesInterval)
Sets a time (in milliseconds) between unsuccessful requests retries.
|
void |
setRetriesMaxCount(retriesMaxCount)
Sets a count of unsuccessful request retries.
|
void |
setReverseConnectionHoldTimeout(reverseConnectionHoldTimeout)
Sets a time (in milliseconds) how long reverse connection will hold by the server.
|
void |
setServerConnectionLostSilentTimeout(serverConnectionLostSilentTimeout)
Sets a time (in milliseconds) how long server connection lost will not reported.
|
void |
setTimeout(timeout)
Sets the maximal time for waiting of a server reply.
|
void |
setUseApiKeyAuthentication(useApiKeyAuthentication)
Sets should be used api key authentication or not.
|
void |
touch(callback)
Sets the access time for this connection to the current time.
|
void |
unbindProducerFor(eventId)
Unbinds the specified event identifier from Fabric, so that it can't be
raised via this connection.
|
// Create connection fabricConnection = new HTTPFabricConnection(); // Login to Fabric fabricConnection.authenticate(username, password, applicationName).then(function(response){ // authentication is ok, open the connection fabricConnection.open().then(function(){ // connection successfully opened }, function(error) { // connection open error }); }, function(error) { // authentication error });
- Parameters:
- {String} user
- The user name which will be used to login to Fabric and in each message to ensure that it belongs to an authorized user.
- {String} password
- The password which will be used to login to Fabric and in each message to ensure that it belongs to an authorized user.
- {Function} exceptionHandler
- If function callback used then exceptionHandler will be called with the exception object
returned from the server for a previously called method. This
parameter can be omitted in which case an exception is passed to
the callback function if it is specified as the last parameter of the
called method. The exception object can have
detailMessage
field, in which case it contains the error message. Otherwise the exception object is the error message itself. Here is an example of a correct exception handler:var alertExceptionHandler = function(exception) { if ((exception != null) && (exception.detailMessage != null)) alert(exception.detailMessage); else alert("ERROR: " + exception); }
If function callback not specified and promise is used, exceptionHandler will be called if some errors occurred in resolve/reject methods. - {String} url
- The url to be used in fabric requests. If this parameter is not null,
then a cross-domain mechanism is used for all the requests. Otherwise
all the requests are sent to the current host and an ajax mechanism
is used. The port can be not specified, in which case the default one
(port 80) is used. When specified the port should be separated from
the host by ':'.
Examples:
'streamscape.com:8080', 'streamscape.com', window.location.hostname + ':81', 'streamscape.com:' + window.location.port
- Parameters:
- {Event.AbstractDataEvent} event
- The event for which the acknowledgement should be raised
- {boolean} withSourceData
- If this flag is true, then the acknowledgement will be filled with some data from the specified source event
- {String} action
- The action which is performed when the acknowledgement is raised.
Possible values are:
- ACKNOWLEDGE: The event is acknowledged and no further action is taken. If the event is queued up it is left on the queue.
- ACKNOWLEDGE_AND_FORWARD: The event is acknowledged and is
forwarded to its next destination specified by
forwardTo
field. - ACKNOWLEDGE_AND_DISCARD: The event is acknowledged and then discarded. If the event is queued up it is removed from the queue.
- ACKNOWLEDGE_AND_EXPIRE: The event is acknowledged and then marked as expired. The actual usage is implementation specific.
- ACKNOWLEDGE_UNDELIVERED: The event is acknowledged with UNDELIVERED status.
- ACKNOWLEDGE_AND_SUSPEND: The event is acknowledged and the
recipient should suspend all further processing of
this
eventId
. The status does specify how or when processing resumes. - RESCIND: Resets the event's status to whatever it was prior to any processing, essentially marking the event as new. This action results in the event potentially being re-processed.
- RESCIND_AND_FORWARD: Resets the event's status to whatever it
was prior to any processing and forwards it to it's
next destination specified by
forwardTo
field. - RESCIND_AND_DISCARD: Resets the event's status to whatever it was prior to any processing and marks it as discard-able. A discard-able datagram should be removed from the processing component or queue.
- {String} recipientId
- The identifier of the acknowledgement recipient.
- {String} eventScope
- The scope of the acknowledgement to be raised. See HTTPFabricConnection#getEventScope for possible event scope values.
- {number} timeToLive
- The time interval (in milliseconds) within that the acknowledgement persists (in a queue, cache or fabric buffer) before it will be discarded. Non-positive value implies ignoring of this parameter.
maxSize
size for the events which
satisfy the specified simple eventFilter
. When the cache
threshold (maxSize
) is reached, thresholdAction
is performed for any new event. The simple filter is any filter which
doesn't contain '&' symbol. In case of a complex filter user can divide it
into several simple ones and create a separate cache for each simple
filter.
- Parameters:
- {String} eventFilter
- The event filter of the cache. This filter is actually an event id mask, which defines what event id can have a cached event. See HTTPFabricConnection#createEventConsumer for details.
- {number} maxSize
- The cache size (maximum number of events contained in the cache). A negative value means an unlimited cache.
- {String} thresholdAction
- The action which is performed when the cache threshold
(
maxSize
) is reached. Possible values are:- LRE_DISCARD: LRE (Least Recent Event) is removed from the cache and the new event is put to it
- MRE_DISCARD: The new event (which is MRE - Most Recent Event) is discarded, i.e. is not put to the cache
FabricUnboundEventException
.
- Parameters:
- {String} eventId
- The event identifier to be bound in Fabric
- Parameters:
- {String} rangeName
- The name of the constraint to be created
- {String} minValue
- The left boundary of the range constraint to be created. The date format is 'MM.DD.YYYY HH:mm:ss'.
- {String} maxValue
- The right boundary of the range constraint to be created. The date format is 'MM.DD.YYYY HH:mm:ss'.
- {String} eventScope
- The data scope of the constraint to be created. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Returns:
- The created constraint object
- Parameters:
- {String} domainName
- The name of the domain constraint to be created
- {String} eventScope
- The data scope of the domain constraint to be created. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Returns:
- The created domain constraint object
The consumer should have a unique name within Fabric. This name can be used then to get this consumer. The created consumer consumes all the events which come within its
eventScope
and within
the scope of this connection, and satisfy its eventFilter
,
eventSelector
and noLocal
flag (if it is true
then 'LOCAL' scope is subtracted from the consumer scope).Event filter is used to filter the events by event id. Event selector is used to select only necessary events depending on the values of its specific properties.
When an event satisfies all the consumer conditions, then the consumer listener's
onEvent()
method is called for this event.
- Parameters:
- {String} consumerName
- The name of the consumer, which should be unique within Fabric
- {EventListener} listener
- The listener associated with the consumer. All the consumed events
are processed by the listener's
onEvent()
method. - {String} eventFilter
- The event filter of the consumer. This filter is actually an event id mask, which defines what event id can have a consumed event. See HTTPFabricConnection#createEventConsumer for details.
- {String} eventSelector
- The event selector of the consumer. Selector allows to specify almost any conditions on event properties' values which should be satisfied for an event to be consumed. See Selector for details.
- {String} eventScope
- The scope of the created consumer. See HTTPFabricConnection#getEventScope for possible event scope values.
- {boolean} noLocal
- If this flag is true, then the created consumer doesn't consume local events (events raised by this connection itself).
- Returns:
- {Promise} promise success response callback will be called with created consumer object on success, otherwise error callback will be called
eventScope
and within the scope of this connection, and
satisfy its eventFilter
, eventSelector
and
noLocal
flag (if it is true then 'LOCAL' scope is subtracted
from the consumer scope).Event filter is used to filter the events by event id. Event selector is used to select only necessary events depending on the values of its specific properties.
When an event satisfies all the consumer conditions, then the consumer listener's
onEvent()
method is called for this event.
- Parameters:
- {String} consumerName
- The name of the consumer, which should be unique within Fabric
- {EventListener} listener
- The listener associated with the consumer. All the consumed events
are processed by the listener's
onEvent()
method. - {String} eventFilter
- The event filter of the consumer. This filter is actually an
event id mask, which defines what event id can have a consumed
event.
Event id is divided into parts by symbol '.'. Symbols '*', '#', '!', '&' have special meaning for an event filter. Symbol '*' means any non-empty set of characters within the current part of the event id. Symbol '#' means any non-empty set of any characters (including event id parts delimiter '.'). Symbol '!' means any set of characters within the current part of the event id except the set of characters coming after this symbol till the end of the part. Symbol '&' means that this filter is satisfied by both: event ids, which satisfy the filter expression before this symbol; and event ids, which satisfy the filter expression after this symbol.
Examples:
Filter Satisfies Not satisfies event.http.cli* 'event.http.clip', 'event.http.client', 'event.http.cliaaa', 'event.http.cli123' 'event.http.cli', 'event.http.client.me' event.http.* 'event.http.a', 'event.http.abcd', 'event.http.client', 'event.http.abbccc' 'event.http.', 'event.http.a.b' event.http.cli# 'event.http.clip', 'event.http.client', 'event.http.cli.a', 'event.http.client.me' 'event.http', 'event.http.cli' event.http.!cli* 'event.http.cli', 'event.http.client.me', 'event.http.cli.a', 'event.http.cli.me' 'event.http.client', 'event.http.cli1' event.http.!cli# 'event.http.cli', 'event.http.clnt', 'event.http.clnt.me', 'event.http' 'event.http.clip', 'event.http.cli.me' event.http.c*&event.http.j# 'event.http.cl', 'event.http.client', 'event.http.js', 'event.http.java', 'event.http.j.ack', 'event.http.j.ack.ok' 'event.http.c', 'event.http.c.you', 'event.http.client.me', 'event.http', 'event.http.j' # any event id no event ids - {String} eventSelector
- The event selector of the consumer. Selector allows to specify almost any conditions on event properties' values which should be satisfied for an event to be consumed. See Selector for details.
- {String} eventScope
- The scope of the created consumer. See HTTPFabricConnection#getEventScope for possible event scope values.
- {boolean} noLocal
- If this flag is true, then the created consumer doesn't consume local events (events raised by this connection itself).
- Returns:
- {Promise} promise success response callback will be called with created consumer object on success, otherwise error callback will be called
The created receiver receives all the events which come within its
eventScope
and within the scope of this connection, and
satisfy its eventFilter
, eventSelector
and
noLocal
flag (if it is true then 'LOCAL' scope is subtracted
from the consumer scope).Event filter is used to filter the events by event id. Event selector is used to select only necessary events depending on the values of its specific properties.
When an event satisfies all the receiver conditions, it is put to the queue of this receiver. User can call
receive()
or
receiveNoWait()
method to get this event from the queue.
- Parameters:
- {String} receiverName
- The name of the receiver, which should be unique within Fabric
- {String} eventFilter
- The event filter of the receiver. This filter is actually an event id mask, which defines what event id can have a received event. See HTTPFabricConnection#createEventConsumer for details.
- {String} eventSelector
- The event selector of the receiver. Selector allows to specify almost any conditions on event properties' values which should be satisfied for an event to be received. See Selector for details.
- {String} eventScope
- The scope of the created receiver. See HTTPFabricConnection#getEventScope for possible event scope values.
- {boolean} noLocal
- If this flag is true, then the created receiver doesn't receive local events (events raised by this connection itself).
- receiver
- Returns:
- The receiver object. In case of some error at server side the exception handler is called and this receiver object becomes invalid. Calling of its asynchronous methods will cause exceptions
- Parameters:
- {String} rangeName
- The name of the constraint to be created
- {number} minValue
- The left boundary of the range constraint to be created
- {number} maxValue
- The right boundary of the range constraint to be created
- {String} eventScope
- The data scope of the constraint to be created. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Returns:
- The created constraint object
eventScope
and within the scope of this connection, but
without 'LOCAL' scope if noLocal
flag is set to true.When the request satisfies these conditions, the consumer listener's
onEvent()
method is called for this request. This method
returns a reply event for the processed request. The reply is then
returned to the entity which has raised the request (see
HTTPFabricConnection#raiseRequest method).
- Parameters:
- {String} consumerName
- The name of the consumer, which should be unique within Fabric
- {EventListener} listener
- The listener associated with the consumer. The consumed requests
are processed by the listener's
onEvent()
method, which returns a reply event for each request event. - {String} eventScope
- The scope of the created consumer. See HTTPFabricConnection#getEventScope for possible event scope values. It can't have 'LOCAL' value.
- Returns:
- {Promise} promise success response callback will be called with created consumer object on success, otherwise error callback will be called
createServiceAccessor(null, serviceType, serviceName)
.
- Parameters:
- {String} serviceType
- The service type
- {String} serviceName
- The service name
- Returns:
- The accessor object. In case of some error at server side the exception handler is called and this accessor object becomes invalid. In this case calling of its asynchronous methods will cause exceptions.
- Parameters:
- {String} nodeName
- The node name where the service is looked up
- {String} serviceType
- The service type
- {String} serviceName
- The service name
- Returns:
- The accessor object. In case of some error at server side the exception handler is called and this accessor object becomes invalid. In this case calling of its asynchronous methods will cause exceptions.
createSLSession(null)
.
The created session object is passed to the specified
callback
function when it is returned from server side or
to promise callback if callback function not specified.
- Parameters:
- {Function} callback
- The callback function called with the created session object. (See HTTPFabricConnection for a callback description). Callback object type: 'SLSession'.
- Returns:
- {Promise} if callback not specified
The created session object is passed to the specified
callback
function when it is returned from server side.
- Parameters:
- {String} nodeName
- The name of the node to which the session is created.
- {Function} callback
- The callback function called with the created session object. (See HTTPFabricConnection for a callback description). Callback object type: 'SLSession'.
- Returns:
- {Promise} if callback not specified
User
object is passed to the specified callback
function or
to promise callback when it is returned from server side.
(See SecurityManager#updateUser for 'Security.User' class description).NOTE: The created user can't send any requests to Fabric because it doesn't have a fabric connection. Use SecurityManager#createUser and SecurityManager#lookupUser to get a fully functional
Security.User
object.
- Parameters:
- {String} user.name
- Required. The name of the user to be created
- {String} user.password
- The password of the user to be created
- {String} user.description
- The description of the user to be created
- {String} user.domain
- The domain in which the user should be created. This parameter can be omitted in which case the default domain is used.
- {Object} user.vcard
- vCard as per RFC 6350
User
object is passed to the specified callback
function or
to promise callback when it is returned from server side.
(See SecurityManager#updateUser for 'Security.User' class description).NOTE: The created user can't send any requests to Fabric because it doesn't have a fabric connection. Use SecurityManager#createUser and SecurityManager#lookupUser to get a fully functional
Security.User
object.
- Parameters:
- {String} name
- The name of the user to be created
- {String} password
- The password of the user to be created
- {String} description
- The description of the user to be created
- {String} domain
- The domain in which the user should be created. This parameter can be omitted in which case the default domain is used.
- {Function} callback
- The callback function called with the created user object.
(See HTTPFabricConnection for a callback description).
Callback object type: Security.User.
Note that the created user can't send any requests to Fabric
because it doesn't have a fabric connection. Use
SecurityManager#createUser and
SecurityManager#lookupUser to get a fully functional
Security.User
object. If not specified promise callbacks will be used. - callback
- Parameters:
- {String} consumerName
- The name of the consumer to be dropped
- Parameters:
- {String} rangeName
- The name of the constraint to be dropped
- {String} eventScope
- The data scope of the constraint to be dropped. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Parameters:
- {String} domainName
- The name of the domain constraint to be dropped
- {String} eventScope
- The data scope of the domain constraint to be dropped. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Parameters:
- {String} consumerName
- The name of the consumer to be dropped
- Parameters:
- {String} consumerName
- The name of the consumer to be dropped
- Parameters:
- {String} receiverName
- The name of the receiver to be dropped
- withoutInvoke
- Parameters:
- {String} rangeName
- The name of the constraint to be dropped
- {String} eventScope
- The data scope of the constraint to be dropped. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Parameters:
- {String} consumerName
- The name of the consumer to be dropped
- Returns:
- Acceptor name
- Returns:
- The client id of this connection
- Parameters:
- {number} connectionReopenInterval
- the value to be set in milliseconds.
- Parameters:
- {String} rangeName
- The name of the date constraint to be returned
- {String} eventScope
- The data scope of the constraint to be returned. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Returns:
- The constraint of this connection, which has the specified name and scope
- Returns:
- The description of this connection
- Parameters:
- {String} domainName
- The name of the domain constraint to be returned
- {String} eventScope
- The data scope of the domain constraint to be returned. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Returns:
- The domain constraint of this connection, which has the specified name and scope
- Returns:
- A new Accessor.DropBox object
- Parameters:
- {String} consumerName
- The name of the consumer to be returned
- Returns:
- The found consumer or null if no consumer is found
- Parameters:
- {String} consumerName
- The name of the consumer to be returned
- Returns:
- The found consumer or null if no consumer is found
- Returns:
- A new EventDatagramFactory object
- Parameters:
- {String} receiverName
- The name of the receiver to be returned
- Returns:
- The found receiver or null if no receiver is found
- INHERITED: For the connection the actual event scope will be taken 'OBSERVABLE'. For consumers, receivers, caches and so on the actual event scope will be taken equal to the event scope of the connection to which they belong.
- LOCAL: Events raised by this connection can only be seen and processed by this connection itself. The connection is not bound to Fabric and may not see or process any external events.
- OBSERVABLE: The connection is bound to Fabric node. This allows all other components within the node runtime (JVM) to see and process its events. Likewise this connection can see and process events raised by any other component with a similar scope. Note that it is possible for components with a higher scope, such as 'GLOBAL' to act as "routers", thereby connecting the component to external nodes and clients.
- GLOBAL: In addition to being an 'OBSERVABLE' event, the event is propagated to all Fabric nodes that are interested in consuming it. Likewise event consumers with a scope of 'GLOBAL' may receive and process events from other nodes with the same scope.
- CLUSTER: Reserved for cluster operations and components that function in a symmetric cluster.
- Returns:
- The event scope of the connection (it can be null if it is not opened yet)
- Returns:
- The address of this connection component in Fabric if the connection is already opened and null otherwise.
- Returns:
- A new Accessor.File object
- Returns:
- Http-session identifier
- Returns:
- A new Moderator object
- Returns:
- The name of this connection (it can be null if it is not opened yet)
- Returns:
- number in milliseconds
- Parameters:
- {String} rangeName
- The name of the numeric constraint to be returned
- {String} eventScope
- The data scope of the constraint to be returned. Possible values: 'LOCAL' (the current component scope), 'OBSERVABLE' (the current Fabric node scope), 'GLOBAL' (the whole Fabric scope).
- Returns:
- The constraint of this connection, which has the specified name and scope
- Returns:
- organizations list
Value 0
means that the connection will not attempt to reconnect.
Negative value means that the connection will try to reconnect infinitely (until successful connecting).
Default value is -1
that means to reconnect infinitely.
- Returns:
- the number of reconnect attempts.
Default value is 2000 millisecond
.
- Returns:
- number time interval (in milliseconds) between reconnect attempts.
- Parameters:
- {String} consumerName
- The name of the consumer to be returned
- Returns:
- The found consumer or null if no consumer is found
- Parameters:
- a
- time in milliseconds.
- Returns:
- number max count
- Parameters:
- reverseConnectionHoldTimeout
- Returns:
- the time (in milliseconds) how long reverse connection will hold by the server.
- Returns:
- Runtime version
- Returns:
- A new SecurityManager object
- Returns:
- number time (in milliseconds)
- Returns:
- The timeZone offset in minutes (i.e. -180);
- Parameters:
- {String} service
- The full name of the service: <service type>.<service name>
- Returns:
- The accessor object. In case of some error at server side the exception handler is called and this accessor object becomes invalid. In this case calling of its asynchronous methods will cause exceptions.
- Parameters:
- {String} nodeName
- The node name where the dataspace is looked up
- {String} service
- The full name of the service: <service type>.<service name>
- Returns:
- The accessor object. In case of some error at server side the exception handler is called and this accessor object becomes invalid. In this case calling of its asynchronous methods will cause exceptions.
- Returns:
- {ConnectionStatistics}
- Returns:
- Domain name
- Returns:
- {int} timeout in milliseconds
- Returns:
- The timeZone Display Name in minutes (i.e. Moscow Standard Time);
- Returns:
- The type of this connection which is 'Client_HTTP'.
- Returns:
- The URL of this connection.
- Returns:
- The name of the user who is logged in to Fabric via this connection
- Returns:
- Javascript API version
- Returns:
- True if this connection has some bound event ids, false otherwise
- Parameters:
- url
- Returns:
- {Promise}
- Parameters:
- {String} eventId
- The event identifier to be checked
- Returns:
- boolean if
eventId
is bound for this connection in Fabric, and false otherwise
- Returns:
- True if this connection is opened and false otherwise
- Returns:
- {boolean|*}
- Returns:
- A list of the bound event ids for this connection
callback
function when it is returned from server side.
- Parameters:
- {Function} callback
- The callback function called with the list of consumers. (See HTTPFabricConnection for a callback description). Callback object type: {String[]}.
callback
function when it is returned from server side.
- Parameters:
- {Function} callback
- The callback function called with the list of consumers. (See HTTPFabricConnection for a callback description). Callback object type: {String[]}.
callback
function when it is returned from server side.
- Parameters:
- {Function} callback
- The callback function called with the list of receivers. (See HTTPFabricConnection for a callback description). Callback object type: {String[]}.
- Parameters:
- {Function} callback
- The callback function called with the organizations list. (See HTTPFabricConnection for a callback description). Callback object type: String[].
- url
callback
function when it is returned from server side.
- Parameters:
- {Function} callback
- The callback function called with the list of consumers. (See HTTPFabricConnection for a callback description). Callback object type: {String[]}.
Note that the connection is opened asynchronously, which means that it remains not opened in the calling method and all the upper methods in the calling hierarchy. Any synchronous methods which return the parameters, set after the connection opening, can't be called right after the
open()
call. However all the asynchronous methods can be
called safely in any place after open()
. For calling
synchronous methods promise callbacks should be used. Here
is an example:
function exceptionHandler(exception) { console.log("Unhandled Exception during open callbacks"); console.log(exception); } function onEvent(event) { alert(Utilities.encode(event)); } connection = new HTTPFabricConnection(exceptionHandler); connection.open().then(function(response){ var time = (new Date()).getTime(); var uniqueName = 'TestConsumer_' + time + '_' + Math.random(); var listener = new EventListener(onEvent); consumer = connection.createEventAsyncConsumer(uniqueName, listener, 'event.test.notify', null, 'INHERITED', false); consumer.start(); }, function(exception) { console.log("Open failed"); console.log(exception); });In case of an error an exception object is returned from the server it will be passed to promise exception handler.
- Parameters:
- {boolean} noReverse
- If this parameter is specified and set to true, then no reverse connection is opened with Fabric. It means that no consumers can be created because consumers get events via a reverse connection from Fabric. If no events consuming is needed then this parameter should be set to true to save cpu and memory resources.
- Returns:
- {Promise}
callback
function when it is returned from server side. If the server doesn't
respond during the timeout (see HTTPFabricConnection.setTimeout)
then a callback function is called with 'null' response and 'success' set
to 'false': callback(null, sequenceId, false)
.
- Parameters:
- {Function} callback
- The callback function called with 'AVAILABLE' string. (See HTTPFabricConnection for a callback description). Callback object type: {String}.
- Parameters:
- {Event.AcknowledgementEvent} event
- The acknowledgement event to be raised
- {String} eventScope
- The scope of the event to be raised. See HTTPFabricConnection#getEventScope for possible event scope values.
- {number} timeToLive
- The time interval (in milliseconds) within that the event persists (in a queue, cache or fabric buffer) before it will be discarded. Non-positive value implies ignoring of this parameter.
- Returns:
- {Promise} if callback not specified
- Parameters:
- {advisory} event
- The advisory event to be raised.
- {String} eventScope
- The scope of the event to be raised. See HTTPFabricConnection#getEventScope for possible event scope values.
- Returns:
- {Promise}
timeout
milliseconds. Its request event id should be bound in Fabric
(see HTTPFabricConnection#bindProducerFor).The reply event for this request is passed to the specified
callback
function when it is returned from server side.
If callback
not specified promise is returned.
- Parameters:
- {String} consumerName
- The name of the consumer to which the request is raised
- {Event.AbstractDataEvent} request
- The request event to be sent
- {number} timeout
- The time (in milliseconds) of waiting for the reply. Non-positive value is considered as eternal timeout.
- {Function} callback
- The callback function called with the reply event object. (See HTTPFabricConnection for a callback description). Callback object type: Event.AbstractDataEvent
- Returns:
- {Promise} if callback not specified
- Parameters:
- {Event.AbstractDataEvent} event
- The event to be raised.
- {String} eventScope
- The scope of the event to be raised. See HTTPFabricConnection#getEventScope for possible event scope values.
- {number} timeToLive
- The time interval (in milliseconds) within that the event persists (in a queue, cache or fabric buffer) before it will be discarded. Non-positive value implies ignoring of this parameter.
- Returns:
- {Promise} if callback not specified
- Parameters:
- {Event.ExceptionEvent} event
- The exception event to be raised
- {String} eventScope
- The scope of the event to be raised. See HTTPFabricConnection#getEventScope for possible event scope values.
timeout
milliseconds. Its
event id should be bound in Fabric (see
HTTPFabricConnection#bindProducerFor). The request is
raised as a common event and can be consumed by several
non-direct consumers. Consumers process this event and then raise an
acknowledgement event to Fabric. Only one acknowledgement is returned from
the server according to the specified distributionStrategy
.
If matchStrategy
is equal to 'REPLY_WITH_CORRELATION_ID' then
only acknowledgements with the correlationId
equal to the
request correlationId
are considered. The acknowledgement
eventId
should be equal to the request replyTo
field if the latter is present.The acknowledgement event for this request is passed to the specified
callback
function when it is returned from server side.
- Parameters:
- {Event.AbstractDataEvent} request
- The request event to be raised
- {String} eventScope
- The scope of the event to be raised. See HTTPFabricConnection#getEventScope for possible event scope values.
- {String} distributionStrategy
- The strategy which defines to what consumer or consumers the
request event will be distributed and what reply will be returned
to the caller. Possible values are:
- AUCTION: The first reply received from all the appropriate consumers is returned to the caller
- FAIR: Not supported currently
- WEIGHTED: Not supported currently
- CYCLIC: Not supported currently
- {String} matchStrategy
- The strategy which defines what consumers' acknowledgements fit
the raised request. Possible values are:
- REPLY_TO: The acknowledgement
eventId
should be equal to the requestreplyTo
field if the latter is present. - REPLY_WITH_CORRELATION_ID: Except the
replyTo
field thecorrelationId
of the acknowledgement should be equal to the requestcorrelationId
.
- REPLY_TO: The acknowledgement
- {number} timeout
- The time (in milliseconds) of waiting for the reply. Non-positive value is considered as eternal timeout.
- {Function} callback
- The callback function called with the acknowledgement event. (See HTTPFabricConnection for a callback description). Callback object type: Event.AcknowledgementEvent
- Parameters:
- {String} eventFilter
- The event filter of the cache. This filter is actually an event id mask, which defines what event id can have a cached event. See HTTPFabricConnection#createEventConsumer for details.
- Parameters:
- {Security.ClientId} clientId
- The client id to be set for this connection
- Returns:
- The new client id if the connection isn't opened or null otherwise
- Parameters:
- {number} connectionReopenInterval
- the value to be set in milliseconds.
- Parameters:
- {Constraint.DateRange} range
- The date constraint to be set for this Fabric connection
- Parameters:
- {String} description
- The description to be set for this connection
- Returns:
- The new description if the connection is not opened and the description is not more than 20 symbols long or null otherwise
- Parameters:
- {Constraint.Domain} domain
- The domain constraint to be set for this Fabric connection
- Parameters:
- {String} eventScope
- The event scope to be set for this connection
- Returns:
- The new event scope if the connection is not opened or null otherwise.
- Parameters:
- {number} lease
- The lease period in milliseconds which should be set for this connection. The default value is 300000 (5 minutes).
The possible values for open link mode are:
- START: A new Fabric connection is started for this user
- ATTACH: This session is attached to the already existing Fabric connection for this user
- STOP: When close() is called the Fabric connection is stopped and removed
- DETACH: When close() is called this session is detached and the Fabric connection is kept opened
connection.setLinkMode('ATTACH'); connection.setLinkMode('DETACH');
- Parameters:
- {Constraint.DateRange} range
- The date constraint to be set for this Fabric connection
- Parameters:
- {String} newName
- The name to be set for this connection
- Returns:
- The new connection name if it is not opened or null if it is
Value less or equals to 0 means that connection will work without reverse connection. Default value is 5 minutes.
- Parameters:
- {number} noReverseConnectionTimeout
- the value to be set.
- Parameters:
- {Constraint.NumericRange} range
- The numeric constraint to be set for this Fabric connection
Value 0
means that the connection will not attempt to reconnect.
Negative value means that the connection will try to reconnect infinitely (until successful connecting).
Default value is -1
that means to reconnect infinitely.
- Parameters:
- {number} reconnectAttempts
- the value to be set.
Default value is 2000 millisecond
.
- Parameters:
- {number} reconnectInterval
- the value to be set.
- Parameters:
- {number} retriesInterval
- the value to be set.
- Parameters:
- {number} retriesMaxCount
- the value to be set.
- Parameters:
- {number} reverseConnectionHoldTimeout
- the value to be set.
- Parameters:
- {number} serverConnectionLostSilentTimeout
- the value to be set.
callback(null, sequenceId, false)
.If callback is not specified promise error callback will be called with timeout exception and timeouted flag set to true. Default value is 30000 milliseconds.
- Parameters:
- {number} timeout
- The maximal time in milliseconds for which a server reply is waited
- Parameters:
- useApiKeyAuthentication
callback
function when it is returned from server side. If the server doesn't
respond during the timeout (see HTTPFabricConnection.setTimeout)
then a callback function is called with 'null' response and 'success' set
to 'false': callback(null, sequenceId, false)
.
- Parameters:
- {Function} callback
- The callback function called with an empty string answer. (See HTTPFabricConnection for a callback description). Callback object type: {String}.
FabricUnboundEventException
.
- Parameters:
- {String} eventId
- The event identifier to be unbound from Fabric