Search in sources :

Example 1 with LocalTxQueueTransactionRecoverer

use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer in project mule by mulesoft.

the class LocalTxQueueTransactionRecovererTestCase method offerAndFailBetweenRealOfferAndCommitThenRecover.

@Test
public void offerAndFailBetweenRealOfferAndCommitThenRecover() throws Exception {
    txLog = new TestTransactionLogger(temporaryFolder.getRoot().getAbsolutePath(), muleContext).failDuringLogCommit();
    final DefaultQueueStore outQueue = new DefaultQueueStore(QUEUE_NAME, muleContext, new DefaultQueueConfiguration(0, true));
    persistentTransactionContext = new PersistentQueueTransactionContext(txLog, createQueueProvider(outQueue));
    persistentTransactionContext.offer(outQueue, testEvent(), TIMEOUT);
    try {
        persistentTransactionContext.doCommit();
        fail();
    } catch (ResourceManagerException e) {
    // expected
    }
    txLog.close();
    txLog = new TestTransactionLogger(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
    queueTransactionRecoverer = new LocalTxQueueTransactionRecoverer(txLog, createQueueProvider(outQueue));
    queueTransactionRecoverer.recover();
    Serializable muleEvent = outQueue.poll(TIMEOUT);
    assertThat(muleEvent, nullValue());
}
Also used : Serializable(java.io.Serializable) DefaultQueueConfiguration(org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration) LocalTxQueueTransactionRecoverer(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer) ResourceManagerException(org.mule.runtime.core.api.transaction.xa.ResourceManagerException) Test(org.junit.Test)

Example 2 with LocalTxQueueTransactionRecoverer

use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer in project mule by mulesoft.

the class LocalTxQueueTransactionRecovererTestCase method doSetUp.

@Override
protected void doSetUp() throws Exception {
    ((DefaultMuleConfiguration) muleContext.getConfiguration()).setWorkingDirectory(temporaryFolder.getRoot().getAbsolutePath());
    txLog = new LocalTxQueueTransactionJournal(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
    inQueue = new DefaultQueueStore(QUEUE_NAME, muleContext, new DefaultQueueConfiguration(0, true));
    persistentTransactionContext = new PersistentQueueTransactionContext(txLog, createQueueProvider(inQueue));
    queueTransactionRecoverer = new LocalTxQueueTransactionRecoverer(txLog, createQueueProvider(inQueue));
}
Also used : DefaultQueueConfiguration(org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration) DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) LocalTxQueueTransactionRecoverer(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer) LocalTxQueueTransactionJournal(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal)

Example 3 with LocalTxQueueTransactionRecoverer

use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer in project mule by mulesoft.

the class LocalTxQueueTransactionRecovererTestCase method offerAndFailThenRecover.

@Test
public void offerAndFailThenRecover() throws Exception {
    final DefaultQueueStore outQueue = new DefaultQueueStore(QUEUE_NAME, muleContext, new DefaultQueueConfiguration(0, true));
    persistentTransactionContext = new PersistentQueueTransactionContext(txLog, createQueueProvider(outQueue));
    persistentTransactionContext.offer(outQueue, testEvent(), TIMEOUT);
    assertThat(outQueue.poll(TIMEOUT), nullValue());
    txLog.close();
    txLog = new LocalTxQueueTransactionJournal(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
    queueTransactionRecoverer = new LocalTxQueueTransactionRecoverer(txLog, createQueueProvider(outQueue));
    queueTransactionRecoverer.recover();
    Serializable muleEvent = outQueue.poll(TIMEOUT);
    assertThat(muleEvent, nullValue());
}
Also used : Serializable(java.io.Serializable) DefaultQueueConfiguration(org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration) LocalTxQueueTransactionRecoverer(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer) LocalTxQueueTransactionJournal(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal) Test(org.junit.Test)

Example 4 with LocalTxQueueTransactionRecoverer

use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer in project mule by mulesoft.

the class TransactionalQueueManager method initialise.

@Override
public void initialise() throws InitialisationException {
    String workingDirectory = getMuleContext().getConfiguration().getWorkingDirectory();
    int queueTransactionFilesSizeInMegabytes = getMuleContext().getConfiguration().getMaxQueueTransactionFilesSizeInMegabytes();
    localTxTransactionJournal = new LocalTxQueueTransactionJournal(workingDirectory + File.separator + "queue-tx-log", getMuleContext(), queueTransactionFilesSizeInMegabytes);
    localTxQueueTransactionRecoverer = new LocalTxQueueTransactionRecoverer(localTxTransactionJournal, this);
    xaTransactionJournal = new XaTxQueueTransactionJournal(workingDirectory + File.separator + "queue-xa-tx-log", getMuleContext(), queueTransactionFilesSizeInMegabytes);
    xaTransactionRecoverer = new XaTransactionRecoverer(xaTransactionJournal, this);
}
Also used : LocalTxQueueTransactionRecoverer(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer) XaTxQueueTransactionJournal(org.mule.runtime.core.internal.util.journal.queue.XaTxQueueTransactionJournal) XaTransactionRecoverer(org.mule.runtime.core.internal.util.xa.XaTransactionRecoverer) LocalTxQueueTransactionJournal(org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal)

Aggregations

LocalTxQueueTransactionRecoverer (org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionRecoverer)4 DefaultQueueConfiguration (org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration)3 LocalTxQueueTransactionJournal (org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal)3 Serializable (java.io.Serializable)2 Test (org.junit.Test)2 DefaultMuleConfiguration (org.mule.runtime.core.api.config.DefaultMuleConfiguration)1 ResourceManagerException (org.mule.runtime.core.api.transaction.xa.ResourceManagerException)1 XaTxQueueTransactionJournal (org.mule.runtime.core.internal.util.journal.queue.XaTxQueueTransactionJournal)1 XaTransactionRecoverer (org.mule.runtime.core.internal.util.xa.XaTransactionRecoverer)1