use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal in project mule by mulesoft.
the class LocalTxQueueTransactionRecovererTestCase method pollAndFailThenRecover.
@Test
public void pollAndFailThenRecover() throws Exception {
inQueue.offer(testEvent(), 0, TIMEOUT);
Serializable value = persistentTransactionContext.poll(inQueue, 100000);
assertThat(inQueue.poll(TIMEOUT), nullValue());
assertThat(value, notNullValue());
txLog.close();
txLog = new LocalTxQueueTransactionJournal(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
queueTransactionRecoverer.recover();
CoreEvent muleEvent = (CoreEvent) inQueue.poll(TIMEOUT);
assertThat(muleEvent, notNullValue());
assertThat(testEvent().getContext().getId(), equalTo(muleEvent.getContext().getId()));
}
use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal in project mule by mulesoft.
the class LocalTxQueueTransactionRecovererTestCase method failBetweenLogEntryWriteAndRealPoolThenRecover.
@Test
public void failBetweenLogEntryWriteAndRealPoolThenRecover() throws Exception {
inQueue.offer(testEvent(), 0, TIMEOUT);
persistentTransactionContext.poll(inQueue, TIMEOUT);
txLog.close();
txLog = new LocalTxQueueTransactionJournal(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
queueTransactionRecoverer.recover();
CoreEvent muleEvent = (CoreEvent) inQueue.poll(TIMEOUT);
assertThat(muleEvent, notNullValue());
assertThat(testEvent().getContext().getId(), equalTo(muleEvent.getContext().getId()));
muleEvent = (CoreEvent) inQueue.poll(TIMEOUT);
assertThat(muleEvent, nullValue());
}
use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal in project mule by mulesoft.
the class LocalTxQueueTransactionRecovererTestCase method pollAndFailThenRecoverWithTwoElements.
@Test
public void pollAndFailThenRecoverWithTwoElements() throws Exception {
final String MESSAGE_CONTENT_2 = TEST_PAYLOAD + "2";
CoreEvent testEvent2 = eventBuilder(muleContext).message(of(MESSAGE_CONTENT_2)).build();
inQueue.offer(testEvent(), 0, TIMEOUT);
inQueue.offer(testEvent2, 0, TIMEOUT);
Serializable value = persistentTransactionContext.poll(inQueue, 100000);
assertThat(inQueue.getSize(), is(1));
assertThat(value, notNullValue());
txLog.close();
txLog = new LocalTxQueueTransactionJournal(temporaryFolder.getRoot().getAbsolutePath(), muleContext);
queueTransactionRecoverer.recover();
CoreEvent muleEvent = (CoreEvent) inQueue.poll(TIMEOUT);
assertThat(muleEvent, notNullValue());
// recovered element should be
assertThat(muleEvent.getMessage().getPayload().getValue().toString(), is(MESSAGE_CONTENT_2));
// last
muleEvent = (CoreEvent) inQueue.poll(TIMEOUT);
assertThat(muleEvent, notNullValue());
// recovered element
assertThat(muleEvent.getMessage().getPayload().getValue().toString(), is(TEST_PAYLOAD));
}
use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal 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));
}
use of org.mule.runtime.core.internal.util.journal.queue.LocalTxQueueTransactionJournal 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());
}
Aggregations