public abstract class BaseDestination
extends java.lang.Object
BaseDestination
represent the end-points that the transport
can use.
init()
-> connect()
->
start()
-> close()
Users must take care of this sequence while providing the Destination's implementation
Modifier and Type | Method and Description |
---|---|
void |
bind(EventProcessor eventProcessor)
Initializes the listener(s) for the specified EventProcessor.
|
abstract void |
close()
Closes the Destination and frees up all its resources.
|
abstract void |
connect()
Connects the
Destination to its underlying end-point. |
BaseChannel |
getChannel()
Gets the
Channel instance
associated with this destination |
java.lang.String |
getDefaultEventUri()
Gets the default Event URI associated with this
Destination |
java.lang.String |
getDestinationName()
Gets the name of the
Destination |
java.util.Properties |
getDestinationProperties()
Gets the Properties associated with the
Destination |
EventContext |
getEventContext(Event event)
Gets the user
EventContext
You can override to provide custom implementation for EventContext
If not defined the DefaultEventContext will be used. |
EventProcessor |
getEventProcessor()
Gets the instance of
EventProcessor .This
is used to process events received on the destination |
BaseEventSerializer |
getSerializer()
Gets the
BaseEventSerializer instance
associated with this destination |
java.lang.String |
getUri()
Gets the URI of this
Destination |
abstract void |
init()
Initializes the
Destination by allocating necessary resources, creating pools, etc. |
boolean |
isSuspended()
Returns the suspension state of Destination.
|
abstract Event |
requestEvent(Event outevent,
java.lang.String responseEventURI,
BaseEventSerializer serializer,
long timeout,
java.util.Map userData)
Sends an event on the specified destination and waits for a response.
|
void |
resume()
Sets the flag suspended to "false".
|
abstract void |
send(EventWithId event,
java.util.Map userData)
Sends an event on this
Destination . |
abstract void |
start()
Starts the destination, so that it can receive data from the end-point.
|
void |
suspend()
Sets the flag suspended to "true".
|
public abstract void init()
Destination
by allocating necessary resources, creating pools, etc.
After this call, you will be able to
connect
, start
or close
this Destination
.java.lang.Exception
- when initialization failedBaseDestination.connect()
,
BaseDestination.close()
public abstract void connect()
Destination
to its underlying end-point.
After this call, you will be able to start
or close
the Destination
.
Do not start sending or receiving data here.
java.lang.Exception
- when the Destination could not be connected to the underlying
endpoint.BaseDestination.start()
,
BaseDestination.close()
public abstract void start()
Only valid on a connected Destination
After this
call, you will be able to stop
and close
the
Destination
.
java.lang.Exception
- when the Destination could not be started.BaseDestination.connect()
,
BaseDestination.close()
public abstract void close()
After this call, you will be able to init
the
Destination
.
java.lang.Exception
- encountered exceptionpublic void suspend()
public boolean isSuspended()
public void resume()
public abstract void send(EventWithId event, java.util.Map userData)
Destination
.
This method is invoked when the BE application code invokes Event.send()
event
- the Event
to send. The user's Destination implementation should use the Destination's serializer as configured in the project and send this data to its configured end-pointuserData
- During runtime, the application code can optionally pass a map of key/value pairs using Event.sendEvent
.
The users destination may choose to make use of this additional data.java.lang.Exception
- when the event could not be sentpublic void bind(EventProcessor eventProcessor)
start
.
The threading model is left to the programmer.java.lang.Exception
- encountered exceptionpublic abstract Event requestEvent(Event outevent, java.lang.String responseEventURI, BaseEventSerializer serializer, long timeout, java.util.Map userData)
outevent
- The outgoing Event
responseEventURI
- the URI of the response eventserializer
- the instance of serializertimeout
- timeoutuserData
- During runtime, the application code can optionally pass a map of key/value pairs using Event.requestEvent
.
The users destination may choose to make use of this additional data.Event
of type responseEventURI
java.lang.Exception
- Exception when request failedpublic java.lang.String getDestinationName()
Destination
Destination
namepublic java.util.Properties getDestinationProperties()
Destination
Destination
Propertiespublic java.lang.String getUri()
Destination
public java.lang.String getDefaultEventUri()
Destination
Destination
public BaseChannel getChannel()
Channel
instance
associated with this destinationChannel
associated with
this destinationpublic BaseEventSerializer getSerializer()
BaseEventSerializer
instance
associated with this destinationBaseEventSerializer
instance associated with
this destinationpublic EventProcessor getEventProcessor()
EventProcessor
.This
is used to process events received on the destinationEventProcessorr
.public EventContext getEventContext(Event event)
EventContext
You can override to provide custom implementation for EventContext
If not defined the DefaultEventContext will be used.event
- the event for which EventContext
is required.EventContext
.