MigratoryData Client API for PHP
Developer's Guide and Reference Manual
MigratoryDataClient Class Reference

This class implements all the necessary operations for connecting to a cluster of MigratoryData servers and publishing real-time messages. More...

Public Member Functions

 MigratoryDataClient ()
 Create a MigratoryDataClient object.
 
void setEntitlementToken (String token)
 Assign an authorization token to the client. More...
 
void setConnectionTimeout (long connectionTimeoutMs)
 Define the timeout value to establish a connection with a MigratoryData server. More...
 
void setServers (List< String > servers)
 Connect to a MigratoryData server in the list provided by the argument. More...
 
String publish (MigratoryDataMessage message)
 Publish the message provided in argument. More...
 

Static Public Attributes

static final String NOTIFY_PUBLISH_OK = "NOTIFY_PUBLISH_OK"
 Indicate that the client successfully published a message. More...
 
static final String NOTIFY_PUBLISH_FAILED = "NOTIFY_PUBLISH_FAILED"
 Indicate that the client was unable to publish a message. More...
 
static final String NOTIFY_PUBLISH_DENIED = "NOTIFY_PUBLISH_DENIED"
 Indicate that the client was unable to publish a message because it is not allowed by your entitlement rules. More...
 
static final String NOTIFY_PUBLISH_NO_SUBSCRIBER = "NOTIFY_PUBLISH_NO_SUBSCRIBER"
 Indicate that the client was unable to publish a message because there is no client subscribed to the subject of the message. More...
 
static final String NOTIFY_PUBLISH_TIMEOUT = "NOTIFY_PUBLISH_TIMEOUT"
 Indicate that the client timed out when trying to get a response for a message publication. More...
 

Detailed Description

This class implements all the necessary operations for connecting to a cluster of MigratoryData servers and publishing real-time messages.

Member Function Documentation

void MigratoryDataClient.setEntitlementToken ( String  token)

Assign an authorization token to the client.

To define which users of your application have access to which subjects, you will first have to configure the parameter Entitlement in the configuration file of the MigratoryData server — see the parameter Entitlement in the MigratoryData Configuration Guide (PDF, HTML).

Then, you will have to use the entitlement-related part of the MigratoryData Extension API to allow or deny certain users to subscribe / publish to certain subjects or use the Basic entitlement mode which do not require any programming.

Note
If you configured the Basic entitlement method in your MigratoryData servers using the parameter Entitlement, then, in order to be able to publish messages, the token defined by this API method must be equal to the value of the parameter EntitlementAllowToken of your servers.
Parameters
tokenA string representing an authorization token.
void MigratoryDataClient.setConnectionTimeout ( long  connectionTimeoutMs)

Define the timeout value to establish a connection with a MigratoryData server.

Parameters
connectionTimeoutMsThe timeout value (in milliseconds) used by the client to establish a connection with a MigratoryData server; default value is 1000 milliseconds.
void MigratoryDataClient.setServers ( List< String >  servers)

Connect to a MigratoryData server in the list provided by the argument.

Parameters
serversThe addresses of the MigratoryData servers in the cluster.
Exceptions
MigratoryDataExceptionExceptions with the following error codes:
  • E_INVALID_URL_LIST
  • E_CLUSTER_MEMBERS_CONNECTION_FAILED
  • E_ENTITLEMENT_TOKEN
String MigratoryDataClient.publish ( MigratoryDataMessage  message)

Publish the message provided in argument.

Parameters
messageA MigratoryDataMessage object
Returns
A string representing the response received from the MigratoryData cluster:
  • NOTIFY_PUBLISH_OK,
  • NOTIFY_PUBLISH_FAILED,
  • NOTIFY_PUBLISH_DENIED,
  • NOTIFY_PUBLISH_NO_SUBSCRIBER, or
  • NOTIFY_PUBLISH_TIMEOUT
Exceptions
MigratoryDataExceptionExceptions with the following error codes:
  • E_MSG_NULL
  • E_MSG_FIELD_INVALID
  • E_MSG_INVALID
  • E_INVALID_SUBJECT
  • E_INVALID_PROTOCOL

Member Data Documentation

final String MigratoryDataClient.NOTIFY_PUBLISH_OK = "NOTIFY_PUBLISH_OK"
static

Indicate that the client successfully published a message.

This constant is used to indicate that the publication of a message has succeeded.

final String MigratoryDataClient.NOTIFY_PUBLISH_FAILED = "NOTIFY_PUBLISH_FAILED"
static

Indicate that the client was unable to publish a message.

This constant is used to indicate that the publication of a message has failed.

final String MigratoryDataClient.NOTIFY_PUBLISH_DENIED = "NOTIFY_PUBLISH_DENIED"
static

Indicate that the client was unable to publish a message because it is not allowed by your entitlement rules.

This constant is used to indicate that the publication of a message has failed. The publication failed because the client – identified with the token defined with the API method MigratoryDataClient.setEntitlementToken() – is not allowed to publish on the subject of the message.

final String MigratoryDataClient.NOTIFY_PUBLISH_NO_SUBSCRIBER = "NOTIFY_PUBLISH_NO_SUBSCRIBER"
static

Indicate that the client was unable to publish a message because there is no client subscribed to the subject of the message.

This constant is used to indicate that the publication of the message has failed. The publication failed because there is no client then subscribed to the subject of the message.

final String MigratoryDataClient.NOTIFY_PUBLISH_TIMEOUT = "NOTIFY_PUBLISH_TIMEOUT"
static

Indicate that the client timed out when trying to get a response for a message publication.

This constant is used to indicate that the publication of the message timeout without knowing if the message was published or not.