bci.publisher package¶
Subpackages¶
Submodules¶
bci.publisher.publisher module¶
-
class
bci.publisher.publisher.Publisher(mq_url=None, is_subscriber=None)¶ Bases:
objectRepresents a message queue publisher.
-
mq_url¶ URL of the message queue’s server.
- Type
str
-
is_subscriber¶ If true, this publisher is also a subscriber.
- Type
bool
- Parameters
mq_url (
str, optional) – URL of the message queue’s server. Default to DEFAULT_MQ_URL.is_subscriber (
bool, optional) – If true, this publisher is also a subscriber. Default to DEFAULT_IS_SUBSCRIBER.
- Raises
ValueError – If an invalid URL was provided.
-
publish(message, exchange, routing_key)¶ Publishes message to the queues on the exchange, while routing it by the routing key.
- Parameters
message (str) – JSON-formatted message to be published.
exchange (str) – The name of the exchange to publish to.
routing_key (str) – The routing key to bind on.
-
subscribe(exchange, routing_key, queue, callback)¶ Subscribes queue to exchange on routing_key, and starts the created channel to consume messages.
- Parameters
exchange (str) – The name of the exchange to subscribe to.
routing_key (str) – The routing key to bind on.
queue (str) – The queue to consume from.
callback (callable) – The function to call when consuming with the following signature: callback(channel, method, properties, body)
-
Module contents¶
-
class
bci.publisher.Publisher(mq_url=None, is_subscriber=None)¶ Bases:
objectRepresents a message queue publisher.
-
mq_url¶ URL of the message queue’s server.
- Type
str
-
is_subscriber¶ If true, this publisher is also a subscriber.
- Type
bool
- Parameters
mq_url (
str, optional) – URL of the message queue’s server. Default to DEFAULT_MQ_URL.is_subscriber (
bool, optional) – If true, this publisher is also a subscriber. Default to DEFAULT_IS_SUBSCRIBER.
- Raises
ValueError – If an invalid URL was provided.
-
publish(message, exchange, routing_key)¶ Publishes message to the queues on the exchange, while routing it by the routing key.
- Parameters
message (str) – JSON-formatted message to be published.
exchange (str) – The name of the exchange to publish to.
routing_key (str) – The routing key to bind on.
-
subscribe(exchange, routing_key, queue, callback)¶ Subscribes queue to exchange on routing_key, and starts the created channel to consume messages.
- Parameters
exchange (str) – The name of the exchange to subscribe to.
routing_key (str) – The routing key to bind on.
queue (str) – The queue to consume from.
callback (callable) – The function to call when consuming with the following signature: callback(channel, method, properties, body)
-