dxlclient.message module

The messages module contains the different types of messages that are transmitted over the Data Exchange Layer (DXL) fabric.

Event messages are sent using the dxlclient.client.DxlClient.send_event() method of a client instance. Event messages are sent by one publisher and received by one or more recipients that are currently subscribed to the Message.destination_topic associated with the event (otherwise known as one-to-many).

Request messages are sent using the dxlclient.client.DxlClient.sync_request() and dxlclient.client.DxlClient.async_request() methods of a client instance. Request messages are used when invoking a method on a remote service. This communication is one-to-one where a client sends a request to a service instance and in turn receives a response.

Response messages are sent by service instances upon receiving Request messages. Response messages are sent using the dxlclient.client.DxlClient.send_response() method of a client instance. Clients that are invoking the service (sending a request) will receive the response as a return value of the dxlclient.client.DxlClient.sync_request() method of a client instance or via the dxlclient.callbacks.ResponseCallback callback when invoking the asynchronous method, dxlclient.client.DxlClient.async_request().

ErrorResponse messages are sent by the DXL fabric itself or service instances upon receiving Request messages. The error response may indicate the inability to locate a service to handle the request or an internal error within the service itself. Error response messages are sent using the dxlclient.client.DxlClient.send_response() method of a client instance.

NOTE: Some services may chose to not send a Response message when receiving a Request. This typically occurs if the service is being used to simply collect information from remote clients. In this scenario, the client should use the asynchronous form for sending requests, dxlclient.client.DxlClient.async_request()

class dxlclient.message.ErrorResponse(request, error_code=0, error_message='')

Bases: dxlclient.message.Response

ErrorResponse messages are sent by the DXL fabric itself or service instances upon receiving Request messages. The error response may indicate the inability to locate a service to handle the request or an internal error within the service itself. Error response messages are sent using the dxlclient.client.DxlClient.send_response() method of a client instance.

Constructor parameters:

Parameters:
  • request -- The Request message that this is a response for
  • error_code -- The numeric error code
  • error_message -- The textual error message
error_code

The numeric error code for the error response

error_message

The textual error message for the error response

message_type

The numeric type of the message

class dxlclient.message.Event(destination_topic)

Bases: dxlclient.message.Message

Event messages are sent using the dxlclient.client.DxlClient.send_event() method of a client instance. Event messages are sent by one publisher and received by one or more recipients that are currently subscribed to the Message.destination_topic associated with the event (otherwise known as one-to-many).

Constructor parameters:

Parameters:destination_topic -- The topic to publish the message to
message_type

The numeric type of the message

class dxlclient.message.Message(destination_topic)

Bases: abc.ABC

The base class for the different Data Exchange Layer (DXL) message types

Constructor parameters:

Parameters:destination_topic -- The topic to publish the message to
MESSAGE_TYPE_ERROR = 3

The numeric type identifier for the ErrorResponse message type

MESSAGE_TYPE_EVENT = 2

The numeric type identifier for the Event message type

MESSAGE_TYPE_REQUEST = 0

The numeric type identifier for the Request message type

MESSAGE_TYPE_RESPONSE = 1

The numeric type identifier for the Response message type

MESSAGE_VERSION = 2
broker_ids

The set of broker identifiers that the message is to be routed to. Setting this value will limit which brokers the message will be delivered to. This can be used in conjunction with client_ids().

client_ids

The set of client identifiers that the message is to be routed to. Setting this value will limit which clients the message will be delivered to. This can be used in conjunction with broker_ids().

destination_tenant_guids

The set of tenant identifiers that the message is to be routed to. Setting this value will limit which clients the message will be delivered to. This can be used in conjunction with broker_ids() and client_ids().

destination_topic

The topic to publish the message to

message_id

Unique identifier for the message (UUID)

message_type

The numeric type of the message

other_fields

Returns a dict (dictionary) containing the set of additional fields associated with the message. These fields can be used to add "header" like values to the message without requiring modifications to be made to the payload.

payload

The application-specific payload of the message (bytes)

source_broker_id

The identifier of the DXL broker that the message's originating client is connected to (set by the initial broker)

source_client_id

The identifier of the DXL client that sent the message (set by the broker that initially receives the message)

source_tenant_guid

The tenant identifier of the DXL client that sent the message (set by the broker that initially receives the message)

version

The version of the DXL message (used to determine the features that are available)

class dxlclient.message.Request(destination_topic)

Bases: dxlclient.message.Message

Request messages are sent using the dxlclient.client.DxlClient.sync_request() and dxlclient.client.DxlClient.async_request() methods of a client instance. Request messages are used when invoking a method on a remote service. This communication is one-to-one where a client sends a request to a service instance and in turn receives a response.

Constructor parameters:

Parameters:destination_topic -- The topic to publish the request to
message_type

The numeric type of the message

reply_to_topic

The topic that the Response to this Request will be sent to

service_id

The identifier of the service that this request will be routed to. If an identifier is not specified, the initial broker that receives the request will select the service to handle the request (round-robin by default).

class dxlclient.message.Response(request)

Bases: dxlclient.message.Message

Response messages are sent by service instances upon receiving Request messages. Response messages are sent using the dxlclient.client.DxlClient.send_response() method of a client instance. Clients that are invoking the service (sending a request) will receive the response as a return value of the dxlclient.client.DxlClient.sync_request() method of a client instance or via the dxlclient.callbacks.ResponseCallback callback when invoking the asynchronous method, dxlclient.client.DxlClient.async_request().

Constructor parameters:

Parameters:request -- The Request message that this is a response for
message_type

The numeric type of the message

request

The Request message that this is a response for

request_message_id

Unique identifier (UUID) for the Request message that this message is a response for. This is used by the invoking dxlclient.client.DxlClient to correlate an incoming Response message with the Request message that was initially sent by the client.

service_id

The identifier of the service that sent this response (the service that the corresponding Request was routed to).