void inProgressClearRequired() { inProgressClearRequiredFlag.incrementAndGet(); // deal with delivered messages async to avoid lock contention with in progress acks clearDeliveredList = true; // force a rollback if we will be acking in a transaction after/during failover // bc acks are async they may not get there reliably on reconnect and the consumer // may not be aware of the reconnect in a timely fashion if in onMessage if (!deliveredMessages.isEmpty() && session.getTransactionContext().isInTransaction()) { session.getTransactionContext().setRollbackOnly(true); } }
public void close() throws JMSException { if (!closed) { if (getTransactionContext().isInXATransaction()) { if (!synchronizationRegistered) { synchronizationRegistered = true; getTransactionContext().addSynchronization(new Synchronization() {
public void close() throws JMSException { if (!unconsumedMessages.isClosed()) { if (!deliveredMessages.isEmpty() && session.getTransactionContext().isInTransaction()) { session.getTransactionContext().addSynchronization(new Synchronization() { @Override public void afterCommit() throws Exception {
if (!synchronizationRegistered) { synchronizationRegistered = true; session.getTransactionContext().addSynchronization(new Synchronization() { @Override public void beforeEnd() throws Exception {
private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException { // acks accumulate on the broker pending transaction completion to indicate // delivery status registerSync(); MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1); ack.setTransactionId(session.getTransactionContext().getTransactionId()); session.sendAck(ack); }
public synchronized void dispose() throws JMSException { if (!closed) { try { executor.close(); for (Iterator<ActiveMQMessageConsumer> iter = consumers.iterator(); iter.hasNext();) { ActiveMQMessageConsumer consumer = iter.next(); consumer.setFailureError(connection.getFirstFailureError()); consumer.dispose(); lastDeliveredSequenceId = Math.max(lastDeliveredSequenceId, consumer.getLastDeliveredSequenceId()); } consumers.clear(); for (Iterator<ActiveMQMessageProducer> iter = producers.iterator(); iter.hasNext();) { ActiveMQMessageProducer producer = iter.next(); producer.dispose(); } producers.clear(); try { if (getTransactionContext().isInLocalTransaction()) { rollback(); } } catch (JMSException e) { } } finally { connection.removeSession(this); this.transactionContext = null; closed = true; } } }
previouslyDeliveredMessages = new PreviouslyDeliveredMap<MessageId, Boolean>(session.getTransactionContext().getTransactionId());
private void destroyConsumer() { if (consumer == null) { return; } try { if (session.getTransacted() && session.getTransactionContext().isInLocalTransaction()) { session.commit(); } consumer.close(); consumer = null; } catch (JMSException e) { e.printStackTrace(); } }
/** * Acknowledge all the messages that have been delivered to the client up to * this point. * * @throws JMSException */ public void acknowledge() throws JMSException { clearDeliveredList(); waitForRedeliveries(); synchronized(deliveredMessages) { // Acknowledge all messages so far. MessageAck ack = makeAckForAllDeliveredMessages(MessageAck.STANDARD_ACK_TYPE); if (ack == null) { return; // no msgs } if (session.getTransacted()) { rollbackOnFailedRecoveryRedelivery(); session.doStartTransaction(); ack.setTransactionId(session.getTransactionContext().getTransactionId()); } pendingAck = null; session.sendAck(ack); // Adjust the counters deliveredCounter = Math.max(0, deliveredCounter - deliveredMessages.size()); additionalWindowSize = Math.max(0, additionalWindowSize - deliveredMessages.size()); if (!session.getTransacted()) { deliveredMessages.clear(); } } }
ack.setFirstMessageId(md.getMessage().getMessageId()); doStartTransaction(); ack.setTransactionId(getTransactionContext().getTransactionId()); if (ack.getTransactionId() != null) { getTransactionContext().addSynchronization(new Synchronization() { if (getTransactionContext() != null && getTransactionContext().isInXATransaction()) { LOG.debug("Marking transaction: {} rollbackOnly", getTransactionContext()); getTransactionContext().setRollbackOnly(true);
MessageAck oldPendingAck = pendingAck; pendingAck = new MessageAck(md, ackType, deliveredCounter); pendingAck.setTransactionId(session.getTransactionContext().getTransactionId()); if( oldPendingAck==null ) { pendingAck.setFirstMessageId(pendingAck.getLastMessageId());
void inProgressClearRequired() { inProgressClearRequiredFlag.incrementAndGet(); // deal with delivered messages async to avoid lock contention with in progress acks clearDeliveredList = true; // force a rollback if we will be acking in a transaction after/during failover // bc acks are async they may not get there reliably on reconnect and the consumer // may not be aware of the reconnect in a timely fashion if in onMessage if (!deliveredMessages.isEmpty() && session.getTransactionContext().isInTransaction()) { session.getTransactionContext().setRollbackOnly(true); } }
void inProgressClearRequired() { inProgressClearRequiredFlag.incrementAndGet(); // deal with delivered messages async to avoid lock contention with in progress acks clearDeliveredList = true; // force a rollback if we will be acking in a transaction after/during failover // bc acks are async they may not get there reliably on reconnect and the consumer // may not be aware of the reconnect in a timely fashion if in onMessage if (!deliveredMessages.isEmpty() && session.getTransactionContext().isInTransaction()) { session.getTransactionContext().setRollbackOnly(true); } }
void inProgressClearRequired() { inProgressClearRequiredFlag.incrementAndGet(); // deal with delivered messages async to avoid lock contention with in progress acks clearDeliveredList = true; // force a rollback if we will be acking in a transaction after/during failover // bc acks are async they may not get there reliably on reconnect and the consumer // may not be aware of the reconnect in a timely fashion if in onMessage if (!deliveredMessages.isEmpty() && session.getTransactionContext().isInTransaction()) { session.getTransactionContext().setRollbackOnly(true); } }
protected XAResource createXaResource(PooledSession session) throws JMSException { XAResource xares = new LocalAndXATransaction(session.getSession().getTransactionContext()); if (name != null) { xares = new WrapperNamedXAResource(xares, name); } return xares; }
@Override protected XAResource createXaResource(PooledSession session) throws JMSException { if (session.getInternalSession() instanceof XASession) { return ((XASession)session.getInternalSession()).getXAResource(); } else { return ((ActiveMQSession)session.getInternalSession()).getTransactionContext(); } }
private void destroyConsumer() { if (consumer == null) { return; } try { if (session.getTransacted() && session.getTransactionContext().isInLocalTransaction()) { session.commit(); } consumer.close(); consumer = null; } catch (JMSException e) { e.printStackTrace(); } }
private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException { // acks accumulate on the broker pending transaction completion to indicate // delivery status registerSync(); MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1); ack.setTransactionId(session.getTransactionContext().getTransactionId()); session.sendAck(ack); }
private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException { // acks accumulate on the broker pending transaction completion to indicate // delivery status registerSync(); MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1); ack.setTransactionId(session.getTransactionContext().getTransactionId()); session.sendAck(ack); }
private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException { // acks accumulate on the broker pending transaction completion to indicate // delivery status registerSync(); MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1); ack.setTransactionId(session.getTransactionContext().getTransactionId()); session.sendAck(ack); }