|
|||||||||
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 interface |
MessageBusBinding.StatsListener
Listener used to allow binding statistics to be collected. |
static class |
MessageBusBinding.SynchronousBlockingFlushContext
Context for flushing using synchronous blocking semantics. |
static class |
MessageBusBinding.SynchronousNonBlockingFlushContext
Context for flushing using synchronous non-blocking semantics. |
Field Summary | |
---|---|
static int |
PRESERVE_CHANNEL_JOINS
Flag that can be used on close(flags) to indicate that the binding
that should not leave channels that were joined, but instead preserve
any interests or subscriptions that have been established. |
static String |
PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT
Config property that globally controls whether or not bus and channel name are set on received messages. |
static boolean |
PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT_DEFAULT
The default value for PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT . |
static String |
PROP_SET_FLOW_ON_RECEIPT
Config property that globally controls whether or not message flows are set on received messages. |
static boolean |
PROP_SET_FLOW_ON_RECEIPT_DEFAULT
The default value for PROP_SET_FLOW_ON_RECEIPT . |
static String |
PROP_SET_KEY_ON_RECEIPT
Config property that globally controls whether or not bus and channel name are set on received messages. |
static boolean |
PROP_SET_KEY_ON_RECEIPT_DEFAULT
The default value for PROP_SET_KEY_ON_RECEIPT . |
static String |
PROP_SET_SNO_ON_RECEIPT
Config property that globally controls whether or not message sequence nunbers are set on received messages. |
static boolean |
PROP_SET_SNO_ON_RECEIPT_DEFAULT
The default value for PROP_SET_SNO_ON_RECEIPT . |
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 |
close(int closeFlags)
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. |
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 This method can be invoked on a binding in any state. |
MessageChannel |
getMessageChannel(String channelName)
Get a handle to a message channel. |
XString |
getNameAsRaw()
Get this MessageBusBinding 's name as an XString
|
MessageBusBinding.State |
getState()
Get a binding's state. |
void |
getStats(StringBuilder sb)
Get a binding's provider specific stats. |
String |
getType()
Get this MessageBusBinding 's type. |
XString |
getTypeAsRaw()
Get this MessageBusBinding 's type as an XString
Returns the provider name for this bus. |
String |
getUserName()
Get the name of the user that created a binding. |
void |
setAttachment(Object object)
This method is reserved for internal use. |
void |
setStatsListener(MessageBusBinding.StatsListener callback)
This method is reserved for internal use. |
void |
start()
Start a binding. |
Methods inherited from interface com.neeve.event.IEventSource |
---|
getName |
Field Detail |
---|
static final String PROP_SET_FLOW_ON_RECEIPT
MessageBusDescriptor.PROPNAME_SET_FLOW_ON_RECEIPT
Default value: false
static final boolean PROP_SET_FLOW_ON_RECEIPT_DEFAULT
PROP_SET_FLOW_ON_RECEIPT
.
static final String PROP_SET_SNO_ON_RECEIPT
MessageBusDescriptor.PROPNAME_SET_SNO_ON_RECEIPT
Default value: true
static final boolean PROP_SET_SNO_ON_RECEIPT_DEFAULT
PROP_SET_SNO_ON_RECEIPT
.
static final String PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT
MessageBusDescriptor.PROPNAME_SET_BUS_AND_CHANNEL_ON_RECEIPT
Default value: false
static final boolean PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT_DEFAULT
PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT
.
static final String PROP_SET_KEY_ON_RECEIPT
MessageBusDescriptor.PROPNAME_SET_KEY_ON_RECEIPT
Default value: false
static final boolean PROP_SET_KEY_ON_RECEIPT_DEFAULT
PROP_SET_KEY_ON_RECEIPT
.
static final int PRESERVE_CHANNEL_JOINS
close(flags)
to indicate that the binding
that should not leave channels that were joined, but instead preserve
any interests or subscriptions that have been established.
Method Detail |
---|
void setAttachment(Object object)
Object getAttachment()
void setStatsListener(MessageBusBinding.StatsListener callback)
A StatsListener must be set prior to the bus being opened, and once set cannot be changed.
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.
String getType()
MessageBusBinding
's type.
Returns the provider name for this bus.
XString getTypeAsRaw()
MessageBusBinding
's type as an XString
Returns the provider name for this bus.
XString getNameAsRaw()
MessageBusBinding
's name as an XString
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.
void getStats(StringBuilder sb)
This method can be invoked on a binding in any state.
sb
- The string builder into which to write stats.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
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.
channelName
- The name of the channel to get.
SmaException
- Thrown in case an error is encountered during
this method.void start() throws 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.
SmaException
void flush(MessageBusBinding.FlushContext flushContext) throws SmaException
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.
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.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
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 containing 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
or Closing
bindings. An exception will
be thrown if invoked on bindings in any other state.
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.void close() throws SmaException
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
, Closing
,
Failed
or Closed
bindings.
An exception will be thrown if invoked on bindings in any other state.
Calling this method on a Closing
or Closed
channel has no effect and results in the call returning immediately.
SmaException
- Thrown in case an error is encountered during
the closing of the binding, in which case the caller should inspect
the state of the binding and its channels to determine the effective
outcome of the call.void close(int closeFlags) throws SmaException
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
, Closing
,
Failed
or Closed
bindings.
An exception will be thrown if invoked on bindings in any other state.
Calling this method on a Closing
or Closed
channel has no effect and results in the call returning immediately.
closeFlags
- Indicates whether or not to leave channels that were previously joined.
Specifying a value of false
causes subscriptions and interests for this buses
channels in tact. Permissible flags are:
SmaException
- Thrown in case an error is encountered during
the closing of the binding, in which case the caller should inspect
the state of the binding and its channels to determine the effective
outcome of the call.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |