我正在使用IBM.XMS lib与WebSphereMQ交谈。异步消费者和使用TransactionScope
当使用同步方法接收消息,例如:
using (var scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
{
message = consumer.Receive(1000);
if (message != null)
{
//Do work here
scope.Complete();
}
}
但是,如果我想使用异步方法:
consumer.MessageListener = delegate(IMessage msg)
{
//Do work here
//But where do I put TransactionScope?
};
我不知道如何来包装MessageListener
回调在TransactionScope
之内。
有谁知道如何做到这一点?
如果消费者实例已从会话中创建,则会话可能已创建,以便在委托运行期间存在(Transaction.Current)周围的环境事务。 – 2013-04-11 10:26:49