本文整理汇总了Java中org.jeeventstore.DuplicateCommitException类的典型用法代码示例。如果您正苦于以下问题:Java DuplicateCommitException类的具体用法?Java DuplicateCommitException怎么用?Java DuplicateCommitException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DuplicateCommitException类属于org.jeeventstore包,在下文中一共展示了DuplicateCommitException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_duplicate_commit
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
public void test_duplicate_commit() throws ConcurrencyException {
String id = UUID.randomUUID().toString();
try {
for (int i = 0; i < 2; i++)
persistence.persistChanges(new DefaultChangeSet(
"DEFAULT",
"TEST_DUPLICATE",
i + 1,
id,
new ArrayList<Serializable>()));
fail("Should have failed by now");
} catch (EJBException | DuplicateCommitException e) {
// expected
}
}
示例2: persistChanges
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
private void persistChanges(String commitId)
throws ConcurrencyException, DuplicateCommitException {
long newversion = version + 1;
ChangeSet changes = new DefaultChangeSet(
bucketId,
streamId,
newversion,
commitId,
appendedEvents);
List<ChangeSet> clist = new ArrayList<>();
clist.add(changes);
log.log(Level.FINE, "Persisting commit #{3} {0} into stream {4}/{1}",
new Object[]{commitId, streamId, newversion, bucketId});
persistence.persistChanges(changes);
this.populateWith(clist.iterator());
this.clearChanges();
}
示例3: persistChanges
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Override
public void persistChanges(ChangeSet changeSet)
throws ConcurrencyException, DuplicateCommitException {
if (RESET.equals(changeSet.streamId())) {
this.cleanup();
return;
}
// version 0 -> changeset.size() == 0, i.e. wrong if size > 0
// version 1 -> size == 1
// etc
// we add the changeSet first, such that we can ignore the
// exception in tests where we actually want to create an invalid stream.
changeSets.add(changeSet);
if (changeSets.size() != changeSet.streamVersion())
throw new ConcurrencyException();
}
示例4: test_regular_commit_write_only
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
public void test_regular_commit_write_only() throws Exception {
OptimisticEventStream oes = (OptimisticEventStream) OptimisticEventStream
.createWritable(BUCKET_ID, STREAM_ID, NUM_CHANGESETS, persistence);
List<ChangeSet> beforePersisted = IteratorUtils.toList(persistence.allChanges(BUCKET_ID));
// now commit some data
List<Integer> ints = TestUtils.randomdata(10);
for (Integer i : ints)
oes.append(i);
String commitId = UUID.randomUUID().toString();
try {
oes.commit(commitId);
} catch (DuplicateCommitException | ConcurrencyException e) {
throw new RuntimeException(e);
}
comparePersisted(beforePersisted, NUM_CHANGESETS + 1, ints);
}
示例5: log
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Override
@Asynchronous
public void log(Command<?> command, Map<String, String> metadata) {
Validate.notNull(command, "command must not be null");
Validate.notNull(metadata, "metadata must not be null");
String commandId = command.id().toString();
WritableEventStream stream = streamFor(command);
CommandLogEnvelope<Command<?>> envelope = new CommandLogEnvelope<Command<?>>(command,
new HashMap<>(metadata));
log.log(Level.FINE, "Logging command: {0}", envelope);
stream.append(envelope);
try {
stream.commit(commandId);
} catch (DuplicateCommitException | ConcurrencyException e) {
throw new RuntimeException(e);
}
}
示例6: dispatch
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Override
public void dispatch(Event event) {
log.fine("Dispatch event #" + event.id() + ", " + event);
String eventId = event.id().toString();
String streamId = String.format("%s:%s", event.getClass().getCanonicalName(), eventId);
WritableEventStream stream = eventStore.createStream(sagaTimeoutEventBucketId, streamId);
stream.append(event);
try {
stream.commit(streamId);
} catch (ConcurrencyException | DuplicateCommitException e) {
// this simply means the event has been stored already, this is good,
// we can ignore these errors
log.log(Level.FINE, "Caught exception saving stream with id {0}, but ignored on purpose: {1}",
new Object[]{streamId, e});
}
}
开发者ID:JEEventStore,项目名称:JEECQRS-JCommonDomain-Integration,代码行数:17,代码来源:SagaTrackerPersistingEventBusService.java
示例7: persistChanges
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void persistChanges(ChangeSet changeSet) throws ConcurrencyException, DuplicateCommitException {
if (changeSet == null)
throw new IllegalArgumentException("changeSet must not be null");
String body = createSerializedBody(changeSet);
log.log(Level.FINE, "writing {0} as serialized {1}",
new Object[]{changeSet.changeSetId(), body});
EventStoreEntry entry = createEntry(changeSet, body);
doPersist(changeSet.bucketId(), entry);
log.log(Level.FINE, "wrote ChangeSet {0} to event store, id #{1}",
new Object[]{changeSet.changeSetId(),
Long.toString(entry.id() == null ? -1 : entry.id())});
}
示例8: store
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
private void store(String bucketId, String streamId, Serializable data) {
List<Serializable> events = new ArrayList<>();
events.add(data);
try {
ChangeSet cs = new DefaultChangeSet(
bucketId, streamId, 1,
UUID.randomUUID().toString(),
events);
persistence.persistChanges(cs);
} catch (ConcurrencyException | DuplicateCommitException e) {
throw new RuntimeException(e);
}
}
示例9: test_optimistic_lock
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
public void test_optimistic_lock() throws DuplicateCommitException {
ChangeSet cs = new DefaultChangeSet(
"DEFAULT",
"TEST_49",
5, // exists
UUID.randomUUID().toString(),
new ArrayList<Serializable>());
try {
persistence.persistChanges(cs);
fail("Should have failed by now");
} catch (EJBException | ConcurrencyException e) {
// expected
}
}
示例10: test_persistChanges_nullarg
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
public void test_persistChanges_nullarg() throws ConcurrencyException, DuplicateCommitException {
try {
persistence.persistChanges(null);
fail("Should have failed by now");
} catch (EJBException e) {
// expected
}
}
示例11: commit
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Override
public void commit(String commitId)
throws DuplicateCommitException, ConcurrencyException {
if (commitId == null)
throw new IllegalArgumentException("commitId must not be null");
log.log(Level.FINE, "Attempting to commit changes: {0}", this.streamId);
if (!hasChanges())
return;
this.persistChanges(commitId);
}
示例12: init
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@BeforeMethod
public void init() {
this.persistence = new MockPersistence();
List<ChangeSet> data = TestUtils.createChangeSets("", "", 1, 100);
try {
for (ChangeSet cs : data)
persistence.persistChanges(cs);
} catch (ConcurrencyException | DuplicateCommitException e) {
throw new RuntimeException(e);
}
}
示例13: testConcurrencyFailure
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
private void testConcurrencyFailure() throws DuplicateCommitException {
List<Integer> data = TestUtils.randomdata(10);
ChangeSet cs = new DefaultChangeSet("", "", 100, UUID.randomUUID().toString(), data);
try {
persistence.persistChanges(cs);
fail("Should have failed by now");
} catch (ConcurrencyException e) {
// ok
}
}
示例14: test_persistChanges
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
public void test_persistChanges() throws DuplicateCommitException {
NotifyingPersistenceDecorator decorator = new NotifyingPersistenceDecorator(
this, new TestNotifier());
assertNull(this.persistedChangeset);
assertTrue(!this.received);
ChangeSet cs = new TestChangeSet("TEST_BUCKET", "blabla");
try {
decorator.persistChanges(cs);
} catch (ConcurrencyException e) { }
assertTrue(this.received);
assertEquals(this.persistedChangeset, cs);
}
示例15: test_no_notification_on_exception
import org.jeeventstore.DuplicateCommitException; //导入依赖的package包/类
@Test
public void test_no_notification_on_exception() throws DuplicateCommitException {
NotifyingPersistenceDecorator decorator = new NotifyingPersistenceDecorator(
this, new TestNotifier());
assertNull(this.persistedChangeset);
assertTrue(!this.received);
try {
decorator.persistChanges(null);
fail("Should have failed by now");
} catch (ConcurrencyException e) {
// expected
}
assertTrue(!this.received);
}