<commit_before>ZeroMQ message dispatcher for ProophServiceBus
===================================================
[![Build Status](https://travis-ci.org/prooph/psb-zeromq-producer.svg)](https://travis-ci.org/prooph/psb-zeromq-producer)
[![Coverage Status](https://coveralls.io/repos/prooph/psb-zeromq-producer/badge.svg?branch=master&service=github)](https://coveralls.io/github/prooph/psb-zeromq-producer?branch=master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/prooph/improoph)

Use [ZeroMQ](http://zeromq.org/) as message producer for [Prooph Service Bus](https://github.com/prooph/service-bus).
Works together with bus types: CommandBus, EventBus.

# Installation

You can install the producer via composer by adding `"prooph/psb-zeromq-producer": "dev-master"` as requirement to your composer.json.

# Support

- Ask questions on [prooph-users](https://groups.google.com/forum/?hl=de#!forum/prooph) google group.
- File issues at [https://github.com/prooph/psb-zeromq-producer/issues](https://github.com/prooph/psb-zeromq-producer/issues).
- Say hello in the [prooph gitter](https://gitter.im/prooph/improoph) chat.


# Contribute

Please feel free to fork and extend existing or add new features and send a pull request with your changes!
To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.<commit_msg>Updates to readme adding documentation.<commit_after>ZeroMQ message dispatcher for ProophServiceBus
===================================================
[![Build Status](https://travis-ci.org/prooph/psb-zeromq-producer.svg)](https://travis-ci.org/prooph/psb-zeromq-producer)
[![Coverage Status](https://coveralls.io/repos/prooph/psb-zeromq-producer/badge.svg?branch=master&service=github)](https://coveralls.io/github/prooph/psb-zeromq-producer?branch=master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/prooph/improoph)

Use [ZeroMQ](http://zeromq.org/) as message producer for [Prooph Service Bus](https://github.com/prooph/service-bus).
Works together with bus types: CommandBus, EventBus.

# Requirements
PHP doesn't come with native support for ZeroMQ however there is an extension `ext-zmq` instructions are available on the ZMQ website for the PHP bindings.

http://zeromq.org/bindings:php

# Installation

So after `ext-zmq` is installed on your server/development machine you're ready for the next step! Composer will be able to install prooph zeromq producer in seconds if not quicker. Run the following command to install via composer.

`composer require prooph/psb-zeromq-producer:~0.2`

# Command/Event Bus (PUB/SUB)

To construct your Command/Event bus you'll need to have a server running ZMQ with [`ZMQ::SOCKET_SUB`](http://php.net/manual/en/class.zmq.php#zmq.constants.socket-sub) this will then receive the messages from the producer.

For basic tutorial on PUB/SUB: http://zguide.zeromq.org/page:all#Getting-the-Message-Out

### Usage Examples

```
$container = new Container;
$container['config'] = [
    'prooph' => [
        'zeromq_producer' => [
            'dsn' => 'tcp://127.0.0.1:5555', // ZMQ Server Address.
            'persistent_id' => 'example', // ZMQ Persistent ID to keep connections alive between requests.
            'rpc' => false, // Use as Query Bus.
        ]
    ]
];

$factory = Prooph\ServiceBus\Message\ZeroMQ\Container\ZeroMQMessageProducerFactory;
$zmqProducer = $factory($container);

// Setup complete, now to add it to the prooph service bus.

$commandBus = new Prooph\ServiceBus\CommandBus();
$router = new Prooph\ServiceBus\Plugin\Router\CommandRouter();
$router->route('ExampleCommand')
    ->to($zmqProducer);

$commandBus->utilize($router);
$echoText = new ExampleCommand('It works');
$commandBus->dispatch($echoText);

// Now check your server to make sure it received this command.
```

# Query Bus (REQ/REP)

To construct your Query bus you'll need to have a ZMQ server running with [`ZMQ::SOCKET_REP`](http://php.net/manual/en/class.zmq.php#zmq.constants.socket-rep) this will then receive the messages from the producer and MUST reply as part of the REQ/REP specification.

For basic tutorial on REQ/REP: http://zguide.zeromq.org/page:all#Ask-and-Ye-Shall-Receive

### Usage Examples

```
$container = new Container;
$container['config'] = [
    'prooph' => [
        'zeromq_producer' => [
            'dsn' => 'tcp://127.0.0.1:5555', // ZMQ Server Address.
            'persistent_id' => 'example', // ZMQ Persistent ID to keep connections alive between requests.
            'rpc' => true, // Use as Query Bus.
        ]
    ]
];

$factory = Prooph\ServiceBus\Message\ZeroMQ\Container\ZeroMQMessageProducerFactory;
$zmqProducer = $factory($container);

// Setup complete, now to add it to the prooph service bus.

// @codeliner can yo give this implementation.
```

# Support

- Ask questions on [prooph-users](https://groups.google.com/forum/?hl=de#!forum/prooph) google group.
- File issues at [https://github.com/prooph/psb-zeromq-producer/issues](https://github.com/prooph/psb-zeromq-producer/issues).
- Say hello in the [prooph gitter](https://gitter.im/prooph/improoph) chat.


# Contribute

Please feel free to fork and extend existing or add new features and send a pull request with your changes!
To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.
{'fraction_non_alphanumeric': 0.14878318584070796, 'fraction_numerical': 0.004793510324483776, 'mean_word_length': 4.446787148594377, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 22, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6754869', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1674, 'n_words': 452}