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.