当前位置: 首页>>代码示例>>Java>>正文


Java WritableEventStream类代码示例

本文整理汇总了Java中org.jeeventstore.WritableEventStream的典型用法代码示例。如果您正苦于以下问题:Java WritableEventStream类的具体用法?Java WritableEventStream怎么用?Java WritableEventStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WritableEventStream类属于org.jeeventstore包,在下文中一共展示了WritableEventStream类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOpenStreamForWritingConcurrency

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
@Test
public void testOpenStreamForWritingConcurrency() throws Exception {
    cleanup();
    fill(BUCKET_ID, "FOO", 10);
    caught = false;
    caughtCS = null;
    WritableEventStream wes = eventStore.openStreamForWriting(BUCKET_ID, "FOO", 8);
    wes.append("bla");
    try {
        wes.commit(UUID.randomUUID().toString());
        fail("Should have failed by now");
    } catch (ConcurrencyException e) {
        // expected
    }
    assertTrue(!caught);
    assertTrue(caughtCS == null);
    assertEquals(BUCKET_ID, wes.bucketId());
    assertEquals("FOO", wes.streamId());
}
 
开发者ID:JEEventStore,项目名称:JEEventStore,代码行数:20,代码来源:OptimisticEventStoreServiceTest.java

示例2: log

import org.jeeventstore.WritableEventStream; //导入依赖的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);
    }
}
 
开发者ID:JEEventStore,项目名称:JEECQRS-JCommonDomain-Integration,代码行数:18,代码来源:CommandLoggerService.java

示例3: dispatch

import org.jeeventstore.WritableEventStream; //导入依赖的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

示例4: fill

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
private void fill(String bucketId, String streamId, int count) throws Exception {
    WritableEventStream wes = eventStore.createStream(bucketId, streamId);
    for (int i = 0; i < count; i++) {
        List<Integer> data = TestUtils.randomdata(i % 5 + 1);
        for (Integer ii : data)
            wes.append(ii);
        wes.commit(UUID.randomUUID().toString());
    }
}
 
开发者ID:JEEventStore,项目名称:JEEventStore,代码行数:10,代码来源:OptimisticEventStoreServiceTest.java

示例5: testCreateStream

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
@Test
public void testCreateStream() throws Exception {
    cleanup();
    WritableEventStream wes = eventStore.createStream(BUCKET_ID, "CREATED");
    assertEquals(wes.version(), 0);
    testWriting(wes);
    assertEquals(BUCKET_ID, wes.bucketId());
    assertEquals("CREATED", wes.streamId());
}
 
开发者ID:JEEventStore,项目名称:JEEventStore,代码行数:10,代码来源:OptimisticEventStoreServiceTest.java

示例6: testOpenStreamForWriting

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
@Test
public void testOpenStreamForWriting() throws Exception {
    cleanup();
    fill(BUCKET_ID, "FOO", 10);
    WritableEventStream wes = eventStore.openStreamForWriting(BUCKET_ID, "FOO", 10);
    assertEquals(wes.version(), 10);
    testWriting(wes);
    assertEquals(BUCKET_ID, wes.bucketId());
    assertEquals("FOO", wes.streamId());
}
 
开发者ID:JEEventStore,项目名称:JEEventStore,代码行数:11,代码来源:OptimisticEventStoreServiceTest.java

示例7: test_create_writeable

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
@Test
public void test_create_writeable() {
    WritableEventStream oes = OptimisticEventStream.createWritable(BUCKET_ID, STREAM_ID, 28l, persistence);
    assertEquals(oes.bucketId(), BUCKET_ID);
    assertEquals(oes.streamId(), STREAM_ID);
    assertEquals(28l, oes.version());
}
 
开发者ID:JEEventStore,项目名称:JEEventStore,代码行数:8,代码来源:OptimisticEventStreamTest.java

示例8: busForStream

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
private EventSourcingBus<Event> busForStream(final WritableEventStream stream) {
    return new EventSourcingBus<Event>() {
        @Override
        public void store(Event event) {
            appendToStream(stream, event);
        }
        @Override
        public void commit(String commitId) {
            commitChanges(stream, commitId);
        }
    };
}
 
开发者ID:JEEventStore,项目名称:JCommonDomain,代码行数:13,代码来源:AbstractJEEventStoreRepository.java

示例9: commitChanges

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
protected void commitChanges(WritableEventStream stream, String commitId) {
    try {
        stream.commit(commitId);
    } catch (DuplicateCommitException | ConcurrencyException e) {
        throw new RuntimeException("committing changes failed: " + e.getMessage(), e);
    }
}
 
开发者ID:JEEventStore,项目名称:JCommonDomain,代码行数:8,代码来源:AbstractJEEventStoreRepository.java

示例10: busForAdd

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
@Override
protected EventSourcingBus<Event> busForAdd(String streamId) {
    WritableEventStream stream = eventStore().createStream(bucketId(), streamId);
    return busForStream(stream);
}
 
开发者ID:JEEventStore,项目名称:JCommonDomain,代码行数:6,代码来源:AbstractJEEventStoreRepository.java

示例11: busForSave

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
@Override
protected EventSourcingBus<Event> busForSave(String streamId, long version) {
    WritableEventStream stream = eventStore().openStreamForWriting(bucketId(), streamId, version);
    return busForStream(stream);
}
 
开发者ID:JEEventStore,项目名称:JCommonDomain,代码行数:6,代码来源:AbstractJEEventStoreRepository.java

示例12: appendToStream

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
protected void appendToStream(WritableEventStream stream, Event event) {
    stream.append(event);
}
 
开发者ID:JEEventStore,项目名称:JCommonDomain,代码行数:4,代码来源:AbstractJEEventStoreRepository.java

示例13: streamFor

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
protected WritableEventStream streamFor(Command command) {
    return eventStore.createStream(commandBucketId, streamIdFor(command));
}
 
开发者ID:JEEventStore,项目名称:JEECQRS-JCommonDomain-Integration,代码行数:4,代码来源:CommandLoggerService.java

示例14: createWritable

import org.jeeventstore.WritableEventStream; //导入依赖的package包/类
/**
 * Factory method to create a new writable event stream supporting optimistic locking.
 * Does not query the persistence layer upon creation.
 * 
 * @param bucketId  the identifier of the bucket the stream belongs to
 * @param streamId  the identifier of the stream
 * @param version   the version of the stream
 * @param persistence  the persistence layer to which changes are to be committed
 * @return  the stream
 */
protected static WritableEventStream createWritable(
        String bucketId,
        String streamId, 
        long version,
        EventStorePersistence persistence) {
    
    return new OptimisticEventStream(bucketId, streamId, version, persistence);
}
 
开发者ID:JEEventStore,项目名称:JEEventStore,代码行数:19,代码来源:OptimisticEventStream.java


注:本文中的org.jeeventstore.WritableEventStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。