com.neeve.sma
Interface MessageBusBinding

All Superinterfaces:
IEventSource
All Known Implementing Classes:
LoopbackMessageBusBinding, com.neeve.sma.impl.MessageBusBindingBase, SolaceMessageBusBinding

public interface MessageBusBinding
extends IEventSource

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.

Threading:
A message bus binding is not safe for concurrent access by multiple thread.

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

PROP_SET_FLOW_ON_RECEIPT

static final String PROP_SET_FLOW_ON_RECEIPT
Config property that globally controls whether or not message flows are set on received messages. This value can be overridden per binding in its descriptor by setting the property MessageBusDescriptor.PROPNAME_SET_FLOW_ON_RECEIPT Default value: false

See Also:
Constant Field Values

PROP_SET_FLOW_ON_RECEIPT_DEFAULT

static final boolean PROP_SET_FLOW_ON_RECEIPT_DEFAULT
The default value for PROP_SET_FLOW_ON_RECEIPT.

See Also:
Constant Field Values

PROP_SET_SNO_ON_RECEIPT

static final String PROP_SET_SNO_ON_RECEIPT
Config property that globally controls whether or not message sequence nunbers are set on received messages. This value can be overridden per binding in its descriptor by setting the property MessageBusDescriptor.PROPNAME_SET_SNO_ON_RECEIPT Default value: true

See Also:
Constant Field Values

PROP_SET_SNO_ON_RECEIPT_DEFAULT

static final boolean PROP_SET_SNO_ON_RECEIPT_DEFAULT
The default value for PROP_SET_SNO_ON_RECEIPT.

See Also:
Constant Field Values

PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT

static final 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. This value can be overridden per binding in its descriptor by setting the property MessageBusDescriptor.PROPNAME_SET_BUS_AND_CHANNEL_ON_RECEIPT Default value: false

See Also:
Constant Field Values

PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT_DEFAULT

static final boolean PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT_DEFAULT
The default value for PROP_SET_BUS_AND_CHANNEL_ON_RECEIPT.

See Also:
Constant Field Values

PROP_SET_KEY_ON_RECEIPT

static final String PROP_SET_KEY_ON_RECEIPT
Config property that globally controls whether or not bus and channel name are set on received messages. This value can be overridden per binding in its descriptor by setting the property MessageBusDescriptor.PROPNAME_SET_KEY_ON_RECEIPT Default value: false

See Also:
Constant Field Values

PROP_SET_KEY_ON_RECEIPT_DEFAULT

static final boolean PROP_SET_KEY_ON_RECEIPT_DEFAULT
The default value for PROP_SET_KEY_ON_RECEIPT.

See Also:
Constant Field Values

PRESERVE_CHANNEL_JOINS

static final 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.

See Also:
Constant Field Values
Method Detail

setAttachment

void setAttachment(Object object)
This method is reserved for internal use.


getAttachment

Object getAttachment()
This method is reserved for internal use.


setStatsListener

void setStatsListener(MessageBusBinding.StatsListener callback)
This method is reserved for internal use.

A StatsListener must be set prior to the bus being opened, and once set cannot be changed.


getId

int getId()
Get the system-wide unique binding id.

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.

Threading:
This method is safe for concurrent access by multiple threads.

getType

String getType()
Get this MessageBusBinding's type.

Returns the provider name for this bus.

Threading:
This method is safe for concurrent access by multiple threads.

getTypeAsRaw

XString getTypeAsRaw()
Get this MessageBusBinding's type as an XString

Returns the provider name for this bus.

Threading:
This method is safe for concurrent access by multiple threads.

getNameAsRaw

XString getNameAsRaw()
Get this MessageBusBinding's name as an XString

Threading:
This method is safe for concurrent access by multiple threads.

getUserName

String getUserName()
Get the name of the user that created a binding.

This method can be invoked on a binding in any state.

Threading:
This method is safe for concurrent access by multiple threads.

getDescriptor

MessageBusDescriptor getDescriptor()
Get the bus descriptor used to created a binding.

This method can be invoked on a binding in any state.

Threading:
This method is safe for concurrent access by multiple threads.

getLatencyManager

MessageLatencyManager getLatencyManager()
Get a binding's latency manager

This method can be invoked on a binding in any state.

Threading:
This method is safe for concurrent access by multiple threads.

getStats

void getStats(StringBuilder sb)
Get a binding's provider specific stats.

This method can be invoked on a binding in any state.

Parameters:
sb - The string builder into which to write stats.
Threading:
This method is safe for concurrent access by multiple threads.

getEventHandler

IEventHandler getEventHandler()
Get a binding's event handler.

This method can be invoked on a binding in any state.

Threading:
This method is safe for concurrent access by multiple threads.

getState

MessageBusBinding.State getState()
Get a binding's state.

This method can be invoked on a binding in any state.

Threading:
This method is safe for concurrent access by multiple threads.

getMessageChannel

MessageChannel getMessageChannel(String channelName)
                                 throws SmaException
Get a handle to a message channel.

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.

Parameters:
channelName - The name of the channel to get.
Throws:
SmaException - Thrown in case an error is encountered during this method.
Threading:
This method is not safe for concurrent access by multiple threads.

start

void start()
           throws SmaException
Start a binding.

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.

Throws:
SmaException
Threading:
This method is not safe for concurrent access by multiple threads.

flush

void flush(MessageBusBinding.FlushContext flushContext)
           throws SmaException
Flush all outbound messages buffered by a binding.

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.

Parameters:
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.
Throws:
SmaException - Thrown in case an error is encountered while flushing the queue.
Threading:
This method is not safe for concurrent access by multiple threads.

canFail

boolean canFail()
Get whether a binding can fail.

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.

Threading:
This method is safe for concurrent access by multiple threads.

acksRequireFlush

boolean acksRequireFlush()
Get whether a binding requires a flush for acks to be sent.

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.

Threading:
This method is safe for concurrent access by multiple threads.

fail

void fail(Exception e,
          boolean dispatchFailureEvent)
          throws SmaException
Fail a message bus binding.

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.

Parameters:
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.
Throws:
SmaException - Thrown in case an error is encountered during this method.
Threading:
This method is not safe for concurrent access by multiple threads.

close

void close()
           throws SmaException
Close a message bus binding.

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.

Throws:
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.
Threading:
This method is not safe for concurrent access by multiple threads.

close

void close(int closeFlags)
           throws SmaException
Close a message bus binding.

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.

Parameters:
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:
Throws:
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.
Threading:
This method is not safe for concurrent access by multiple threads.


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.