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() |
com.devexperts.util.TimePeriodInfo |
getAggregationPeriodInfo()
Returns the aggregation period info for this adapter (programmatic API).
|
String |
getAggregationPeriodInfoStr()
Returns the current effective aggregation period info as JSON.
|
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.
|
String |
getDefaultAggregationPeriod()
Returns the default aggregation period for server-side adapters (AgentAdapter).
|
QDEndpoint |
getEndpoint()
Returns endpoint of this message adapter.
|
FieldReplacersCache |
getFieldReplacer()
Field Replacers specification.
|
String |
getMaxAggregationPeriod()
Returns the maximum aggregation period bound.
|
protected static long |
getMessageMask(MessageType message) |
String |
getMinAggregationPeriod()
Returns the minimum aggregation period bound.
|
com.devexperts.connector.proto.EndpointId |
getRemoteEndpointId() |
protected String |
getRemoteHostAddress() |
protected ProtocolOption.Set |
getRemoteOptSet() |
String |
getRequestedAggregationPeriod()
Returns the client-requested aggregation period string.
|
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 |
setAggregationPeriodInfo(com.devexperts.util.TimePeriodInfo timePeriodInfo)
Updates the server-applied aggregation period info on this adapter.
|
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 |
setDefaultAggregationPeriod(String defaultAggregationPeriod)
Sets the default aggregation period applied when client doesn't specify one.
|
void |
setLoginHandler(QDLoginHandler loginHandler) |
void |
setMaxAggregationPeriod(String maxAggregationPeriod)
Sets the maximum bound for aggregation period validation.
|
void |
setMessageListener(MessageListener listener)
Note: this method SHOULD be called before calling .start()
- it does not give immediate notification regarding the pending messages
|
void |
setMinAggregationPeriod(String minAggregationPeriod)
Sets the minimum bound for aggregation period validation.
|
protected void |
setRemoteOptSet(ProtocolOption.Set optSet) |
void |
setRequestedAggregationPeriod(String requestedAggregationPeriod)
Sets the requested aggregation period to send to the server.
|
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, processTimeProgressReportpublic 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 com.devexperts.util.TimePeriodInfo getAggregationPeriodInfo()
AgentAdapter: computed from actual channel shaper values.
For DistributorAdapter: received from server.TimePeriodInfo.UNKNOWN if not available@Internal public void setAggregationPeriodInfo(com.devexperts.util.TimePeriodInfo timePeriodInfo)
DistributorAdapter overrides with the real assignment, and wrapper adapters
(e.g. RMIMessageAdapter) override to forward to their attached adapter.public String getAggregationPeriodInfoStr()
MessageAdapterMBean{"min":1.5,"max":2.0} (seconds with decimals).getAggregationPeriodInfoStr in interface MessageAdapterMBeanpublic String getRequestedAggregationPeriod()
MessageAdapterMBeannull if not set. Applicable for client-side adapters (DistributorAdapter).getRequestedAggregationPeriod in interface MessageAdapterMBeanpublic void setRequestedAggregationPeriod(String requestedAggregationPeriod)
MessageAdapterMBeansetRequestedAggregationPeriod in interface MessageAdapterMBeanrequestedAggregationPeriod - aggregation period string (e.g. "1s"), or "undefined"/empty to resetpublic String getDefaultAggregationPeriod()
MessageAdapterMBeangetDefaultAggregationPeriod in interface MessageAdapterMBeanpublic void setDefaultAggregationPeriod(String defaultAggregationPeriod)
MessageAdapterMBeansetDefaultAggregationPeriod in interface MessageAdapterMBeanpublic String getMinAggregationPeriod()
MessageAdapterMBeangetMinAggregationPeriod in interface MessageAdapterMBeanpublic void setMinAggregationPeriod(String minAggregationPeriod)
MessageAdapterMBeansetMinAggregationPeriod in interface MessageAdapterMBeanpublic String getMaxAggregationPeriod()
MessageAdapterMBeangetMaxAggregationPeriod in interface MessageAdapterMBeanpublic void setMaxAggregationPeriod(String maxAggregationPeriod)
MessageAdapterMBeansetMaxAggregationPeriod in interface MessageAdapterMBeanpublic 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 MessageConsumerprocessDescribeProtocol in class MessageConsumerAdapterdesc - 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 MessageConsumerhandleCorruptedStream in class MessageConsumerAdapterpublic void handleCorruptedMessage(int messageTypeId)
handleCorruptedMessage in interface MessageConsumerhandleCorruptedMessage in class MessageConsumerAdapterpublic void handleUnknownMessage(int messageTypeId)
handleUnknownMessage in interface MessageConsumerhandleUnknownMessage in class MessageConsumerAdapterpublic boolean retrieveMessages(MessageVisitor visitor)
MessageProvidertrue if some messages still remains in the provider
or false if all accumulated messages were retrieved.retrieveMessages in interface MessageProviderpublic void setMessageListener(MessageListener listener)
setMessageListener in interface MessageProviderpublic final boolean isAlive()
isAlive in interface MessageAdapterMBeanpublic 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 MessageAdapterMBeanpublic 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–2026 Devexperts LLC. All rights reserved.