Exemplo n.º 1
0
def get_client():
    """
    Instantiate publishing client.

    Instantiated trough the defined config.
    """
    conf = load_config()
    publisher_class = Factory.make_class('Publisher', conf.publisher_class)
    return publisher_class(conf)
Exemplo n.º 2
0
def get_client():
    """
    Instantiate publishing client.

    Instantiated trough the defined config.
    """
    conf = load_config()
    publisher_class = Factory.make_class(
        'Publisher',
        conf.publisher_class)
    return publisher_class(conf)
Exemplo n.º 3
0
def get_client(config=None):
    """
    Instantiate publishing client.

    Instantiated trough the defined config.
    """
    config = config or load_publisher_config()
    import_string = '{0}/{1}'.format(config.publisher_class.mod,
                                     config.publisher_class.cls)
    publisher_class = Factory.make_class('EventPublisher', [import_string, ])
    return publisher_class(config)
Exemplo n.º 4
0
def get_client(config=None):
    """
    Instantiate publishing client.

    Instantiated trough the defined config.
    """
    config = config or load_publisher_config()
    import_string = '{0}/{1}'.format(config.publisher_class.mod,
                                     config.publisher_class.cls)
    publisher_class = Factory.make_class('EventPublisher', [
        import_string,
    ])
    return publisher_class(config)
Exemplo n.º 5
0
def schedule_message(self, routing_key, body):
    """
    Keyword Arguments:
    :param routing_key: Routing key for the topic exchange
    :type routing_key: str or unicode

    :param body: Message body in json.dumps format
    :type body: str
    """
    try:
        message = json.loads(body)
        message['routing-key'] = routing_key
        conf = load_amqp_client_config('schedule_message')
        publisher_class = Factory.make_class('SchedulerPublisher',
                                             conf.publisher_class)
        with publisher_class(conf) as amqp_client:
            amqp_client.publish(message)
    except Exception as e:
        # we want to log and retry sending indefinitely...
        # TODO logger... use Cerebrum's??
        raise self.retry(exc=e, max_retries=None)  # retry forever