public Task <T> Get <T>(Guid sagaId, SynchronizedStorageSession session, ContextBag context)
            where T : class, IContainSagaData
        {
            var result = session.Session().Get <T>(sagaId, GetLockModeForSaga <T>());

            return(Task.FromResult(result));
        }
 Task <T> ISagaPersister.Get <T>(string property, object value, SynchronizedStorageSession session, ContextBag context)
 {
     return(session.Session().CreateCriteria(typeof(T))
            .SetLockMode(GetLockModeForSaga <T>())
            .Add(Restrictions.Eq(property, value))
            .UniqueResultAsync <T>());
 }
Beispiel #3
0
    public Task <OrderSagaData> FindBy(CompleteOrder message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
    {
        var orderSagaData = storageSession.Session().QueryOver <OrderSagaData>()
                            .Where(d => d.OrderId == message.OrderId)
                            .SingleOrDefault();

        return(Task.FromResult(orderSagaData));
    }
Beispiel #4
0
        public Task <TweetReceivedSagaData> FindBy(TweetReceived message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
        {
            var tweetReceivedSagaData = storageSession.Session().QueryOver <TweetReceivedSagaData>()
                                        .Where(d => d.Hashtag == message.Track)
                                        .SingleOrDefault();

            return(Task.FromResult(tweetReceivedSagaData));
        }
    public Task <OrderSagaData> FindBy(StartOrder message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
    {
        IAsyncDocumentSession session = storageSession.Session();

        //if the instance is null a new saga will be automatically created if
        //the Saga handles the message as IAmStartedByMessages<StartOrder>; otherwise an exception is raised.
        return(session.LoadByUniqueConstraintAsync <OrderSagaData>(d => d.OrderId, message.OrderId));
    }
Beispiel #6
0
    public Task <OrderSagaData> FindBy(PaymentTransactionCompleted message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
    {
        var session       = storageSession.Session();
        var orderSagaData = session.QueryOver <OrderSagaData>()
                            .Where(d => d.PaymentTransactionId == message.PaymentTransactionId)
                            .SingleOrDefault();

        return(Task.FromResult(orderSagaData));
    }
Beispiel #7
0
    public Task <OrderSagaData> FindBy(StartOrder message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
    {
        var session = storageSession.Session();
        // if the instance is null a new saga will be automatically created if
        // the Saga handles the message as IAmStartedByMessages<StartOrder>; otherwise an exception is raised.
        var orderSagaData = session.QueryOver <OrderSagaData>()
                            .Where(d => d.OrderId == message.OrderId)
                            .SingleOrDefault();

        return(Task.FromResult(orderSagaData));
    }
Beispiel #8
0
            public Task <MySagaData> FindBy(MyMessage message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
            {
                //your custom finding logic here, e.g.
                ISession   nhibernateSession = storageSession.Session();
                MySagaData sagaData          = nhibernateSession.QueryOver <MySagaData>()
                                               .Where(x =>
                                                      x.SomeID == message.SomeID &&
                                                      x.SomeData == message.SomeData)
                                               .SingleOrDefault();

                return(Task.FromResult(sagaData));
            }
    public ReceiverDataContext GetDataContext(SynchronizedStorageSession storageSession)
    {
        if (context == null)
        {
            var dbConnection = storageSession.Session().Connection;
            context = new ReceiverDataContext(dbConnection);

            //Don't use transaction because connection is enlisted in the TransactionScope
            context.Database.UseTransaction(null);

            //Call SaveChanges before completing storage session
            storageSession.OnSaveChanges(x => context.SaveChangesAsync());
        }
        return(context);
    }
 public Task Complete(IContainSagaData saga, SynchronizedStorageSession session, ContextBag context)
 {
     return(session.Session().DeleteAsync(saga));
 }
 public Task <T> Get <T>(Guid sagaId, SynchronizedStorageSession session, ContextBag context)
     where T : class, IContainSagaData
 {
     return(session.Session().GetAsync <T>(sagaId, GetLockModeForSaga <T>()));
 }
 public Task Save(IContainSagaData saga, SagaCorrelationProperty correlationProperty, SynchronizedStorageSession session, ContextBag context)
 {
     return(session.Session().SaveAsync(saga));
 }
 public Task Complete(IContainSagaData saga, SynchronizedStorageSession session, ContextBag context)
 {
     session.Session().Delete(saga);
     return(Task.FromResult(0));
 }
 public Task Save(IContainSagaData saga, SagaCorrelationProperty correlationProperty, SynchronizedStorageSession session, ContextBag context)
 {
     session.Session().Save(saga);
     return(Task.FromResult(0));
 }
Beispiel #15
0
    public Task <OrderSagaData> FindBy(CompleteOrder message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context)
    {
        IAsyncDocumentSession session = storageSession.Session();

        return(session.LoadByUniqueConstraintAsync <OrderSagaData>(d => d.OrderId, message.OrderId));
    }