/**
  * {@inheritdoc}
  */
 public function commit(SagaInterface $saga)
 {
     if (!$saga->isActive()) {
         unset($this->managedSagas[$saga->getSagaIdentifier()]);
     } else {
         $this->managedSagas[$saga->getSagaIdentifier()] = $saga;
     }
     $saga->getAssociationValues()->commit();
 }
Пример #2
0
 /**
  * Constructs a new SagaEntry for the given <code>saga</code>. The given saga must be serializable. The provided
  * saga is not modified by this operation.
  *
  * @param SagaInterface $saga The saga to store
  * @param SerializerInterface $serializer The serialization mechanism to convert the Saga to a byte stream
  */
 public function __construct(SagaInterface $saga, SerializerInterface $serializer)
 {
     $this->sagaId = $saga->getSagaIdentifier();
     $serialized = $serializer->serialize($saga);
     $this->serializedSaga = $serialized->getData();
     $this->sagaType = $serialized->getType()->getName();
     $this->revision = $serialized->getType()->getRevision();
     $this->saga = $saga;
 }
Пример #3
0
 /**
  * Constructs a new SagaEntry for the given <code>saga</code>. The given saga must be serializable. The provided
  * saga is not modified by this operation.
  *
  * @param SagaInterface $saga The saga to store
  * @param SerializerInterface $serializer The serialization mechanism to convert the Saga to a byte stream
  */
 public function __construct(SagaInterface $saga, SerializerInterface $serializer)
 {
     $this->sagaId = $saga->getSagaIdentifier();
     $serialized = $serializer->serialize($saga);
     $this->serializedSaga = $serialized->getData();
     $this->sagaType = get_class($saga);
     $this->saga = $saga;
     $this->associationValues = $saga->getAssociationValues()->asArray();
 }
 protected function storeSaga(SagaInterface $saga)
 {
     $entry = new SagaEntry($saga, $this->serializer);
     $this->entityManager->persist($entry);
     $this->logger->debug("Storing saga id {id} as {data}", array('id' => $saga->getSagaIdentifier(), 'data' => $entry->getSerializedSaga()));
     if ($this->useExplicitFlush) {
         $this->entityManager->flush();
     }
 }
Пример #5
0
 /**
  * Update a stored Saga, by replacing it with the given <code>saga</code> instance.
  *
  * @param SagaInterface $saga The saga that has been modified and needs to be updated in the storage
  */
 protected function updateSaga(SagaInterface $saga)
 {
     $sagaEntry = new SagaEntry($saga, $this->serializer);
     $this->mongoTemplate->sagaCollection()->findAndModify(SagaEntry::queryByIdentifier($saga->getSagaIdentifier()), $sagaEntry->asDBObject());
 }