Search in sources :

Example 1 with IntegrationEvent

use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.

the class BoundedContextShould method notify_integration_event_subscriber.

@Test
public void notify_integration_event_subscriber() {
    registerAll();
    final MemoizingObserver<Ack> observer = memoizingObserver();
    final IntegrationEvent event = Given.AnIntegrationEvent.projectCreated();
    final Message msg = unpack(event.getMessage());
    boundedContext.notify(event, observer);
    assertEquals(Responses.statusOk(), observer.firstResponse().getStatus());
    assertEquals(subscriber.getHandledEvent(), msg);
}
Also used : Message(com.google.protobuf.Message) Ack(io.spine.core.Ack) IntegrationEvent(io.spine.server.integration.IntegrationEvent) Test(org.junit.Test)

Example 2 with IntegrationEvent

use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.

the class BoundedContext method notify.

/**
 * Sends an integration event to this {@code BoundedContext}.
 */
@Experimental
@Override
public void notify(IntegrationEvent integrationEvent, StreamObserver<Ack> observer) {
    final Event event = EventFactory.toEvent(integrationEvent);
    eventBus.post(event, observer);
}
Also used : Event(io.spine.core.Event) IntegrationEvent(io.spine.server.integration.IntegrationEvent) Experimental(io.spine.annotation.Experimental)

Example 3 with IntegrationEvent

use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.

the class EventFactory method toEvent.

/**
 * Creates an event based on the passed integration event.
 */
public static Event toEvent(IntegrationEvent integrationEvent) {
    final IntegrationEventContext sourceContext = integrationEvent.getContext();
    final EventContext context = toEventContext(sourceContext);
    final Event result = createEvent(sourceContext.getEventId(), integrationEvent.getMessage(), context);
    return result;
}
Also used : EventContext(io.spine.core.EventContext) IntegrationEventContext(io.spine.server.integration.IntegrationEventContext) IntegrationEventContext(io.spine.server.integration.IntegrationEventContext) Event(io.spine.core.Event) IntegrationEvent(io.spine.server.integration.IntegrationEvent)

Example 4 with IntegrationEvent

use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.

the class EventFactory method toEvent.

/**
     * Creates an event based on the passed integration event.
     */
public static Event toEvent(IntegrationEvent integrationEvent) {
    final IntegrationEventContext sourceContext = integrationEvent.getContext();
    final EventContext context = toEventContext(sourceContext);
    final Event result = createEvent(sourceContext.getEventId(), integrationEvent.getMessage(), context);
    return result;
}
Also used : IntegrationEventContext(io.spine.server.integration.IntegrationEventContext) EventContext(io.spine.base.EventContext) IntegrationEventContext(io.spine.server.integration.IntegrationEventContext) IntegrationEvent(io.spine.server.integration.IntegrationEvent) Event(io.spine.base.Event)

Example 5 with IntegrationEvent

use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.

the class BoundedContext method notify.

@SuppressWarnings("MethodDoesntCallSuperMethod")
/* We ignore method from super because the default implementation sets
           unimplemented status. */
@Override
public void notify(IntegrationEvent integrationEvent, StreamObserver<Response> responseObserver) {
    final Message eventMsg = unpack(integrationEvent.getMessage());
    final boolean isValid = eventBus.validate(eventMsg, responseObserver);
    if (isValid) {
        final Event event = EventFactory.toEvent(integrationEvent);
        eventBus.post(event);
    }
}
Also used : Message(com.google.protobuf.Message) IntegrationEvent(io.spine.server.integration.IntegrationEvent) Event(io.spine.base.Event)

Aggregations

IntegrationEvent (io.spine.server.integration.IntegrationEvent)6 Message (com.google.protobuf.Message)2 Event (io.spine.base.Event)2 Ack (io.spine.core.Ack)2 Event (io.spine.core.Event)2 IntegrationEventContext (io.spine.server.integration.IntegrationEventContext)2 Test (org.junit.Test)2 Any (com.google.protobuf.Any)1 Experimental (io.spine.annotation.Experimental)1 EventContext (io.spine.base.EventContext)1 EventContext (io.spine.core.EventContext)1 BoundedContext (io.spine.server.BoundedContext)1