public class ServerMessageBusImpl extends Object implements ServerMessageBus
Modifier and Type | Class and Description |
---|---|
class |
ServerMessageBusImpl.RemoteMessageCallback |
Constructor and Description |
---|
ServerMessageBusImpl(ErraiService service,
ErraiServiceConfigurator config)
Sets up the ServerMessageBusImpl with the configuration supplied.
|
Modifier and Type | Method and Description |
---|---|
void |
addQueueClosedListener(QueueClosedListener listener)
Register a
QueueClosedListener with the bus. |
void |
addSubscribeListener(SubscribeListener listener)
Adds subscription listener
|
void |
addUnsubscribeListener(UnsubscribeListener listener)
Adds unsubscription listener
|
void |
associateNewQueue(QueueSession oldSession,
QueueSession newSession) |
void |
attachMonitor(BusMonitor monitor)
Attach a monitor to the bus.
|
void |
closeQueue(MessageQueue queue)
Closes the message queue
|
void |
closeQueue(String sessionId)
Closes the queue with sessionId
|
void |
configure(ErraiServiceConfigurator config)
Configures the server message bus with the specified ErraiServiceConfigurator.
|
void |
finishInit() |
Message |
getDeadLetterMessage(String messageId) |
Map<QueueSession,MessageQueue> |
getMessageQueues()
Gets all the message queues
|
MessageQueue |
getQueue(QueueSession session)
Gets the queue corresponding to the session id given
|
MessageQueue |
getQueueBySession(String sessionId) |
Collection<MessageCallback> |
getReceivers(String subject)
Get a collection of all receivers registered for a specificed subject
|
ScheduledExecutorService |
getScheduler()
Gets the scheduler being used within this message bus for housekeeping and
other periodic or deferred tasks.
|
QueueSession |
getSessionBySessionId(String id) |
boolean |
hasRemoteSubscription(String sessionId,
String subject) |
boolean |
hasRemoteSubscriptions(String subject) |
boolean |
isSubscribed(String subject)
Checks if a subscription exists for subject
|
void |
remoteSubscribe(QueueSession sessionContext,
MessageQueue queue,
String subject)
Adds a new remote subscription and fires subscription listeners
|
void |
remoteUnsubscribe(QueueSession sessionContext,
MessageQueue queue,
String subject)
Unsubscribes a remote subscription and fires the appropriate listeners
|
boolean |
removeDeadLetterMessage(String messageId) |
void |
send(Message message)
Sends the message
|
void |
send(Message message,
boolean fireListeners)
Parses the message appropriately and enqueues it for delivery
|
void |
sendGlobal(Message message)
Sends a message globally to all subscriptions containing the same subject as the specified message.
|
void |
stop()
Stop the MessateBus.
|
Subscription |
subscribe(String subject,
MessageCallback receiver)
Adds a subscription
|
Subscription |
subscribeLocal(String subject,
MessageCallback receiver)
Subscribe a listern locally, but do not advertise or make available the service to remote buses.
|
void |
unsubscribeAll(String subject)
Unsubscribe all subscriptions attached to subject
|
@Inject public ServerMessageBusImpl(ErraiService service, ErraiServiceConfigurator config)
public void configure(ErraiServiceConfigurator config)
configure
in interface ServerMessageBus
config
- - the configuration to usepublic void sendGlobal(Message message)
sendGlobal
in interface MessageBus
message
- - The message to be sent.public void send(Message message)
send
in interface MessageBus
message
- - the message to sendpublic void send(Message message, boolean fireListeners)
send
in interface MessageBus
message
- - the message to be sentfireListeners
- - true if all listeners attached should be notified of deliverypublic MessageQueue getQueue(QueueSession session)
getQueue
in interface ServerMessageBus
session
- - the session id of the queuepublic void closeQueue(String sessionId)
closeQueue
in interface ServerMessageBus
sessionId
- - the session context of the queue to closepublic void closeQueue(MessageQueue queue)
closeQueue
in interface ServerMessageBus
queue
- - the message queue to closepublic Subscription subscribe(String subject, MessageCallback receiver)
subscribe
in interface MessageBus
subject
- - the subject to subscribe toreceiver
- - the callback function called when a message is dispatchedpublic Subscription subscribeLocal(String subject, MessageCallback receiver)
MessageBus
subscribeLocal
in interface MessageBus
public void remoteSubscribe(QueueSession sessionContext, MessageQueue queue, String subject)
sessionContext
- - session context of queuequeue
- - the message queuesubject
- - the subject to subscribe topublic void remoteUnsubscribe(QueueSession sessionContext, MessageQueue queue, String subject)
sessionContext
- - session context of queuequeue
- - the message queuesubject
- - the subject to unsubscribe frompublic void unsubscribeAll(String subject)
unsubscribeAll
in interface MessageBus
subject
- - the subject to unsubscribe frompublic boolean isSubscribed(String subject)
isSubscribed
in interface MessageBus
subject
- - the subject to search the subscriptions forpublic boolean hasRemoteSubscriptions(String subject)
hasRemoteSubscriptions
in interface ServerMessageBus
public boolean hasRemoteSubscription(String sessionId, String subject)
hasRemoteSubscription
in interface ServerMessageBus
public void addSubscribeListener(SubscribeListener listener)
addSubscribeListener
in interface MessageBus
listener
- - subscription listener to addpublic void addUnsubscribeListener(UnsubscribeListener listener)
addUnsubscribeListener
in interface MessageBus
listener
- - adds an unsubscription listenerpublic void associateNewQueue(QueueSession oldSession, QueueSession newSession)
associateNewQueue
in interface ServerMessageBus
public MessageQueue getQueueBySession(String sessionId)
getQueueBySession
in interface ServerMessageBus
public QueueSession getSessionBySessionId(String id)
getSessionBySessionId
in interface ServerMessageBus
public Map<QueueSession,MessageQueue> getMessageQueues()
getMessageQueues
in interface ServerMessageBus
public ScheduledExecutorService getScheduler()
getScheduler
in interface ServerMessageBus
public void addQueueClosedListener(QueueClosedListener listener)
ServerMessageBus
QueueClosedListener
with the bus.addQueueClosedListener
in interface ServerMessageBus
listener
- a instance of the listenerpublic Collection<MessageCallback> getReceivers(String subject)
ServerMessageBus
getReceivers
in interface ServerMessageBus
subject
- The subject.public void attachMonitor(BusMonitor monitor)
MessageBus
attachMonitor
in interface MessageBus
public Message getDeadLetterMessage(String messageId)
getDeadLetterMessage
in interface ServerMessageBus
public boolean removeDeadLetterMessage(String messageId)
removeDeadLetterMessage
in interface ServerMessageBus
public void stop()
ServerMessageBus
stop
in interface ServerMessageBus
public void finishInit()
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.