CZMQCommunicatorFactory

Name

CZMQCommunicatorFactory -- Communicator factory for ZeroMQ

Synopsis


#include <CZMQCommunicatorFactory.h>

class CZMQCommunicatorFactory : public CCommunicatorFactory
{
public:
    CZMQCommunicatorFactory();

    virtual CTransport* createFanoutTransport(int endpointId);
    virtual CTransport* createFanoutClient(int endpointId, int clientId);
    virtual CTransport* createFanInSource(int endpointId) ;
    virtual CTransport* createFanInSink(int endpointId);
    virtual CTransport* createOneToOneSource(int endpointId);
    virtual CTransport* createOneToOneSink(int endpointid);

    std::string getUri(int endpointId);

};

        

DESCRIPTION

This is a factory specialized for the ZeroMQ communications system. See CCommunicatorFactory for more information. This manpage will only describe the ZeroMQ (ZMQ) specific information about this factory.

Native ZMQ specifies endpoints as URI's The URI's describe the communcations mechanism using the URI protocol to specify its own transport mechanism (e.g. tcp or inproc etc.) and the remainder of the URI to specify transport specific information. For example, tcp://somehost.net:1234 specifies a TCP/IP port on smoehost.net port number 1234. inproc://myendpoint specifies a process internal communication transport named myendpoint.

This rich space of URIs must, in some way be mapped to factory endpoint ids, which are integer (and back for that matter). The ZMQ factory does this by allowing the user to specify end point mapping files. Three endpoint mapping files can be specified and all are read allowing endpoints to be user specific, project specific and run specific. The end point files are:

Only the files you need must actually exist (the ZMQ_SERVICES environment variable need not be defined), however at least one endpoint file must exist for the factory to function. See ENDPOINT FILE FORMAT for the format of these endpoint files.

ZMQ factory creational method map as follows to ZMQ sockets:

createFanoutTransport

Creates a ZMQ_ROUTER socket as a server.

createFanoutClient

Creates a ZMQ_DEALER socket as a client.

createFanInSource

Creates a ZMQ_PUSH socket as a client.

createFanInSink

Creates a ZMQ_PULL socket as a server.

createOneToOneSource

Creates a ZMQ_PUSH socket as a client.

createOnToOneSink

Creates a ZMQ_PULL socket as a server.

To support special needs, the factory adds the method getUri. This method takes an integer endpoint id as a parameter and returns an std::string containing the Uri that corresponds to that end point.

Any use of an endpoint id that does not have a mapping (including calls to getUri) results in a std::invalid_argument exception.

ENDPOINT FILE FORMAT

Endpoint files are used to create a correspondence between integer endpointId values and ZMQ endpoint Uris. These files are textual. Leading and trailing whitespace characters on each line are ignored. Empty lines are ignored. Lines whose first non-whitespace character is # are ignored as well.

All of these make it possible for you to create readable and well commented endpoint files.

Each line that is not ignored must have two fields. The first field is an integer endpoint id. The second field is a string that specifies the URI that endpoint Id corresponds to.