本文整理汇总了Java中com.networknt.tram.event.common.DomainEvent类的典型用法代码示例。如果您正苦于以下问题:Java DomainEvent类的具体用法?Java DomainEvent怎么用?Java DomainEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DomainEvent类属于com.networknt.tram.event.common包,在下文中一共展示了DomainEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageHandler
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public void messageHandler(Message message) {
String aggregateType = message.getRequiredHeader(EventMessageHeaders.AGGREGATE_TYPE);
Optional<DomainEventHandler> handler = domainEventHandlers.findTargetMethod(message);
if (!handler.isPresent()) {
return;
}
DomainEvent param = JSonMapper.fromJson(message.getPayload(), handler.get().getEventClass());
handler.get().invoke(new DomainEventEnvelopeImpl<>(message,
aggregateType,
message.getRequiredHeader(EventMessageHeaders.AGGREGATE_ID),
message.getRequiredHeader(Message.ID),
param));
}
示例2: publish
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
@Override
public void publish(String aggregateType, Object aggregateId, Map<String, String> headers, List<DomainEvent> domainEvents) {
for (DomainEvent event : domainEvents) {
messageProducer.send(aggregateType,
makeMessageForDomainEvent(aggregateType, aggregateId, headers, event));
}
}
示例3: makeMessageForDomainEvent
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public static Message makeMessageForDomainEvent(String aggregateType, Object aggregateId, Map<String, String> headers, DomainEvent event) {
String aggregateIdAsString = aggregateId.toString();
return MessageBuilder
.withPayload(JSonMapper.toJson(event))
.withExtraHeaders("", headers)
.withHeader(Message.PARTITION_ID, aggregateIdAsString)
.withHeader(EventMessageHeaders.AGGREGATE_ID, aggregateIdAsString)
.withHeader(EventMessageHeaders.AGGREGATE_TYPE, aggregateType)
.withHeader(EventMessageHeaders.EVENT_TYPE, event.getClass().getName())
.build();
}
示例4: ResultWithEvents
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public ResultWithEvents(T result, List<DomainEvent> events) {
this.result = result;
this.events = events;
}
示例5: publish
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
default void publish(Class<?> aggregateType, Object aggregateId, List<DomainEvent> domainEvents) {
publish(aggregateType.getName(), aggregateId, domainEvents);
}
示例6: DomainEventHandler
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public DomainEventHandler(String aggregateType, Class<DomainEvent> eventClass, Consumer<DomainEventEnvelope<DomainEvent>> handler) {
this.aggregateType = aggregateType;
this.eventClass = eventClass;
this.handler = handler;
}
示例7: invoke
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public void invoke(DomainEventEnvelope<DomainEvent> dee) {
handler.accept(dee);
}
示例8: getEventClass
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public Class<DomainEvent> getEventClass() {
return eventClass;
}
示例9: onEvent
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <E extends DomainEvent> DomainEventHandlersBuilder onEvent(Class<E> eventClass, Consumer<DomainEventEnvelope<E>> handler) {
handlers.add(new DomainEventHandler(aggregateType, ((Class<DomainEvent>) eventClass), (e) -> handler.accept((DomainEventEnvelope<E>) e)));
return this;
}
示例10: EventClassAndAggregateId
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public EventClassAndAggregateId(Class<DomainEvent> eventClass, Long aggregateId) {
this.eventClass = eventClass;
this.aggregateId = aggregateId;
}
示例11: EventToPublish
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public EventToPublish(Class aggregateType, String aggregateId, List<DomainEvent> domainEvents) {
this.aggregateType = aggregateType;
this.aggregateId = aggregateId;
this.domainEvents = domainEvents;
}
示例12: getDomainEvents
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public List<DomainEvent> getDomainEvents() {
return domainEvents;
}
示例13: SagaEventHandler
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public SagaEventHandler(Class<DomainEvent> eventClass, Function<Data, Long> aggregateIdProvider, SagaStateMachineAction<Data, DomainEventEnvelope<DomainEvent>> action) {
this.eventClass = eventClass;
this.aggregateIdProvider = aggregateIdProvider;
this.action = action;
}
示例14: make
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public static <Data> SagaEventHandler make(Class<DomainEvent> eventClass, Function<Data, Long> aggregateIdProvider,
SagaStateMachineAction<Data, DomainEventEnvelope<DomainEvent>> eventHandler) {
return new SagaEventHandler<Data>(eventClass, aggregateIdProvider, eventHandler);
}
示例15: getAction
import com.networknt.tram.event.common.DomainEvent; //导入依赖的package包/类
public SagaStateMachineAction<Data, DomainEventEnvelope<DomainEvent>> getAction() {
return action;
}