Interface MessageDispatchManager


  • public interface MessageDispatchManager
    • Method Detail

      • dispatch

        java.util.List<java.lang.String> dispatch​(java.lang.String project,
                                                  java.lang.String messageHandler,
                                                  java.util.Properties filterParams)
        Sends a message to a message handler in a project. The message handler can either be in the Gateway, a client, or Perspective session.

        You can add optional properties using the filterParams Properties object. For example, to deliver messages to clients that have a user logged in named Bob, you would configure the filterParams like so:
        Properties filterParams = new Properties();
        filterParams.setProperty(MessageDispatchManager.SCOPE_KEY, MessageDispatchManager.SCOPE_CLIENT_ONLY); filterParams.setProperty(MessageDispatchManager.USER_KEY, "Bob");


        If you do not want to pass any filtering properties, just pass in an empty Properties object.
        Parameters:
        project - The project name. This value is required.
        messageHandler - The message handler name. This value is required.
        filterParams - See notes above.
        Returns:
        A String List of all the systems that should receive the message, based on the filterParams. This list can include both clients and the Gateway. This list will NOT contain the recipients forwarded to the Perspective module. An item in the list is formatted like so: [type=Client,sessionId=55488AF6,clientAddress=127.0.0.1,clientHostName=localhost,project=SomeProject, messageHandler=MyHandler,filterParams={scope=CG, hostName=localhost}]
      • dispatch

        java.util.List<java.lang.String> dispatch​(java.lang.String project,
                                                  java.lang.String messageHandler,
                                                  org.python.core.PyDictionary messagePayload,
                                                  java.util.Properties filterParams)
        Sends a message to a message handler in a project. The message handler can either be in the Gateway or in a client.

        You can add optional properties using the filterParams Properties object. For example, to deliver messages to clients that have a user logged in named Bob, you would configure the filterParams like so:
        Properties filterParams = new Properties();
        filterParams.setProperty(MessageDispatchManager.SCOPE_KEY, MessageDispatchManager.SCOPE_CLIENT_ONLY); filterParams.setProperty(MessageDispatchManager.USER_KEY, "Bob");


        If you do not want to pass any filtering properties, just pass in an empty Properties object.

        This version of the function passes a PyDictionary object, which you can add items that can be read by the receiving message handler script.

        PyDictionary object example
        PyDictionary messagePayload = new PyDictionary(new PyObject[] {new PyString("name"), new PyString("Bob"), new PyString("age"), new PyInteger(31) });

        Receiving message handler script (note that the dictionary delivered to the message handler is always called 'messagePayload')
        print(messagePayload['name'] # prints "Bob"
        Parameters:
        project - The project name. This value is required.
        messageHandler - The message handler name. This value is required.
        messagePayload - See notes above.
        filterParams - See notes above.
        Returns:
        A String List of all the systems that should receive the message, based on the filterParams. This list can include both clients and the Gateway. An item in the list is formatted like this example: [type=Client,sessionId=55488AF6,clientAddress=127.0.0.1,clientHostName=localhost,project=SomeProject, messageHandler=MyHandler,filterParams={scope=CG, hostName=localhost}]
      • dispatchRequest

        void dispatchRequest​(java.lang.String project,
                             java.lang.String messageHandler,
                             org.python.core.PyDictionary messagePayload,
                             java.util.Properties params,
                             MessageResultHandler resultHandler)
        Dispatches a "request", which is a message that expects a result. It is expected that the message is handled asynchronously, and the result is communicated back through the result handler.
        If the params specifies a remote gateway target, the request will go through the gateway network, otherwise it will be handled locally. Currently requests cannot propagate to clients.
        Parameters:
        project - The project name. This value is required.
        messageHandler - The message handler name. This value is required.
        messagePayload - See notes for dispatch.
        params - Similar to parameters on dispatch, but without all of the client filtering properties.
        resultHandler - the handler that will receive the success or failure notification.