src/Queue/MongoQueue.php
function push($payload, $queue = null)
    {
        if ( null === $queue && $payload instanceof iPayloadQueued )
            $queue = $payload->getQueue();




        /** @var QueuedPayload $qPayload */
        $qPayload = $payload;

        $time = ($payload instanceof iPayloadQueued)
            ? $time = $payload->getCreatedTimestamp()
            : time();

        if (! $payload instanceof iPayloadQueued ) {
            $qPayload = new QueuedPayload($payload);

            $uid      = new MongoDB\BSON\ObjectID();
            $qPayload = $qPayload
                ->withUID( $uid )
            ;

        } else {

            $uid = new MongoDB\BSON\ObjectID($qPayload->getUID());
        }

        $qPayload = $qPayload->withQueue( $this->_normalizeQueueName($queue) );


        // .............

        $sPayload = $this->_interchangeable()
            ->makeForward($qPayload);

        try {
            $this->collection->insertOne(
                [
                    '_id'     => $uid,
                    'queue'   => $qPayload->getQueue(),
                    'payload' => new MongoDB\BSON\Binary($sPayload, MongoDB\BSON\Binary::TYPE_GENERIC),
                    'payload_humanize' => $sPayload,
                    'created_timestamp' => $time,
                    'pop'     => false, // not yet popped; against race condition
                ]
            );

        } catch (\Exception $e) {
            throw new exWriteError('Error While Write To Mongo Client.', $e->getCode(), $e);
        }


        return $qPayload;
    }
function push($payload, $queue = null)
    {
        if ( null === $queue && $payload instanceof iPayloadQueued )
            $queue = $payload->getQueue();




        /** @var QueuedPayload $qPayload */
        $qPayload = $payload;

        $time = ($payload instanceof iPayloadQueued)
            ? $time = $payload->getCreatedTimestamp()
            : time();

        if (! $payload instanceof iPayloadQueued ) {
            $qPayload = new QueuedPayload($payload);

            $uid      = new MongoDB\BSON\ObjectID();
            $qPayload = $qPayload
                ->withUID( $uid )
            ;

        } else {

            $uid = new MongoDB\BSON\ObjectID($qPayload->getUID());
        }

        $qPayload = $qPayload->withQueue( $this->_normalizeQueueName($queue) );


        // .............

        $sPayload = $this->_interchangeable()
            ->makeForward($qPayload);

        try {
            $this->collection->insertOne(
                [
                    '_id'     => $uid,
                    'queue'   => $qPayload->getQueue(),
                    'payload' => new MongoDB\BSON\Binary($sPayload, MongoDB\BSON\Binary::TYPE_GENERIC),
                    'payload_humanize' => $sPayload,
                    'created_timestamp' => $time,
                    'pop'     => false, // not yet popped; against race condition
                ]
            );

        } catch (\Exception $e) {
            throw new exWriteError('Error While Write To Mongo Client.', $e->getCode(), $e);
        }


        return $qPayload;
    }
Push To Queue

@param iPayload $payload Serializable payload
@param string   $queue

@return iPayloadQueued
@throws exIOError