[ 
https://issues.apache.org/activemq/browse/AMQNET-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=54309#action_54309
 ] 

Michel Van Hoof commented on AMQNET-188:
----------------------------------------

Looking further, the bug actually occurs in the TcpTransport.Cs class:

{code}
public void Oneway(Command command)
                {
                        lock(myLock)
                        {
                                try
                                {
                                        if(closed.Value)
                                        {
                                                throw new 
InvalidOperationException("Error writing to broker.  Transport connection is 
closed.");
                                        }

                                        if(command is ShutdownInfo)
                                        {
                                                seenShutdown = true;
                                        }

                                        Wireformat.Marshal(command, 
socketWriter);
                                        //jdg socketWriter.Flush();
                                }
                                catch(Exception ex)
                                {
                                        if(command.ResponseRequired)
                                        {
                                                // Make sure that something 
higher up doesn't get blocked.
                                                // Respond with an exception.
                                                ExceptionResponse er = new 
ExceptionResponse();
                                                BrokerError error = new 
BrokerError();

                                                error.Message = "Transport 
connection error: " + ex.Message;
                                                error.ExceptionClass = 
ex.ToString();
                                                er.Exception = error;
                                                er.CorrelationId = 
command.CommandId;
                                                commandHandler(this, er);
                                        }
                                }
                        }
                }
{code}

Although i can't see why the exception is not handled by the 
HandleTransportFailure ? Maybe the error is thrown before the listener is 
attached ?

> Apache.NMS.ActiveMQ.MessageProducer does throw error when on FailoverTransport
> ------------------------------------------------------------------------------
>
>                 Key: AMQNET-188
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-188
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: ActiveMQ
>    Affects Versions: 1.1.0
>         Environment: Windows XP SP3, Windows 2003 Server
>            Reporter: Michel Van Hoof
>            Assignee: Jim Gomes
>
> 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:
> {code}
> 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);
>                       }
>               }
> {code}
> this is the error:
> {code}
>  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)
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to