Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-166

Transaction doesn't work with amqp .net lite client

XMLWordPrintable

    • Release Notes
    • Hide
      AMQP transactions across multiple sessions with the AMQP .NET client were not supported for the Alpha release.
      Feature negotiation should occur when a connection between the Broker and client is established. This feature is now implemented.
      Show
      AMQP transactions across multiple sessions with the AMQP .NET client were not supported for the Alpha release. Feature negotiation should occur when a connection between the Broker and client is established. This feature is now implemented.
    • Documented as Resolved Issue
    • Hide

      use this code:

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Transactions;
      using Amqp;
      using Amqp.Framing;
      
      namespace test
      {
          class Test
          {
              public static void Main(string[] args)
              {
                  Address address = new Address("amqp://10.34.124.125:5672");
                  string queue = "jms.queue.test";
                  string testName = "TransactedPosting";
                  int nMsgs = 5;
      
                  Connection connection = new Connection(address);
                  Session session = new Session(connection);
                  SenderLink sender = new SenderLink(session, "sender-" + testName, queue);
      
                  // commit
                  using (var ts = new TransactionScope())
                  {
                      for (int i = 0; i < nMsgs; i++)
                      {
                          Message message = new Message("test");
                          message.Properties = new Properties() { MessageId = "commit" + i, GroupId = testName };
                          sender.Send(message);
                      }
      
                      ts.Complete();
                  }
      
                  // rollback
                  using (var ts = new TransactionScope())
                  {
                      for (int i = nMsgs; i < nMsgs * 2; i++)
                      {
                          Message message = new Message("test");
                          message.Properties = new Properties() { MessageId = "rollback" + i, GroupId = testName };
                          sender.Send(message); //error connection is closed
                      }
                  }
      
                  // commit
                  using (var ts = new TransactionScope())
                  {
                      for (int i = 0; i < nMsgs; i++)
                      {
                          Message message = new Message("test");
                          message.Properties = new Properties() { MessageId = "commit" + i, GroupId = testName };
                          sender.Send(message);
                      }
      
                      ts.Complete();
                  }
      
                  //receive
                  ReceiverLink receiver = new ReceiverLink(session, "receiver-" + testName, queue);
                  for (int i = 0; i < nMsgs * 2; i++)
                  {
                      Message message = receiver.Receive();
                      Trace.WriteLine(TraceLevel.Information, "receive: {0}", message.Properties.MessageId);
                      receiver.Accept(message);
                  }
      
                  connection.Close();
              }
          }
      }
      
      Show
      use this code: using System ; using System .Collections.Generic; using System .Linq; using System .Text; using System .Threading.Tasks; using System .Transactions; using Amqp; using Amqp.Framing; namespace test { class Test { public static void Main(string[] args) { Address address = new Address( "amqp: //10.34.124.125:5672" ); string queue = "jms.queue.test" ; string testName = "TransactedPosting" ; int nMsgs = 5; Connection connection = new Connection(address); Session session = new Session(connection); SenderLink sender = new SenderLink(session, "sender-" + testName, queue); // commit using ( var ts = new TransactionScope()) { for ( int i = 0; i < nMsgs; i++) { Message message = new Message( "test" ); message.Properties = new Properties() { MessageId = "commit" + i, GroupId = testName }; sender.Send(message); } ts.Complete(); } // rollback using ( var ts = new TransactionScope()) { for ( int i = nMsgs; i < nMsgs * 2; i++) { Message message = new Message( "test" ); message.Properties = new Properties() { MessageId = "rollback" + i, GroupId = testName }; sender.Send(message); //error connection is closed } } // commit using ( var ts = new TransactionScope()) { for ( int i = 0; i < nMsgs; i++) { Message message = new Message( "test" ); message.Properties = new Properties() { MessageId = "commit" + i, GroupId = testName }; sender.Send(message); } ts.Complete(); } //receive ReceiverLink receiver = new ReceiverLink(session, "receiver-" + testName, queue); for ( int i = 0; i < nMsgs * 2; i++) { Message message = receiver.Receive(); Trace.WriteLine(TraceLevel.Information, "receive: {0}" , message.Properties.MessageId); receiver.Accept(message); } connection.Close(); } } }
    • Broker - September Sprint

      Transaction sending messages to amq7 doesn't work. Rollback doesn't work.

              rh-ee-ataylor Andy Taylor
              dkornel@redhat.com David Kornel
              David Kornel David Kornel
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: