Uploaded image for project: 'ActiveMQ .Net'
  1. ActiveMQ .Net
  2. AMQNET-188

Apache.NMS.ActiveMQ.MessageProducer does throw error when on FailoverTransport

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.1.0
    • 1.2.0
    • ActiveMQ
    • None
    • Windows XP SP3, Windows 2003 Server

    Description

      I had a production broker which had some issues with his Java GC limits. When the broker had an issue (using failover transport), my services using this broker started throwing errors (while exceptions should be supressed when using failover transport ). Looking into the code i found out that when the broker closes the connection while a message producer is sending messages, this throws an error in the MessageProducer.CS Class in the folowing void:

      protected void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, bool specifiedTimeToLive)
      		{
      			if(null == destination)
      			{
      				// See if this producer was created without a destination.
      				if(null == info.Destination)
      				{
      					throw new NotSupportedException();
      				}
      
      				// The producer was created with a destination, but an invalid destination
      				// was specified.
      				throw new Apache.NMS.InvalidDestinationException();
      			}
      
      			ActiveMQMessage activeMessage = (ActiveMQMessage) message;
      
      			if(!disableMessageID)
      			{
      				MessageId id = new MessageId();
      				id.ProducerId = info.ProducerId;
      				id.ProducerSequenceId = Interlocked.Increment(ref messageCounter);
      				activeMessage.MessageId = id;
      			}
      
      			activeMessage.ProducerId = info.ProducerId;
      			activeMessage.FromDestination = destination;
      			activeMessage.NMSDeliveryMode = deliveryMode;
      			activeMessage.NMSPriority = priority;
      
      			if(!disableMessageTimestamp)
      			{
      				activeMessage.NMSTimestamp = DateTime.UtcNow;
      			}
      
      			if(specifiedTimeToLive)
      			{
      				activeMessage.NMSTimeToLive = timeToLive;
      			}
      
      			lock(closedLock)
      			{
      				if(closed)
      				{
      					throw new ConnectionClosedException();
      				}
      
      				if(session.Transacted)
      				{
      					session.DoStartTransaction();
      					activeMessage.TransactionId = session.TransactionContext.TransactionId;
      				}
      
      				session.DoSend(activeMessage, this.RequestTimeout);
      			}
      		}
      

      this is the error:

       Apache.NMS.ActiveMQ.BrokerException: System.InvalidOperationException: Error writing to broker.  Transport connection is closed.
         at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Oneway(Command command) : Transport connection error: Error writing to broker.  Transport connection is closed.
      
         at Apache.NMS.ActiveMQ.Transport.ResponseCorrelator.Request(Command command, TimeSpan timeout)
         at Apache.NMS.ActiveMQ.Connection.SyncRequest(Command command, TimeSpan requestTimeout)
         at Apache.NMS.ActiveMQ.Session.DoSend(Command message, TimeSpan requestTimeout)
         at Apache.NMS.ActiveMQ.MessageProducer.Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, Boolean specifiedTimeToLive)
         at Apache.NMS.ActiveMQ.MessageProducer.Send(IMessage message)
         at tp2server.mqServer.OnMessage(IMessage oMessage)
      

      Attachments

        Issue Links

          Activity

            People

              jgomes Jim Gomes
              mvhoof Michel Van Hoof
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: