com.dxfeed.api.osub
Class WildcardSymbol

java.lang.Object
  extended by com.dxfeed.api.osub.WildcardSymbol
All Implemented Interfaces:
Serializable

public class WildcardSymbol
extends Object
implements Serializable

Represents [wildcard] subscription to all events of the specific event type. The WildcardSymbol.ALL constant can be added to any DXFeedSubscription instance with addSymbols method to the effect of subscribing to all possible event symbols. The corresponding subscription will start receiving all published events of the corresponding types.

Note, that using wildcard subscription can create extremely high network and CPU load for certain kinds of high-frequency events like quotes. Make sure you have adequate resource and understand the impact before using it.

Sample usage

See DXFeed on how to create connection to the feed. The following code creates listener that prints all TimeAndSale events that are coming from the feed using wildcard subscription symbol:

 DXFeedSubscription<TimeAndSale> sub = feed.createSubscription(TimeAndSale.class);
 sub.addEventListener(new DXFeedEventListener<TimeAndSale>() {
     public void eventsReceived(List<TimeAndSale> events) {
         for (TimeAndSale event : events)
             System.out.println(event);
     }
 });
 sub.addSymbols(WildcardSymbol.ALL);

Observing wildcard subscription

Any instance of ObservableSubscription that is retrieved via DXPublisher.getSubscription method can observe WildcardSymbol.ALL object in its set of symbols if any feed consumer subscribes to wildcard symbol. The recommended approach is to use instanceof WildcardSymbol check if support of wildcard subscription is required.

Limitations

Do not mix WildcardSymbol subscription and subscription to other symbols in a single instance of DXFeedSubscription. Doing so may result in a duplication of events and/or other implementation-specific adverse effects.

Subscription via wildcard symbol for LastingEvent types does not count for the purpose of DXFeed.getLastEvent and DXFeed.getLastEvents methods. Lasting events that are received via wildcard subscription are not conflated in the usual way. They may incur significantly higher resource requirements to process them and may get queued when network and CPU resources are inadequate.

Future compatibility

In the future this class may be extended with support for more specific wildcards in addition to ALL. Data provides that publish events via DXPublisher, track subscription via DXPublisher.getSubscription method, and plan to detect wildcard subscription in order to start publishing all possible events, should use symbol instanceof WildcardSymbol code to detect wildcard symbols to be future-proof.

See Also:
Serialized Form

Field Summary
static WildcardSymbol ALL
          Represents [wildcard] subscription to all events of the specific event type.
static String RESERVED_PREFIX
          Symbol prefix that is reserved for wildcard subscriptions.
 
Method Summary
 boolean equals(Object o)
           
 int hashCode()
           
 String toString()
          Returns "*".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RESERVED_PREFIX

public static final String RESERVED_PREFIX
Symbol prefix that is reserved for wildcard subscriptions. Any subscription starting with "*" is ignored with the exception of WildcardSymbol subscription.

See Also:
Constant Field Values

ALL

public static final WildcardSymbol ALL
Represents [wildcard] subscription to all events of the specific event type.

See Also:
WildcardSymbol
Method Detail

toString

public String toString()
Returns "*".

Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013 Devexperts. All Rights Reserved.