private DoSend ( ActiveMQMessage message, MessageProducer producer, MemoryUsage producerWindow, TimeSpan sendTimeout ) : void | ||
message | ActiveMQMessage | |
producer | MessageProducer | |
producerWindow | MemoryUsage | |
sendTimeout | TimeSpan | |
Résultat | void |
internal void DoSend( ActiveMQMessage message, MessageProducer producer, MemoryUsage producerWindow, TimeSpan sendTimeout )
{
ActiveMQMessage msg = message;
if(IsTransacted)
{
DoStartTransaction();
msg.TransactionId = TransactionContext.TransactionId;
}
msg.RedeliveryCounter = 0;
msg.BrokerPath = null;
if(this.connection.CopyMessageOnSend)
{
msg = (ActiveMQMessage)msg.Clone();
}
msg.OnSend();
msg.ProducerId = msg.MessageId.ProducerId;
if(sendTimeout.TotalMilliseconds <= 0 && !msg.ResponseRequired && !connection.AlwaysSyncSend &&
(!msg.Persistent || connection.AsyncSend || msg.TransactionId != null))
{
this.connection.Oneway(msg);
if(producerWindow != null)
{
// Since we defer lots of the marshaling till we hit the wire, this
// might not provide and accurate size. We may change over to doing
// more aggressive marshaling, to get more accurate sizes.. this is more
// important once users start using producer window flow control.
producerWindow.IncreaseUsage(msg.Size());
}
}
else
{
if(sendTimeout.TotalMilliseconds > 0)
{
this.connection.SyncRequest(msg, sendTimeout);
}
else
{
this.connection.SyncRequest(msg);
}
}
}
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); } }