I've found 3 other solutions to my problem 1) Use a logEndpoint and a another server that listens to start and end messages. 2) Nest my code in a TransactionScope and Suppress it. 3) In the config use consumeInTransaction="false"
Iäve tried option 2 and 3 with success, but I think it most be drawbacks to using them that I'm not aware of. On Sep 20, 5:05 am, Tom Cabanski <[email protected]> wrote: > I think you need to begin the transaction before you open the > session. If you don't, nhibernate does not enlist. It's been a > little while since I used nhibernate so I am not positive. > On Sep 19, 8:52 am, Kenny Eliasson <[email protected]> wrote: > > > > > > > > > Hi there! > > > When I send my messages to the queue I include a JobLogId which I > > later on uses in my consumer for loading a entity from NHibernate. I > > then change the status of the job to processing, starts the invoke the > > Consume-method that can take everywhere from 1 second to 10 minutes > > and after the job is done I once again load the entity and mark it as > > done. > > > The problem is that it seems the DTC-transaction is locking the table, > > so that I can't query on it. > > > I'm using the following code > > > public void Consume(T message) > > { > > > JobLog jobLog; > > using (var session = _sessionFactory.OpenSession()){ > > //using (var tx = session.BeginTransaction()) { > > jobLog = session.Get<JobLog>(message.JobLogId); > > jobLog.Processing(); > > //tx.Commit(); > > session.Flush(); > > } > > > _logger.InfoFormat("Starting processing message of type > > {0}.\nMessage data: {1}", jobLog.MessageType, jobLog.MessageData); > > > try { > > Consume(message, _logger); > > } catch (Exception e) { > > _logger.Fatal(string.Format("The consumer {0} threw an > > exception", this.GetType().Name), e); > > using (var session = _sessionFactory.OpenSession()) > > using (var tx = session.BeginTransaction()) { > > jobLog = session.Get<JobLog>(message.JobLogId); > > jobLog.Crashed(); > > tx.Commit(); > > } > > return; > > } > > > _logger.InfoFormat("Done processing message of type {0}", > > message.GetType().Name); > > > using (var session = _sessionFactory.OpenSession()) { > > //using (var tx = session.BeginTransaction()) { > > jobLog = session.Get<JobLog>(message.JobLogId); > > jobLog.Done(); > > //tx.Commit(); > > session.Flush(); > > } > > } > > > As you see I've tried to comment out the transaction parts of > > NHibernate without success. > > > Is there a way to solve this without locking the whole table? Is there > > a better way of logging then doing it in the consume-method? Any > > thoughts? -- You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.
