org.axonframework.eventhandling.replay
Class DiscardingIncomingMessageHandler

java.lang.Object
  extended by org.axonframework.eventhandling.replay.DiscardingIncomingMessageHandler
All Implemented Interfaces:
IncomingMessageHandler

public class DiscardingIncomingMessageHandler
extends Object
implements IncomingMessageHandler

IncomingMessageHandler implementation that simply discards all messages dispatch during a replay process. This handler is typically useful when not expecting to perform a replay while the cluster is actively listening to events on a command bus, for example when performing an offline replay.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
DiscardingIncomingMessageHandler()
           
 
Method Summary
 void onIncomingMessages(Cluster destination, EventMessage... messages)
          Invoked while the ReplayingCluster is in replay mode and an Event is being dispatched to the Cluster.
 void onReplayFailed(Cluster destination, RuntimeException cause)
          Invoked when a replay has failed.
 void prepareForReplay(Cluster destination)
          Invoked just before replay mode is activated.
 void processBacklog(Cluster destination)
          Invoked when all events from the Event Store have been processed.
 void releaseMessage(DomainEventMessage message)
          Invoked when a message has been replayed from the event store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscardingIncomingMessageHandler

public DiscardingIncomingMessageHandler()
Method Detail

prepareForReplay

public void prepareForReplay(Cluster destination)
Description copied from interface: IncomingMessageHandler
Invoked just before replay mode is activated. Any messages passed to IncomingMessageHandler.onIncomingMessages(org.axonframework.eventhandling.Cluster, org.axonframework.domain.EventMessage[]) prior to this method invocation should be dispatched immediately to the destination cluster to prevent message loss.

This method is invoked in the thread that executes the replay process.

Specified by:
prepareForReplay in interface IncomingMessageHandler
Parameters:
destination - The cluster on which events are about te be replayed

onIncomingMessages

public void onIncomingMessages(Cluster destination,
                               EventMessage... messages)
Description copied from interface: IncomingMessageHandler
Invoked while the ReplayingCluster is in replay mode and an Event is being dispatched to the Cluster. If the timestamp of the given message is before the timestamp of any message reported via IncomingMessageHandler.releaseMessage(org.axonframework.domain.DomainEventMessage), consider discarding the incoming message.

This method is invoked in the thread that attempts to publish the given messages to the given destination.

Specified by:
onIncomingMessages in interface IncomingMessageHandler
Parameters:
destination - The cluster to receive the message
messages - The messages to dispatch to the cluster

releaseMessage

public void releaseMessage(DomainEventMessage message)
Description copied from interface: IncomingMessageHandler
Invoked when a message has been replayed from the event store. If such a message has been received with IncomingMessageHandler.onIncomingMessages(org.axonframework.eventhandling.Cluster, org.axonframework.domain.EventMessage[]), it should be discarded.

After this invocation, any invocation of IncomingMessageHandler.onIncomingMessages(org.axonframework.eventhandling.Cluster, org.axonframework.domain.EventMessage[]) with a message who's timestamp is lower that this message's timestamp can be safely discarded.

This method is invoked in the thread that executes the replay process

Specified by:
releaseMessage in interface IncomingMessageHandler
Parameters:
message - The message replayed from the event store

processBacklog

public void processBacklog(Cluster destination)
Description copied from interface: IncomingMessageHandler
Invoked when all events from the Event Store have been processed. Any remaining backlog, as well as any messages received through IncomingMessageHandler.onIncomingMessages(org.axonframework.eventhandling.Cluster, org.axonframework.domain.EventMessage[]) should be dispatched to the given delegate. Transactions started by the replay process have been committed or rolled back prior to the invocation of this method.

Note that IncomingMessageHandler.onIncomingMessages(org.axonframework.eventhandling.Cluster, org.axonframework.domain.EventMessage[]) may be invoked during or after the invocation of this method. These messages must be dispatched by this handler to prevent message loss.

This method is invoked in the thread that executes the replay process

Specified by:
processBacklog in interface IncomingMessageHandler
Parameters:
destination - The destination cluster to dispatch backlogged messages to

onReplayFailed

public void onReplayFailed(Cluster destination,
                           RuntimeException cause)
Description copied from interface: IncomingMessageHandler
Invoked when a replay has failed. Typically, this means the state of the cluster's backing data source cannot be guaranteed, and the replay should be retried.

Specified by:
onReplayFailed in interface IncomingMessageHandler
Parameters:
destination - The destination cluster to dispatch backlogged messages to, if appropriate in this scenario
cause - The cause of the failure


Copyright © 2010-2012. All Rights Reserved.