Can I use TransactionScope when accessing IBM MQ with XMS? I have this test code:
var context =
new InitialContext(
new Hashtable
{
{ "XMSC_IC_URL", "XXX" },
{ "XMSC_IC_SECURITY_AUTHENTICATION", "none" },
});
var connectionFactory = (IConnectionFactory) context.Lookup("XXX");
connectionFactory.SetStringProperty("XMSC_WMQ_CONNECTION_MODE", "5");
connectionFactory.SetStringProperty("XMSC_WMQ_SSL_CIPHER_SPEC", "TRIPLE_DES_SHA_US");
connectionFactory.SetStringProperty("XMSC_WMQ_SSL_KEY_REPOSITORY", "XXX");
try
{
using (var scope = new TransactionScope())
{
using (var connection = connectionFactory.CreateConnection())
{
connection.Start();
using (var session = connection.CreateSession(true, AcknowledgeMode.SessionTransacted))
{
using (var queue = session.CreateQueue(queueName))
{
using (var consumer = session.CreateConsumer(queue))
{
var message = consumer.Receive();
}
}
}
}
throw new Exception();
scope.Complete();
}
}
catch (Exception)
{
}
He will make receipt (confirmation) of the message, despite the exception. What for? If I comment on all lines with a scope and a line with an exception, the message will remain in the queue. Why does using a transaction scope confirm a message in case of failure?
source
share