Common Ember API Questions
Supported Programming Languages
The Execution Server (ES) uses Java for all user-programmable components, such as algorithms, connectors, callbacks, and so on. All these components running inside the Execution Server must be written in Java. External clients can use Java, REST/WS, or FIX APIs to interact with the Execution Server.
Deltix has other solutions that support C#, C++, and Python, and can interoperate with the Execution Server.
"Publication is closed due timeout" Error
If you are debugging an issue and get a "publication is closed due to timeout" error, it essentially kills the Ember process. There is a workaround.
When setting a breakpoint in the code, edit the Breakpoint Properties:
- Select Suspend > Thread > Make Default.
This keeps the Aeron Heartbeat thread running in the background while you stopped in debugger on breakpoint.
compilation failed
Error while Running Ember Apps under IntelliJ/IDEA
Issue: I see the following or similar compilation failed
error while running Ember apps from IDEA:
ERROR [main] Error compiling type "deltix.timebase.api.messages.calendar.CalendarMessage" bound to deltix.timebase.api.messages.calendar.CalendarMessage: compilation failed: /CalendarMessageBOUND_DECODER1.java:2: error: package deltix.qsrv.hf.pub.codec does not exist public final class CalendarMessageBOUND_DECODER1 implements deltix.qsrv.hf.pub.codec.BoundDecoder, deltix.qsrv.hf.pub.codec.CharSequenceDecoder { ...
This error comes from the TimeBase client code as it tries to compile codecs for the stream you are trying to read. This happens when the compiler sees an incorrect CLASSPATH
.
Workaround options:
- Switch the IDEA runner to a different command line shortening method.
- In .idea/workspace.xml, add
<property name="dynamic.classpath" value="true" />
to<component name="PropertiesComponent">
.
How Do I Set a Custom Order Attribute?
To set a single custom order attribute, follow this code snippet:
private final ReusableCustomAttribute attr = new ReusableCustomAttribute();
/// then something like this:
private void transform(MutableOrderRequest request) {
if (request.getAttributes() != null) {
attr.clear();
attr.setKey(OnBehalfOfCompID);
attr.setValueAsAlphanumeric(request.getSourceId());
((ObjectArrayList)request.getAttributes()).add(attr);
} else {
ObjectList<CustomAttribute> customAttributes = attrBuilder
.clear()
.addText(OnBehalfOfCompID, buffer
.clear()
.appendAlphanumeric(request.getSourceId()))
.build();
request.setAttributes(customAttributes);
}
}
Alternatively, if you need to set multiple custom attributes in an allocation-free manner, use this approach:
private final CustomAttributeListBuilder customAttributesBuilder = new CustomAttributeListBuilder();
request.setAttributes(customAttributesBuilder
.clear()
.addEnum(MyOrderEntryReq.REASON_CUSTOM_ATTRIBUTE_TAG, reason);
.addInteger(Tag.ExecInst, ExecInst.DO_NOT_REDUCE)
.build());
Why Am I Getting a NullPointerException When Setting a Custom Order Request Attribute?
Issue: I am trying to set a custom order request attribute and getting a NullPointerException (NPE):
((ObjectArrayList)request.getAttributes()).add(myAttribute);
In many cases, you don't need custom attributes in a request. By default, when you create a new instance, the MutableOrderNewRequest.attributes
field is NULL
.
To append a custom attribute, you need to initialize it:
ObjectArrayList attributes = (ObjectArrayList) request.getAttributes();
if (attributes == null)
request.setAttributes(attributes = new ObjectArrayList());
MutableCustomAttribute attribute = new MutableCustomAttribute();
attribute.setKey(6021);
attribute.setValue("BEST");
attributes.add(attribute);
To prepare and submit all your algorithm orders, use single instances of MutabeOrderNewRequest
and pre-initialize the attributes list:
private final MutabeOrderNewRequest request = new MutableOrderNewRequest();
private final ObjectArrayList attributes = new ObjectArrayList ();
{
request.setAttributes(attributes);
}
This way, when you submit each order request, you just need to make sure the attributes list contains all the intended attributes.
What happens to the Ember (and specifically with MessageChannel) when the TimeBase is restarted?
When it comes to reading and writing data to TimeBase Ember API offers narrow wrapper over TimeBase. Algorithm MessageChannel output channels are mapped to TickLoader objects of TimeBase API, wrapped into AutoRecoveringLoader
. When this wrapper detects that TimeBase is disconnect it will step sending data to underlying tick loader. When connection to TimeBase is restored, auto-recovering loader will auto-create underlying TickLoader and continue work normally. There is a high chance that message written from the moment connection to TimeBase was lost will be lost.