protected function _prepareMessage($data, array $options)
    {
        $attributes = [];

        $options += [
            'silent' => false,
            'compress' => true,
            'serializer' => extension_loaded('msgpack') ? 'msgpack' : 'json',
            'delivery_mode' => 1
        ];

        switch ($options['serializer']) {
            case 'json':
                $data = json_encode($data);
                $attributes['content_type'] = 'application/json';
                break;

            case 'text':
                $attributes['content_type'] = 'application/text';
                break;

            default:
                throw new RuntimeException('Unknown serializer: ' . $options['serializer']);
        }

        if (!empty($options['compress'])) {
            $data = gzcompress($data);
            $attributes += ['content_encoding' => 'gzip'];
        }

        if (!empty($options['delivery_mode'])) {
            $attributes['delivery_mode'] = $options['delivery_mode'];
        }

        return [$data, $attributes, $options];
    }
protected function _prepareMessage($data, array $options)
    {
        $attributes = [];

        $options += [
            'silent' => false,
            'compress' => true,
            'serializer' => extension_loaded('msgpack') ? 'msgpack' : 'json',
            'delivery_mode' => 1
        ];

        switch ($options['serializer']) {
            case 'json':
                $data = json_encode($data);
                $attributes['content_type'] = 'application/json';
                break;

            case 'text':
                $attributes['content_type'] = 'application/text';
                break;

            default:
                throw new RuntimeException('Unknown serializer: ' . $options['serializer']);
        }

        if (!empty($options['compress'])) {
            $data = gzcompress($data);
            $attributes += ['content_encoding' => 'gzip'];
        }

        if (!empty($options['delivery_mode'])) {
            $attributes['delivery_mode'] = $options['delivery_mode'];
        }

        return [$data, $attributes, $options];
    }
protected function _prepareMessage ( $ data , array $ options ) { $ attributes = [ ] ; $ options += [ 'silent' => false , 'compress' => true , 'serializer' => extension_loaded ( 'msgpack' ) ? 'msgpack' : 'json' , 'delivery_mode' => 1 ] ; switch ( $ options [ 'serializer' ] ) { case 'json' : $ data = json_encode ( $ data ) ; $ attributes [ 'content_type' ] = 'application/json' ; break ; case 'text' : $ attributes [ 'content_type' ] = 'application/text' ; break ; default : throw new RuntimeException ( 'Unknown serializer: ' . $ options [ 'serializer' ] ) ; } if ( ! empty ( $ options [ 'compress' ] ) ) { $ data = gzcompress ( $ data ) ; $ attributes += [ 'content_encoding' => 'gzip' ] ; } if ( ! empty ( $ options [ 'delivery_mode' ] ) ) { $ attributes [ 'delivery_mode' ] = $ options [ 'delivery_mode' ] ; } return [ $ data , $ attributes , $ options ] ; }
Prepare a message by serializing, optionally compressing and setting the correct content type
and content type for the message going to RabbitMQ

@param  mixed $data
@param  array $options
@return array
Prepare a message by serializing optionally compressing and setting the correct content type and content type for the message going to RabbitMQ