public function testEndSaga() { $identifier = \Rhumsaa\Uuid\Uuid::uuid1()->toString(); $saga = new MyTestSaga($identifier); $this->mongoTemplate->sagaCollection()->save((new SagaEntry($saga, new JMSSerializer()))->asDBObject()); $loaded = $this->repository->load($identifier); $loaded->end(); $this->repository->commit($loaded); $this->assertNull($this->mongoTemplate->sagaCollection()->findOne(SagaEntry::queryByIdentifier($identifier))); }
/** * Loads a known Saga instance by its unique identifier. Returned Sagas must be {@link #commit(Saga) committed} * after processing. * Due to the concurrent nature of Sagas, it is not unlikely for a Saga to have ceased to exist after it has been * found based on associations. Therefore, a repository should return <code>null</code> in case a Saga doesn't * exists, as opposed to throwing an exception. * * @param string $sagaIdentifier The unique identifier of the Saga to load * @return SagaInterface The Saga instance, or <code>null</code> if no such saga exists */ public function load($sagaIdentifier) { $dbSaga = $this->mongoTemplate->sagaCollection()->findOne(SagaEntry::queryByIdentifier($sagaIdentifier)); if (null === $dbSaga) { return null; } $serializedSaga = new SimpleSerializedObject($dbSaga[SagaEntry::SERIALIZED_SAGA], new SimpleSerializedType($dbSaga[SagaEntry::SAGA_TYPE])); $saga = $this->serializer->deserialize($serializedSaga); if (null !== $this->injector) { $this->injector->injectResources($saga); } return $saga; }