public abstract class MessageAdapter extends MessageConsumerAdapter implements MessageProvider, MessageAdapterMBean
MessageAdapter
is a basic adapter of some entity to message API.
It implements both MessageConsumer
and MessageProvider
interfaces
with default behavior and is recommended for extension by specific adapters
(instead of pure implementations of corresponding interfaces). Certain QTP connectors
works only with MessageAdapter
as a single representative of some entity.Modifier and Type | Class and Description |
---|---|
static class |
MessageAdapter.AbstractFactory
An abstract message adapter factory for
QDEndpoint or a bunch of QDCollector instances. |
static interface |
MessageAdapter.CloseListener
The
CloseListener is used to notify QTP connector that
this message adapter was closed by some reason. |
static class |
MessageAdapter.ConfigurableFactory
An abstract message adapter factory with ability to configure it with arbitrary keys and values.
|
static interface |
MessageAdapter.Factory
The
Factory performs creation of actual message agents
on demand from QTP connector. |
Modifier | Constructor and Description |
---|---|
protected |
MessageAdapter(QDEndpoint endpoint,
QDStats stats) |
protected |
MessageAdapter(QDStats stats) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addMask(long mask)
Adds bytes from argument mask to internal mask and notifies
listeners if internal mask changed.
|
protected static long |
clearMessageMask(long mask,
MessageType message) |
void |
close()
Closes this adapter.
|
protected void |
closeImpl() |
static DataScheme |
getCommonScheme(QDCollector c1,
QDCollector c2,
QDCollector c3)
Returns common data scheme or throws IllegalArgumentException.
|
com.devexperts.util.TypedMap |
getConnectionVariables()
Returns per-connection variables for this message adapter.
|
QDEndpoint |
getEndpoint()
Returns endpoint of this message adapter.
|
FieldReplacersCache |
getFieldReplacer()
Field Replacers specification.
|
protected static long |
getMessageMask(MessageType message) |
com.devexperts.connector.proto.EndpointId |
getRemoteEndpointId() |
protected String |
getRemoteHostAddress() |
protected ProtocolOption.Set |
getRemoteOptSet() |
abstract DataScheme |
getScheme() |
QDStats |
getStats() |
String |
getStatus() |
void |
handleCorruptedMessage(int messageTypeId) |
void |
handleCorruptedStream() |
void |
handleUnknownMessage(int messageTypeId) |
protected static boolean |
hasMessageMask(long mask,
MessageType message) |
protected static QDFilter |
intersectStripes(QDFilter stripe1,
QDFilter stripe2) |
boolean |
isAlive()
|
boolean |
isClosed() |
boolean |
isMarkedForImmediateRestart()
Returns
true if this message adapter was marked for immediate restart by underlying
connection when it is closed. |
boolean |
isProtocolDescriptorCompatible(ProtocolDescriptor desc) |
void |
markForImmediateRestart()
Marks this message adapter for immediate restart by underlying connection when it is closed.
|
long |
nextRetrieveTime(long currentTime)
Returns next time when
retrieveMessages(MessageVisitor) shall be called. |
protected void |
notifyListener() |
protected void |
prepareAuthenticateProtocolDescriptor(ProtocolDescriptor desc) |
void |
prepareProtocolDescriptor(ProtocolDescriptor desc)
Prepares outgoing protocol descriptor.
|
void |
processDescribeProtocol(ProtocolDescriptor desc)
Deprecated.
|
void |
processDescribeProtocol(ProtocolDescriptor desc,
boolean logDescriptor)
Process incoming protocol descriptor.
|
void |
reinitConfiguration(com.devexperts.auth.AuthSession session)
Updates the adapter configuration.
|
protected void |
reportIgnoredMessage(String reason,
MessageType message) |
protected long |
retrieveDescribeProtocolMessage(MessageVisitor visitor,
long mask) |
protected long |
retrieveMask() |
boolean |
retrieveMessages(MessageVisitor visitor)
Retrieves accumulated message into specified message visitor.
|
void |
setAuthRealm(QDAuthRealm authRealm) |
void |
setCloseListener(MessageAdapter.CloseListener listener) |
void |
setConnectionVariables(com.devexperts.util.TypedMap connectionVariables)
Sets per-connection variables for this message adapter.
|
void |
setLoginHandler(QDLoginHandler loginHandler) |
void |
setMessageListener(MessageListener listener)
Note: this method SHOULD be called before calling .start()
- it does not give immediate notification regarding the pending messages
|
protected void |
setRemoteOptSet(ProtocolOption.Set optSet) |
void |
start()
Starts this adapter.
|
void |
start(MasterMessageAdapter master)
Same as start, but when slave is true it starts in slave mode.
|
protected void |
startImpl(MasterMessageAdapter master) |
boolean |
supportsMixedSubscription() |
String |
toString()
Returns description of this
MessageAdapter for management and logging purposes. |
void |
useDescribeProtocol()
Invocation of this method causes this
MessageAdapter to send
DESCRIBE_PROTOCOL message if it is capable of doing so. |
getSymbol, processData, processHeartbeat, processHistoryAddSubscription, processHistoryData, processHistoryRemoveSubscription, processOtherMessage, processOtherMessage, processRecordSource, processStreamAddSubscription, processStreamData, processStreamRemoveSubscription, processSubscription, processTickerAddSubscription, processTickerData, processTickerRemoveSubscription, processTimeProgressReport
public static final String AUTHENTICATION_LOGIN_REQUIRED
protected boolean useDescribeProtocol
protected boolean doNotCloseOnErrors
protected volatile MessageAdapter.CloseListener closeListener
protected volatile MessageListener messageListener
protected com.devexperts.connector.proto.EndpointId remoteEndpointId
public static final int MESSAGE_HEARTBEAT
public static final int MESSAGE_DESCRIBE_PROTOCOL
public static final int MESSAGE_DESCRIBE_RECORDS
public static final int MESSAGE_DESCRIBE_RESERVED
public static final int MESSAGE_PART
public static final int MESSAGE_RAW_DATA
public static final int MESSAGE_TICKER_DATA
public static final int MESSAGE_TICKER_ADD_SUBSCRIPTION
public static final int MESSAGE_TICKER_REMOVE_SUBSCRIPTION
public static final int MESSAGE_STREAM_DATA
public static final int MESSAGE_STREAM_ADD_SUBSCRIPTION
public static final int MESSAGE_STREAM_REMOVE_SUBSCRIPTION
public static final int MESSAGE_HISTORY_DATA
public static final int MESSAGE_HISTORY_ADD_SUBSCRIPTION
public static final int MESSAGE_HISTORY_REMOVE_SUBSCRIPTION
public static final int MESSAGE_RMI_ADVERTISE_SERVICES
public static final int MESSAGE_RMI_DESCRIBE_SUBJECT
public static final int MESSAGE_RMI_DESCRIBE_OPERATION
public static final int MESSAGE_RMI_REQUEST
public static final int MESSAGE_RMI_CANCEL
public static final int MESSAGE_RMI_RESULT
public static final int MESSAGE_RMI_ERROR
public static final int MESSAGE_RMI_RESPONSE
public static final int MAX_SUPPORTED_MESSAGE_TYPE
public static final int MESSAGE_TEXT_FORMAT
public static final int MESSAGE_ZIP_COMPRESSION
public static final int MESSAGE_GZIP_COMPRESSION
protected MessageAdapter(QDEndpoint endpoint, QDStats stats)
protected MessageAdapter(QDStats stats)
public static DataScheme getCommonScheme(QDCollector c1, QDCollector c2, QDCollector c3)
null
parameters.c1
- QDCollectorc2
- QDCollectorc3
- QDCollectorIllegalArgumentException
- if collectors have different schemes or all are null
.public abstract DataScheme getScheme()
public QDEndpoint getEndpoint()
public FieldReplacersCache getFieldReplacer()
public String toString()
MessageAdapter
for management and logging purposes.protected void notifyListener()
public void setCloseListener(MessageAdapter.CloseListener listener)
public long nextRetrieveTime(long currentTime)
retrieveMessages(MessageVisitor)
shall be called.
This method is overridden when a message has to be generated at a certain time in the future.
For immediate message delivery use addMask(long)
, which
immediately calls notifyListener()
as needed.
This implementation returns Long.MAX_VALUE
.
currentTime
- the current value of System.currentTimeMillis()
retrieveMessages(MessageVisitor)
shall be called
even if the mask of messages for immediate delivery is empty.public boolean supportsMixedSubscription()
public void setAuthRealm(QDAuthRealm authRealm)
public void setLoginHandler(QDLoginHandler loginHandler)
@Nullable public com.devexperts.util.TypedMap getConnectionVariables()
public void setConnectionVariables(@Nonnull com.devexperts.util.TypedMap connectionVariables)
protected String getRemoteHostAddress()
public com.devexperts.connector.proto.EndpointId getRemoteEndpointId()
public void useDescribeProtocol()
MessageAdapter
to send
DESCRIBE_PROTOCOL
message if it is capable of doing so.
It should be invoked once before calling start()
.
The code that calls this method shall also consult nextRetrieveTime(long)
.protected long retrieveDescribeProtocolMessage(MessageVisitor visitor, long mask)
public void reinitConfiguration(com.devexperts.auth.AuthSession session)
session
- the unique session.public void prepareProtocolDescriptor(ProtocolDescriptor desc)
super.prepareProtocolDescriptor(desc)
.desc
- outgoing protocol descriptorprotected void prepareAuthenticateProtocolDescriptor(ProtocolDescriptor desc)
public void processDescribeProtocol(ProtocolDescriptor desc, boolean logDescriptor)
super.processDescribeProtocol(desc)
.processDescribeProtocol
in interface MessageConsumer
processDescribeProtocol
in class MessageConsumerAdapter
desc
- incoming protocol descriptorlogDescriptor
- when protocol description shall be logged.public final void processDescribeProtocol(ProtocolDescriptor desc)
processDescribeProtocol(ProtocolDescriptor, boolean)
public boolean isProtocolDescriptorCompatible(ProtocolDescriptor desc)
protected ProtocolOption.Set getRemoteOptSet()
protected void setRemoteOptSet(ProtocolOption.Set optSet)
public QDStats getStats()
public void handleCorruptedStream()
handleCorruptedStream
in interface MessageConsumer
handleCorruptedStream
in class MessageConsumerAdapter
public void handleCorruptedMessage(int messageTypeId)
handleCorruptedMessage
in interface MessageConsumer
handleCorruptedMessage
in class MessageConsumerAdapter
public void handleUnknownMessage(int messageTypeId)
handleUnknownMessage
in interface MessageConsumer
handleUnknownMessage
in class MessageConsumerAdapter
public boolean retrieveMessages(MessageVisitor visitor)
MessageProvider
true
if some messages still remains in the provider
or false
if all accumulated messages were retrieved.retrieveMessages
in interface MessageProvider
public void setMessageListener(MessageListener listener)
setMessageListener
in interface MessageProvider
public final boolean isAlive()
isAlive
in interface MessageAdapterMBean
public final boolean isClosed()
public final String getStatus()
public final void start()
public final void start(MasterMessageAdapter master)
prepareProtocolDescriptor
method of this adapter.public final void close()
close
in interface MessageAdapterMBean
public void markForImmediateRestart()
public boolean isMarkedForImmediateRestart()
true
if this message adapter was marked for immediate restart by underlying
connection when it is closed.protected void startImpl(MasterMessageAdapter master)
protected void closeImpl()
protected void reportIgnoredMessage(String reason, MessageType message)
protected final long retrieveMask()
protected final boolean addMask(long mask)
mask
- changed bytes mask.is alive
.protected static long getMessageMask(MessageType message)
protected static boolean hasMessageMask(long mask, MessageType message)
protected static long clearMessageMask(long mask, MessageType message)
Copyright © 2002–2025 Devexperts LLC. All rights reserved.