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


Java EventData类代码示例

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


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

示例1: appendEvents

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
@Override
public void appendEvents(final String type, final DomainEventStream eventStream) {
   final Map<Object, List<EventData>> identifierToEventStoreEvents = new HashMap<>();
   while (eventStream.hasNext()) {
      final DomainEventMessage message = eventStream.next();
      final Object identifier = message.getAggregateIdentifier();
      if (!identifierToEventStoreEvents.containsKey(identifier)) {
         identifierToEventStoreEvents.put(identifier, new LinkedList<EventData>());
      }
      identifierToEventStoreEvents.get(identifier)
            .add(toEvent(message));
   }
   for (final Entry<Object, List<EventData>> entry : identifierToEventStoreEvents.entrySet()) {
      final String streamName = getStreamName(type, entry.getKey(), prefix);
      final List<EventData> events = entry.getValue();
      client.appendToStream(streamName, ExpectedVersion.ANY, events);
   }
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:19,代码来源:EsjcEventStore.java

示例2: toEvent

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
private EventData toEvent(final DomainEventMessage message) {
   final HashMap<String, Object> metaData = new HashMap<>();
   final HashMap<String, Object> eventMetaData = new HashMap<>();
   for (final Entry<String, Object> entry : message.getMetaData()
         .entrySet()) {
      eventMetaData.put(entry.getKey(), entry.getValue());
   }

   metaData.put(Constants.AGGREGATE_ID_KEY, message.getAggregateIdentifier());
   metaData.put(Constants.PAYLOAD_REVISION_KEY, getPayloadRevision(message.getPayloadType()));
   metaData.put(Constants.EVENT_METADATA_KEY, eventMetaData);

   return EventData.newBuilder()
         .eventId(UUID.fromString(message.getIdentifier())) // TODO check if it is save to assume that this can always be converted to a UUID
         .jsonData(serialize(message.getPayload()))
         .type(message.getPayloadType()
               .getName())
         .metadata(serialize(metaData))
         .build();
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:21,代码来源:EsjcEventStore.java

示例3: matchesSafely

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
@Override
protected boolean matchesSafely(List<RecordedEvent> actual) {
    if (expected.size() == actual.size()) {
        for (int i = 0; i < expected.size(); i++) {
            EventData expectedItem = expected.get(i);
            RecordedEvent actualItem = actual.get(i);

            elementMatcher = RecordedEventMatcher.equalTo(expectedItem);
            elementIndex = i;

            if (!elementMatcher.matches(actualItem)) {
                return false;
            }
        }

        return true;
    } else {
        return false;
    }
}
 
开发者ID:msemys,项目名称:esjc,代码行数:21,代码来源:RecordedEventListMatcher.java

示例4: AppendToStreamOperation

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
public AppendToStreamOperation(CompletableFuture<WriteResult> result,
                               boolean requireMaster,
                               String stream,
                               long expectedVersion,
                               Iterable<EventData> events,
                               UserCredentials userCredentials) {
    super(result, TcpCommand.WriteEvents, TcpCommand.WriteEventsCompleted, userCredentials);
    this.requireMaster = requireMaster;
    this.stream = stream;
    this.expectedVersion = expectedVersion;
    this.events = events;
}
 
开发者ID:msemys,项目名称:esjc,代码行数:13,代码来源:AppendToStreamOperation.java

示例5: TransactionalWriteOperation

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
public TransactionalWriteOperation(CompletableFuture<Void> result,
                                   boolean requireMaster,
                                   long transactionId,
                                   Iterable<EventData> events,
                                   UserCredentials userCredentials) {
    super(result, TcpCommand.TransactionWrite, TcpCommand.TransactionWriteCompleted, userCredentials);
    this.requireMaster = requireMaster;
    this.transactionId = transactionId;
    this.events = events;
}
 
开发者ID:msemys,项目名称:esjc,代码行数:11,代码来源:TransactionalWriteOperation.java

示例6: convert

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
/**
 * Converts a common event into event data.
 * 
 * @param commonEvent
 *            Event to convert.
 * 
 * @return Converted event as event data.
 */
@Override
public final EventData convert(final CommonEvent commonEvent) {

    // User's data
    final String dataType = commonEvent.getDataType().asBaseType();
    final SerializedDataType serUserDataType = new SerializedDataType(dataType);
    final Serializer userDataSerializer = serRegistry.getSerializer(serUserDataType);
    final byte[] serUserData = userDataSerializer.marshal(commonEvent.getData());
    final byte[] serData;
    if (userDataSerializer.getMimeType().matchEncoding(targetContentType)) {
        serData = serUserData;
    } else {
        final Base64Data base64data = new Base64Data(serUserData);
        final Serializer base64Serializer = serRegistry.getSerializer(Base64Data.SER_TYPE);
        serData = base64Serializer.marshal(base64data);
    }

    // EscMeta
    final EscMeta escMeta = EscSpiUtils.createEscMeta(serRegistry, targetContentType, commonEvent);
    final Serializer escMetaSerializer = getSerializer(EscMeta.TYPE);
    final byte[] escSerMeta = escMetaSerializer.marshal(escMeta);

    // Create event data
    final EventData.Builder builder = EventData.newBuilder().eventId(commonEvent.getId().asBaseType())
            .type(dataType);
    if (targetContentType.isJson()) {
        builder.jsonData(serData);
        builder.jsonMetadata(escSerMeta);
    } else {
        builder.data(serData);
        builder.metadata(escSerMeta);
    }
    return builder.build();

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:44,代码来源:CommonEvent2EventDataConverter.java

示例7: asEventData

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
private List<EventData> asEventData(final List<CommonEvent> commonEvents) {
    final List<EventData> list = new ArrayList<>(commonEvents.size());
    for (final CommonEvent commonEvent : commonEvents) {
        list.add(ce2edConv.convert(commonEvent));
    }
    return list;
}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:8,代码来源:ESJCEventStore.java

示例8: main

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, ExecutionException {

        EventStore es = EventStoreBuilder.newBuilder().singleNodeAddress("127.0.0.1", 1113).build();
        es.connect();
        try {

            // Create stream by appending something to it
            String streamId = "MyStream";
            List<EventData> events = new ArrayList<>();
            events.add(EventData.newBuilder().eventId(UUID.randomUUID()).type("baz").data("dummy content")
                    .build());
            es.appendToStream(streamId, ExpectedVersion.any(), events).join();

            // Hard delete
            es.deleteStream(streamId, ExpectedVersion.any(), true).join();

            // Get status
            final StreamMetadataResult result = es.getStreamMetadata(streamId).get();
            if (result.isStreamDeleted) {
                // === THIS IS PRINTED ===
                System.out.println("SOFT DELETED");
            } else {
                System.out.println("HARD DELETED");
            }

        } finally {
            es.disconnect();
        }

    }
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:31,代码来源:NativeDeleteTest.java

示例9: testConvert

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
@Test
public final void testConvert() {

    // PREPARE
    final EnhancedMimeType targetContentType = EnhancedMimeType.create("application", "json",
            Charset.forName("utf-8"));
    final SimpleSerializerDeserializerRegistry serRegistry = new SimpleSerializerDeserializerRegistry();
    final JsonDeSerializer deserializer = new JsonDeSerializer();
    serRegistry.addSerializer(new SerializedDataType("MyData"), deserializer);
    serRegistry.addSerializer(new SerializedDataType("MyMeta"), deserializer);
    serRegistry.addSerializer(new SerializedDataType(EscMeta.TYPE.asBaseType()), deserializer);

    final EventId id = new EventId();
    final TypeName dataType = new TypeName("MyData");
    final Object data = Json.createObjectBuilder().add("id", 1).add("name", "Peter").build();
    final TypeName metaType = new TypeName("MyMeta");
    final Object meta = Json.createObjectBuilder().add("ip", "127.0.0.1").build();
    final CommonEvent commonEvent = new SimpleCommonEvent(id, dataType, data, metaType, meta);

    final CommonEvent2EventDataConverter testee = new CommonEvent2EventDataConverter(serRegistry,
            targetContentType);

    // TEST
    final EventData eventData = testee.convert(commonEvent);

    // VERIFY
    assertThat(eventData.eventId).isEqualTo(commonEvent.getId().asBaseType());
    assertThat(eventData.type).isEqualTo(commonEvent.getDataType().asBaseType());
    assertThat(eventData.isJsonData).isTrue();
    assertThat(new String(eventData.data, deserializer.getMimeType().getEncoding()))
            .isEqualTo("{\"id\":1,\"name\":\"Peter\"}");
    assertThat(eventData.isJsonMetadata).isTrue();
    assertThat(new String(eventData.metadata, deserializer.getMimeType().getEncoding())).isEqualTo(
            "{\"data-type\":\"MyData\"," + "\"data-content-type\":\"application/json; encoding=UTF-8\","
                    + "\"meta-type\":\"MyMeta\",\"meta-content-type\":\"application/json; encoding=UTF-8\","
                    + "\"MyMeta\":{\"ip\":\"127.0.0.1\"}}");

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:39,代码来源:CommonEvent2EventDataConverterTest.java

示例10: write

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
default CompletableFuture<Void> write(Transaction transaction, Iterable<EventData> events) {
    return write(transaction, events, null);
}
 
开发者ID:msemys,项目名称:esjc,代码行数:4,代码来源:TransactionManager.java

示例11: RecordedEventMatcher

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
public RecordedEventMatcher(EventData expected) {
    this.expected = expected;
}
 
开发者ID:msemys,项目名称:esjc,代码行数:4,代码来源:RecordedEventMatcher.java

示例12: equalTo

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
@Factory
public static Matcher<RecordedEvent> equalTo(EventData item) {
    return new RecordedEventMatcher(item);
}
 
开发者ID:msemys,项目名称:esjc,代码行数:5,代码来源:RecordedEventMatcher.java

示例13: RecordedEventListMatcher

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
public RecordedEventListMatcher(List<EventData> expected) {
    this.expected = expected;
}
 
开发者ID:msemys,项目名称:esjc,代码行数:4,代码来源:RecordedEventListMatcher.java

示例14: containsInOrder

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
@Factory
public static Matcher<List<RecordedEvent>> containsInOrder(List<EventData> items) {
    return new RecordedEventListMatcher(items);
}
 
开发者ID:msemys,项目名称:esjc,代码行数:5,代码来源:RecordedEventListMatcher.java

示例15: getTargetType

import com.github.msemys.esjc.EventData; //导入依赖的package包/类
@Override
public final Class<EventData> getTargetType() {
    return EventData.class;
}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:5,代码来源:CommonEvent2EventDataConverter.java


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