|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.applicationblocks.commons.broker.BrokerServiceBase<T>
com.genesyslab.platform.applicationblocks.commons.broker.AsyncBrokerServiceBase<RequestContext>
com.genesyslab.platform.applicationblocks.commons.broker.RequestReceivingBrokerService
setMessageHandler(handler)
to handle incoming messages asynchronously.
@Deprecated public class RequestReceivingBrokerService
RequestReceivingBrokerService
class is designed to work with request messages on server side.
[Java]
final String protocolName = "CustomRouter";
UrsCustomProtocolListener ursServer;
RequestReceivingBrokerService requestBroker;
public void initialize() {
Endpoint endpoint = new Endpoint(
protocolName,
"localhost", 9999);
ursServer = new UrsCustomProtocolListener(endpoint);
requestBroker = new RequestReceivingBrokerService(
new SingleThreadInvoker("RequestReceivingBrokerService-1"));
requestBroker.register(new MyHandler(), null);
ursServer.setReceiver(requestBroker);
ursServer.open();
}
class MyHandler implements Action<RequestContext> {
public void handle(final RequestContext context) {
Message request = context.getRequestMessage();
// ...
Message response = EventSomeResponse.create(
"Operation result");
// ...
context.respond(response);
}
}
Field Summary |
---|
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver |
---|
DEF_INPUT_SIZE |
Constructor Summary | |
---|---|
RequestReceivingBrokerService()
Deprecated. Creates an instance of RequestReceivingBrokerService class. |
|
RequestReceivingBrokerService(AsyncInvoker invoker)
Deprecated. Creates an instance of RequestReceivingBrokerService class. |
Method Summary | |
---|---|
void |
clearInput()
Deprecated. Clears input of the receiver. |
int |
getInputSize()
Deprecated. Returns the amount of messages this Receiver can hold before start to "forget stale messages". |
void |
onChannelClosed(ChannelClosedEvent event)
Deprecated. onChannelClosed is called when the channel closed by any reason. |
void |
onChannelError(ChannelErrorEvent event)
Deprecated. onChannelError is called when some not critical channel error occurs. |
void |
onChannelOpened(java.util.EventObject event)
Deprecated. onChannelOpened is called when the channel opening will be completed successfully. |
void |
processRequest(RequestContext request)
Deprecated. |
RequestContext |
receiveRequest()
Deprecated. It is not supposed to receive requests directly. |
RequestContext |
receiveRequest(long timeout)
Deprecated. It is not supposed to receive requests directly. |
void |
releaseReceivers()
Deprecated. Notifies receivers (threads waiting on receive() methods) they should stop waiting and return null. |
void |
setInputSize(int arg0)
Deprecated. Sets the amount of messages this Receiver can hold before start to "forget stale messages". |
Methods inherited from class com.genesyslab.platform.applicationblocks.commons.broker.AsyncBrokerServiceBase |
---|
publish, setInvoker |
Methods inherited from class com.genesyslab.platform.applicationblocks.commons.broker.BrokerServiceBase |
---|
notify, onNotificationException, onPublish, register, register, switchSubscribersList, unregister, unregister, unregisterAll |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RequestReceivingBrokerService()
RequestReceivingBrokerService
class.
AsyncBrokerServiceBase.setInvoker(AsyncInvoker)
public RequestReceivingBrokerService(AsyncInvoker invoker)
RequestReceivingBrokerService
class.
Method Detail |
---|
public void processRequest(RequestContext request)
processRequest
in interface RequestReceiverSupport
public RequestContext receiveRequest() throws java.lang.InterruptedException, java.lang.IllegalStateException
receiveRequest
in interface RequestReceiver
java.lang.UnsupportedOperationException
java.lang.InterruptedException
- if thread is interrupted during this method
execution
java.lang.IllegalStateException
- if channel is not in appropriate state
to call the methodBrokerServiceBase.register(Subscriber)
,
BrokerServiceBase.register(Action, Predicate)
public RequestContext receiveRequest(long timeout) throws java.lang.InterruptedException, java.lang.IllegalStateException
receiveRequest
in interface RequestReceiver
timeout
- timeout to waitResponse for message
java.lang.UnsupportedOperationException
java.lang.InterruptedException
- if thread is interrupted during this method
execution
ChannelNotOpenedException
- if channel is not in appropriate state
to call the method
java.lang.IllegalStateException
BrokerServiceBase.register(Subscriber)
,
BrokerServiceBase.register(Action, Predicate)
public void clearInput()
Receiver
clearInput
in interface Receiver
public int getInputSize()
Receiver
getInputSize
in interface Receiver
public void releaseReceivers()
Receiver
releaseReceivers
in interface Receiver
public void setInputSize(int arg0)
Receiver
setInputSize
in interface Receiver
arg0
- maximum count of messages stored in receiverpublic void onChannelClosed(ChannelClosedEvent event)
ChannelListener
onChannelClosed
in interface ChannelListener
event
- details. See event.getCause() to analize the source reason.public void onChannelError(ChannelErrorEvent event)
ChannelListener
onChannelError
in interface ChannelListener
event
- details. See event.getCause() to analize the problem source.public void onChannelOpened(java.util.EventObject event)
ChannelListener
onChannelOpened
in interface ChannelListener
event
- details.
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |