Class InboundEventMessageChannelAdapter
java.lang.Object
org.axonframework.extension.spring.messaging.InboundEventMessageChannelAdapter
- All Implemented Interfaces:
SubscribableEventSource,org.springframework.messaging.MessageHandler
public class InboundEventMessageChannelAdapter
extends Object
implements org.springframework.messaging.MessageHandler, SubscribableEventSource
Adapter class that publishes Events from a Spring Messaging Message Channel on the Event Bus. All events are
expected to be contained in the payload of the Message instances.
Optionally, this adapter can be configured with a filter, which can block or accept messages based on their type.
- Since:
- 3.0
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionInitialize the adapter to publish all incoming events to the subscribed processors.InboundEventMessageChannelAdapter(List<BiFunction<List<? extends EventMessage>, ProcessingContext, CompletableFuture<?>>> processors, EventMessageConverter eventMessageConverter) Initialize the adapter to publish all incoming events to the subscribed processors.InboundEventMessageChannelAdapter(EventBus eventBus) Initialize an InboundEventMessageChannelAdapter instance that sends all incoming Event Messages to the giveneventBus. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleMessage(org.springframework.messaging.Message message) Handles the givenmessage.subscribe(BiFunction<List<? extends EventMessage>, ProcessingContext, CompletableFuture<?>> eventsBatchConsumer) Subscribe the giveneventsBatchConsumerto this event source.protected EventMessagetransformMessage(org.springframework.messaging.Message message) Transforms the given incoming Spring Messagingmessageto an Axon EventMessage.
-
Constructor Details
-
InboundEventMessageChannelAdapter
public InboundEventMessageChannelAdapter()Initialize the adapter to publish all incoming events to the subscribed processors. Note that this instance should be registered as a consumer of a Spring Message Channel. -
InboundEventMessageChannelAdapter
Initialize an InboundEventMessageChannelAdapter instance that sends all incoming Event Messages to the giveneventBus. It is still possible for other Event Processors to subscribe to this MessageChannelAdapter.- Parameters:
eventBus- The EventBus instance for forward all messages to
-
InboundEventMessageChannelAdapter
public InboundEventMessageChannelAdapter(List<BiFunction<List<? extends EventMessage>, ProcessingContext, CompletableFuture<?>>> processors, EventMessageConverter eventMessageConverter) Initialize the adapter to publish all incoming events to the subscribed processors. Note that this instance should be registered as a consumer of a Spring Message Channel.- Parameters:
processors- Processors to be subscribedeventMessageConverter- The message converter to use to convert spring message into event message
-
-
Method Details
-
subscribe
@Nonnull public Registration subscribe(@Nonnull BiFunction<List<? extends EventMessage>, ProcessingContext, CompletableFuture<?>> eventsBatchConsumer) Description copied from interface:SubscribableEventSourceSubscribe the giveneventsBatchConsumerto this event source. When subscribed, it will receive all events published to this source since the subscription.If the given
eventsBatchConsumeris already subscribed, nothing happens.Note on
ProcessingContext: TheProcessingContextparameter passed to the consumer may benull. Whennull, it is the responsibility of the registeredeventsBatchConsumerto create an appropriateProcessingContextas needed for processing the events.- Specified by:
subscribein interfaceSubscribableEventSource- Parameters:
eventsBatchConsumer- The event batches consumer to subscribe.- Returns:
- A
Registrationhandle to unsubscribe theeventsBatchConsumer. When unsubscribed, it will no longer receive events.
-
handleMessage
public void handleMessage(@Nonnull org.springframework.messaging.Message message) Handles the givenmessage. If the filter refuses the message, it is ignored.- Specified by:
handleMessagein interfaceorg.springframework.messaging.MessageHandler- Parameters:
message- The message containing the event to publish
-
transformMessage
Transforms the given incoming Spring Messagingmessageto an Axon EventMessage. This method may be overridden to change how messages are translated between the two frameworks.- Parameters:
message- the Spring message to convert to an event- Returns:
- an EventMessage from given Spring message
-