org.fusesource.stomp.jms.TxMessageQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stompjms-client Show documentation
Show all versions of stompjms-client Show documentation
STOMP-JMS is a JMS implementation using STOMP as the wire protocol
/**
* Copyright (C) 2012, FuseSource Corp. All rights reserved.
*
* http://fusesource.com
*
* The software in this package is published under the terms of the
* CDDL license a copy of which has been included with this distribution
* in the license.txt file.
*/
package org.fusesource.stomp.jms;
import org.fusesource.stomp.jms.message.StompJmsMessage;
import java.util.LinkedList;
/**
* @author Hiram Chirino
*/
public class TxMessageQueue extends MessageQueue {
private final LinkedList removed = new LinkedList();
public TxMessageQueue(long maxSize) {
super(maxSize);
}
@Override
protected void removed(QueueEntry entry) {
removed.addFirst(entry);
}
public void commit() {
synchronized (this) {
removed.clear();
}
}
public void rollback() {
synchronized (this) {
for (QueueEntry entry : removed) {
entry.message.setJMSRedelivered(true);
list.addFirst(entry);
size += entry.size;
}
removed.clear();
this.notify();
}
}
}