log.debug(this+" - COMMIT [PUT:QUEUE] "+pendingQueuePuts.size()+" message(s)");
// Simpler (and most common) use case
if (pendingQueuePuts.size() == -1)
{
AbstractMessage message = (AbstractMessage)pendingQueuePuts.get(0);
putImmediately(message,committables);
producedCount++;
}
else
{
// A two phase injection is required because one destination may throw
// an exception while messages have already been added to queues (queue full for example)
// Step 1 - Put messages in locked state
MessageLockSet locks = new MessageLockSet(pendingQueuePuts.size());
try
{
for (int i = 0; i < pendingQueuePuts.size(); i++)
{
AbstractMessage message = (AbstractMessage)pendingQueuePuts.get(i);
putLocked(message, locks, committables);
producedCount++;
}
}
catch (JMSException e)
{
// Remove locked messages
for (int i = 0; i < locks.size(); i++)
{
MessageLock item = locks.get(i);
item.getDestination().removeLocked(item);
}
throw e;
}
// Step 2 - Unlock & deliver messages
for (int i = 0; i < locks.size(); i++)
{
MessageLock item = locks.get(i);
item.getDestination().unlockAndDeliver(item);
}
}
pendingQueuePuts.clear();
}
}
// Topic messages
synchronized (pendingTopicPuts)
{
if (!pendingTopicPuts.isEmpty())
{
if (debugEnabled)
log.debug(this+" - COMMIT [PUT:TOPIC] "+pendingTopicPuts.size()+" message(s)");
for (int i = 0; i < pendingTopicPuts.size(); i++)
{
AbstractMessage message = (AbstractMessage)pendingTopicPuts.get(i);
putImmediately(message,committables);
producedCount++;
}
pendingTopicPuts.clear();