|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MessageBusBinding
Represents a binding to an SMA message bus.
A message bus binding serves as an interface to a message bus. It provides the facilities by which messages can be exchanged with other messaging participants.
A message bus contains message channels. Message channels are the entities
through which users send and receive messages. Before a user can send and
receive messages through a channel, the user needs to get a handle to the
channel. This is done via the getMessageChannel(java.lang.String)
method. The user
can send messages through a channel immediately after getting the handle
to the channel. In order to receive messages from a channel, the user
needs to explicitly join the channel via MessageChannel.join(int)
. Once
joined, messages sent to the channel by other messaging participants will
flow to the joining perticipant's binding. Received messages are dispatched
to the user as message events.
A user creates message bus bindings using MessageBusBindingFactory
.
Nested Class Summary | |
---|---|
static class |
MessageBusBinding.AsynchronousFlushContext
Context for flushing using asychnronous semantics. |
static class |
MessageBusBinding.FlushContext
Base class for all flushing contexts. |
static class |
MessageBusBinding.State
Enumerates the different binding states |
static class |
MessageBusBinding.SynchronousBlockingFlushContext
Context for flushing using synchronous blocking semantics. |
static class |
MessageBusBinding.SynchronousNonBlockingFlushContext
Context for flushing using synchronous non-blocking semantics. |
Method Summary | |
---|---|
boolean |
acksRequireFlush()
Get whether a binding requires a flush for acks to be sent. |
boolean |
canFail()
Get whether a binding can fail. |
void |
close()
Close a message bus binding. |
void |
fail(Exception e,
boolean dispatchFailureEvent)
Fail a message bus binding. |
void |
flush(MessageBusBinding.FlushContext flushContext)
Flush all outbound messages buffered by a binding. |
Object |
getAttachment()
This method is reserved for internal use. |
MessageBusDescriptor |
getDescriptor()
Get the bus descriptor used to created a binding. |
com.neeve.event.IEventHandler |
getEventHandler()
Get a binding's event handler. |
int |
getId()
Get the system-wide unique binding id. |
MessageLatencyManager |
getLatencyManager()
Get a binding's latency manager |
MessageChannel |
getMessageChannel(String channelName)
Get a handle to a message channel. |
com.neeve.raw.RawString |
getNameAsRaw()
Get this MessageBusBinding 's name as a RawString |
MessageBusBinding.State |
getState()
Get a binding's state. |
String |
getStats()
Get a binding's stats |
String |
getUserName()
Get the name of the user that created a binding. |
void |
setAttachment(Object object)
This method is reserved for internal use. |
void |
start()
Start a binding. |
Methods inherited from interface com.neeve.event.IEventSource |
---|
getName |
Method Detail |
---|
void setAttachment(Object object)
Object getAttachment()
int getId()
Each binding generates a system-wide unique identifier to uniquely identify itself across all bus bindings in the system. This method returns a binding's unique id.
This method can be invoked on a binding in any state.
com.neeve.raw.RawString getNameAsRaw()
MessageBusBinding
's name as a RawString
String getUserName()
This method can be invoked on a binding in any state.
MessageBusDescriptor getDescriptor()
This method can be invoked on a binding in any state.
MessageLatencyManager getLatencyManager()
This method can be invoked on a binding in any state.
String getStats()
This method can be invoked on a binding in any state.
com.neeve.event.IEventHandler getEventHandler()
This method can be invoked on a binding in any state.
MessageBusBinding.State getState()
This method can be invoked on a binding in any state.
MessageChannel getMessageChannel(String channelName) throws SmaException
channelName
- The name of the channel to get.
SmaException
- Thrown in case an error is encountered during
this method.
This method returns a user private handle to a message channel. The
returned handle is ready to send messages through the channel. The user
needs to MessageChannel.join(int)
the channel to receive messages
from the channel.
It is safe to call this method repeatedly. A call to get a channel that has already been previously gotten (and not released) will return the same handle that was returned by the previous get.
This method can only be invoked on open bindings. An exception will be thrown if invoked on bindings in any other state.
void start() throws SmaException
SmaException
A message bus binding is ready for outbound traffic as soon as it is opened. However, it needs to be started before inbound messages triggered by channel joins are received and dispatched to the user. Although a channel join can succeed the starting of a binding, if the user joins a channel after starting the binding, there is a chance of message loss for guaranteed channels since the received messages will be discarded by the SMA runtime till the channel is joined. Therefore, it is recommended that the user create the binding, join desired channels and then start the binding.
This method can only be invoked on open bindings. An exception will be thrown if invoked on bindings in any other state.
void flush(MessageBusBinding.FlushContext flushContext) throws SmaException
flushContext
- A context object indicating the IO semantics and
runtime context information related to the flush. A value of null
is interpeted as a request for synchronous flush.
SmaException
- Thrown in case an error is encountered while
flushing the queue.This method transmits all outbound messages buffered by a binding. The call does not return until all buffered messages are transmitted or an error is encountered.
This method can only be invoked on open bindings. An exception will be thrown if invoked on bindings in any other state.
boolean canFail()
This method queries the binding as to whether it can fail. Only bindings that can fail dispatch the 'binding failed' event when they fail. See com.neeve.sma.event for the various SMA events.
This method can be invoked on bindings in any state.
boolean acksRequireFlush()
This method returns whether a binding immediately sends acknowledgments through the underlying provider or enques the ACK for later send hrough either an explicit flush by the user or an implicit flush by the provider. The caller should use this method to determine whether a flush is needed to ensure that the ACKs are indeed dispatched onto the wire.
This method can be invoked on bindings in any state.
void fail(Exception e, boolean dispatchFailureEvent) throws SmaException
e
- The exception to be associated with the 'binding failed'
event that will be triggered by this method.dispatchFailureEvent
- Indicates whether a failure event
should be dispatched to the user or not.
SmaException
- Thrown in case an error is encountered during
this method.
This method 'fails' a binding. It is only supported for bindings
that can fail i.e. those bindings whose canFail()
method
return true. For such bindings, this method triggers the machinery
that puts the binding in the same state as if the binding had
actually failed. This includes dispatching the 'binding failure'
event contaning the exception supplied to this method. An exception
is thrown by this method if invoked on a binding that does not
support failures.
This method can only be invoked on open bindings. An exception will be thrown if invoked on bindings in any other state.
void close() throws SmaException
SmaException
- Thrown in case an error is encountered during
the closing of the binding. The user should assume that the binding
is still open in case the exception is thrown.This method is used to close a bus binding. This method will also close all message channels managed by the bindings. It is safe to invoke this method multiple times.
This method can be invoked on open or failed bindings. An exception will be thrown if invoked on bindings in any other state.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |