# Best Java API for FAST

**URL:** <https://forum.fixtrading.org/t/best-java-api-for-fast/757>\
**Category:** General Q&A\
**Tags:** xid\_169533, imported, fast-protocol\
**Created:** [September 11, 2012, 3:50am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757 "2012-09-11T03:50:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 11, 2012, 3:50am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/1 "2012-09-11T03:50:16Z")

</div>

Imported from previous forum

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 11, 2012, 3:50am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/2 "2012-09-11T03:50:16Z")

</div>

Hi All,

What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?

Really appreciate if you can share your experience.

Thanks;

---

<div class="post-metadata">

**Author:** ![fplpo\_x](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@fplpo\_x](https://forum.fixtrading.org/u/fplpo_x)\
**Post date:** [September 11, 2012, 4:52am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/3 "2012-09-11T04:52:16Z")

</div>

[original email was from janaka Sooriyaarachchi - [janakas@millenniumit.com](mailto:janakas@millenniumit.com) ]  
OpenFAST is better (I can’t say this is the best).

[http://www.openfast.org/](http://www.openfast.org/)

> Hi All,
> 
> What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> 
> Really appreciate if you can share your experience.
> 
> Thanks;

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 11, 2012, 9:34am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/4 "2012-09-11T09:34:09Z")

</div>

I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.

If you can let me know any other good Java API for FAST, it will be really helpful.

> OpenFAST is better (I can’t say this is the best).
> 
> [http://www.openfast.org/](http://www.openfast.org/)
> 
> > Hi All,
> > 
> > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > 
> > Really appreciate if you can share your experience.
> > 
> > Thanks;

---

<div class="post-metadata">

**Author:** ![fplpo\_x](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@fplpo\_x](https://forum.fixtrading.org/u/fplpo_x)\
**Post date:** [September 11, 2012, 10:16am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/5 "2012-09-11T10:16:19Z")

</div>

[original email was from janaka Sooriyaarachchi - [janakas@millenniumit.com](mailto:janakas@millenniumit.com) ]  
How is message rate of your data feed and what is the protocol (tcp/udp) ?

I don’t think data rate will impact on the functionality of OpenFast library.

> I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> 
> If you can let me know any other good Java API for FAST, it will be really helpful.
> 
> > OpenFAST is better (I can’t say this is the best).
> > 
> > [http://www.openfast.org/](http://www.openfast.org/)
> > 
> > > Hi All,
> > > 
> > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > 
> > > Really appreciate if you can share your experience.
> > > 
> > > Thanks;

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 12, 2012, 6:06am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/6 "2012-09-12T06:06:00Z")

</div>

Thanks a lot Janaka for replying.

Actually, we get thousands messages within few seconds on TCP channel.

I have copied my classes below.

This is my message reader class  
…

public class MessageReader {

```
private final MessageInputStream messageIn;
protected MessageBlockReaderFactory messageBlockReaderFactory;

public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {

	messageIn = new MessageInputStream(inputStream);
	messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
	messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
	MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
	messageIn.setBlockReader(msgBlockReader);
	messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
	messageIn.reset();

}

public synchronized Message readMessage() {

	Message m = messageIn.readMessage();

	return m;

}

public void reset() {
	messageIn.reset();
}

public void close() {
	messageIn.close();
}

public int getRemainingBytes() {
	try {
		return messageIn.getUnderlyingStream().available();
	} catch (IOException e) {
	}
	return -1;
}

private static final MessageHandler RESET_HANDLER = new MessageHandler() {
	@Override
	public void handleMessage(Message readMessage, Context context, Coder coder) {
		coder.reset();
	}
};

```

}

…

This is how I read messages

…

final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);

```
	new Thread() {
		public void run() {
			while (true) {

				try {
					
					Message message = reader.readMessage();

					if (message == null) {
						break;
					}

					handleMessage(message);

				} catch (FastException exception) {
					exception.printStackTrace();
					
				}
			}
		}
	}.start();

```

…

Error messages we received when reading messages on TCP channel.

…

org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
at org.openfast.template.Scalar.decode(Scalar.java:246)  
at org.openfast.template.Sequence.decode(Sequence.java:200)  
at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
… 3 more  
Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
at org.openfast.Global.handleError(Global.java:41)  
at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
at org.openfast.template.Scalar.decode(Scalar.java:240)  
… 6 more

…

It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.

Thanks,

> How is message rate of your data feed and what is the protocol (tcp/udp) ?
> 
> I don’t think data rate will impact on the functionality of OpenFast library.
> 
> > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > 
> > If you can let me know any other good Java API for FAST, it will be really helpful.
> > 
> > > OpenFAST is better (I can’t say this is the best).
> > > 
> > > [http://www.openfast.org/](http://www.openfast.org/)
> > > 
> > > > Hi All,
> > > > 
> > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > 
> > > > Really appreciate if you can share your experience.
> > > > 
> > > > Thanks;

---

<div class="post-metadata">

**Author:** ![fplpo\_x](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@fplpo\_x](https://forum.fixtrading.org/u/fplpo_x)\
**Post date:** [September 12, 2012, 6:32am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/7 "2012-09-12T06:32:47Z")

</div>

[original email was from janaka Sooriyaarachchi - [janakas@millenniumit.com](mailto:janakas@millenniumit.com) ]  
As per the error message this is not a issue which related to data rate.  
This relates to message decoding and template miss-matching.

So Check the following points,

1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.

2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.

3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.

> Thanks a lot Janaka for replying.
> 
> Actually, we get thousands messages within few seconds on TCP channel.
> 
> I have copied my classes below.
> 
> This is my message reader class  
> …
> 
> public class MessageReader {
> 
> private final MessageInputStream messageIn;  
> protected MessageBlockReaderFactory messageBlockReaderFactory;
> 
> public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> 
> ```
> messageIn = new MessageInputStream(inputStream);
> messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> messageIn.setBlockReader(msgBlockReader);
> messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> messageIn.reset();
> 
> ```
> 
> }
> 
> public synchronized Message readMessage() {
> 
> ```
> Message m = messageIn.readMessage();
> 
> return m;
> 
> ```
> 
> }
> 
> public void reset() {  
> messageIn.reset();  
> }
> 
> public void close() {  
> messageIn.close();  
> }
> 
> public int getRemainingBytes() {  
> try {  
> return messageIn.getUnderlyingStream().available();  
> } catch (IOException e) {  
> }  
> return -1;  
> }
> 
> private static final MessageHandler RESET\_HANDLER = new MessageHandler() {  
> @Override  
> public void handleMessage(Message readMessage, Context context, Coder coder) {  
> coder.reset();  
> }  
> };
> 
> }
> 
> …
> 
> This is how I read messages
> 
> …
> 
> final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> 
> ```
> new Thread() {
> public void run() {
> while (true) {
> 
> try {
>   				
> Message message = reader.readMessage();
> 
> if (message == null) {
> break;
> }
> 
> handleMessage(message);
> 
> } catch (FastException exception) {
> exception.printStackTrace();
>   				
> }
> }
> }
> }.start();
> 
> ```
> 
> …
> 
> Error messages we received when reading messages on TCP channel.
> 
> …
> 
> org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> at org.openfast.template.Scalar.decode(Scalar.java:246)  
> at org.openfast.template.Sequence.decode(Sequence.java:200)  
> at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> … 3 more  
> Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> at org.openfast.Global.handleError(Global.java:41)  
> at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> at org.openfast.template.Scalar.decode(Scalar.java:240)  
> … 6 more
> 
> …
> 
> It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> 
> Thanks,
> 
> > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > 
> > I don’t think data rate will impact on the functionality of OpenFast library.
> > 
> > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > 
> > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > 
> > > > OpenFAST is better (I can’t say this is the best).
> > > > 
> > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > 
> > > > > Hi All,
> > > > > 
> > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > 
> > > > > Really appreciate if you can share your experience.
> > > > > 
> > > > > Thanks;

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 12, 2012, 7:12am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/8 "2012-09-12T07:12:25Z")

</div>

Thank you very much Janaka.

I checked XML Templates, both are identical.

Could you please let me know how to archive 2nd and 3rd points, as I’m new to OpenFast? It would be really great if you share some resources to understand this.

Thanks a lot again.

> As per the error message this is not a issue which related to data rate.  
> This relates to message decoding and template miss-matching.
> 
> So Check the following points,
> 
> 1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.
> 
> 2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.
> 
> 3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.
> 
> > Thanks a lot Janaka for replying.
> > 
> > Actually, we get thousands messages within few seconds on TCP channel.
> > 
> > I have copied my classes below.
> > 
> > This is my message reader class  
> > …
> > 
> > public class MessageReader {
> > 
> > ```
> > private final MessageInputStream messageIn;
> > protected MessageBlockReaderFactory messageBlockReaderFactory;
> > 
> > public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> > 
> > messageIn = new MessageInputStream(inputStream);
> > messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> > messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> > MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> > messageIn.setBlockReader(msgBlockReader);
> > messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> > messageIn.reset();
> > 
> > }
> > 
> > public synchronized Message readMessage() {
> > 
> > Message m = messageIn.readMessage();
> > 
> > return m;
> > 
> > }
> > 
> > public void reset() {
> > messageIn.reset();
> > }
> > 
> > public void close() {
> > messageIn.close();
> > }
> > 
> > public int getRemainingBytes() {
> > try {
> > return messageIn.getUnderlyingStream().available();
> > } catch (IOException e) {
> > }
> > return -1;
> > }
> > 
> > private static final MessageHandler RESET_HANDLER = new MessageHandler() {
> > @Override
> > public void handleMessage(Message readMessage, Context context, Coder coder) {
> > coder.reset();
> > }
> > };
> > 
> > ```
> > 
> > }
> > 
> > …
> > 
> > This is how I read messages
> > 
> > …
> > 
> > final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> > 
> > ```
> > new Thread() {
> > public void run() {
> > while (true) {
> > 
> > try {
> >   				
> > Message message = reader.readMessage();
> > 
> > if (message == null) {
> > break;
> > }
> > 
> > handleMessage(message);
> > 
> > } catch (FastException exception) {
> > exception.printStackTrace();
> >   				
> > }
> > }
> > }
> > }.start();
> > 
> > ```
> > 
> > …
> > 
> > Error messages we received when reading messages on TCP channel.
> > 
> > …
> > 
> > org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> > at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> > at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> > Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> > at org.openfast.template.Scalar.decode(Scalar.java:246)  
> > at org.openfast.template.Sequence.decode(Sequence.java:200)  
> > at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> > … 3 more  
> > Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> > at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> > at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> > at org.openfast.Global.handleError(Global.java:41)  
> > at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> > at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> > at org.openfast.template.Scalar.decode(Scalar.java:240)  
> > … 6 more
> > 
> > …
> > 
> > It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> > 
> > Thanks,
> > 
> > > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > > 
> > > I don’t think data rate will impact on the functionality of OpenFast library.
> > > 
> > > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > > 
> > > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > > 
> > > > > OpenFAST is better (I can’t say this is the best).
> > > > > 
> > > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > > 
> > > > > > Hi All,
> > > > > > 
> > > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > > 
> > > > > > Really appreciate if you can share your experience.
> > > > > > 
> > > > > > Thanks;

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 12, 2012, 7:27am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/9 "2012-09-12T07:27:40Z")

</div>

Just want to highlight one thing.

I’m not getting this error every time. Sometime, my application works without any error, but sometime we get this decoding error after processing few messages.

Also, I have skipped first bit (message length) before decoding.

…

return new MessageBlockReader() {  
@Override  
public void messageRead(InputStream in, Message message) {  
}

```
		@Override
		public boolean readBlock(InputStream in) {
			try {
				in.skip(offset);
				return true;
			} catch (IOException e) {
				e.printStackTrace();
				return false;
			}
		}

		@Override
		public String toString() {
			return "(default block reader, offset=" + offset + ")";
		}
	};

```

…

Do you see any issues on above code?

Thanks;

> Thank you very much Janaka.
> 
> I checked XML Templates, both are identical.
> 
> Could you please let me know how to archive 2nd and 3rd points, as I’m new to OpenFast? It would be really great if you share some resources to understand this.
> 
> Thanks a lot again.
> 
> > As per the error message this is not a issue which related to data rate.  
> > This relates to message decoding and template miss-matching.
> > 
> > So Check the following points,
> > 
> > 1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.
> > 
> > 2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.
> > 
> > 3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.
> > 
> > > Thanks a lot Janaka for replying.
> > > 
> > > Actually, we get thousands messages within few seconds on TCP channel.
> > > 
> > > I have copied my classes below.
> > > 
> > > This is my message reader class  
> > > …
> > > 
> > > public class MessageReader {
> > > 
> > > ```
> > > private final MessageInputStream messageIn;
> > > protected MessageBlockReaderFactory messageBlockReaderFactory;
> > > 
> > > public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> > > 
> > > messageIn = new MessageInputStream(inputStream);
> > > messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> > > messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> > > MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> > > messageIn.setBlockReader(msgBlockReader);
> > > messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> > > messageIn.reset();
> > > 
> > > }
> > > 
> > > public synchronized Message readMessage() {
> > > 
> > > Message m = messageIn.readMessage();
> > > 
> > > return m;
> > > 
> > > }
> > > 
> > > public void reset() {
> > > messageIn.reset();
> > > }
> > > 
> > > public void close() {
> > > messageIn.close();
> > > }
> > > 
> > > public int getRemainingBytes() {
> > > try {
> > > return messageIn.getUnderlyingStream().available();
> > > } catch (IOException e) {
> > > }
> > > return -1;
> > > }
> > > 
> > > private static final MessageHandler RESET_HANDLER = new MessageHandler() {
> > > @Override
> > > public void handleMessage(Message readMessage, Context context, Coder coder) {
> > > coder.reset();
> > > }
> > > };
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > …
> > > 
> > > This is how I read messages
> > > 
> > > …
> > > 
> > > final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> > > 
> > > ```
> > > new Thread() {
> > > public void run() {
> > > while (true) {
> > > 
> > > try {
> > >   				
> > > Message message = reader.readMessage();
> > > 
> > > if (message == null) {
> > > break;
> > > }
> > > 
> > > handleMessage(message);
> > > 
> > > } catch (FastException exception) {
> > > exception.printStackTrace();
> > >   				
> > > }
> > > }
> > > }
> > > }.start();
> > > 
> > > ```
> > > 
> > > …
> > > 
> > > Error messages we received when reading messages on TCP channel.
> > > 
> > > …
> > > 
> > > org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> > > at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> > > at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> > > Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> > > at org.openfast.template.Scalar.decode(Scalar.java:246)  
> > > at org.openfast.template.Sequence.decode(Sequence.java:200)  
> > > at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> > > … 3 more  
> > > Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> > > at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> > > at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> > > at org.openfast.Global.handleError(Global.java:41)  
> > > at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> > > at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> > > at org.openfast.template.Scalar.decode(Scalar.java:240)  
> > > … 6 more
> > > 
> > > …
> > > 
> > > It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> > > 
> > > Thanks,
> > > 
> > > > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > > > 
> > > > I don’t think data rate will impact on the functionality of OpenFast library.
> > > > 
> > > > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > > > 
> > > > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > > > 
> > > > > > OpenFAST is better (I can’t say this is the best).
> > > > > > 
> > > > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > > > 
> > > > > > > Hi All,
> > > > > > > 
> > > > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > > > 
> > > > > > > Really appreciate if you can share your experience.
> > > > > > > 
> > > > > > > Thanks;

---

<div class="post-metadata">

**Author:** ![fplpo\_x](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@fplpo\_x](https://forum.fixtrading.org/u/fplpo_x)\
**Post date:** [September 12, 2012, 7:39am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/10 "2012-09-12T07:39:39Z")

</div>

[original email was from janaka Sooriyaarachchi - [janakas@millenniumit.com](mailto:janakas@millenniumit.com) ]  
Do not skip one byte always it may vary as per the length of the message. That length field is encoded as a unsigned integer. If message length \> 128 then it length field consist with 2 bytes.

You can use unsigned field decoding functions in OPEN FAST and get the length of message length. Then skip those bytes and decode the message.

Field decoding code samples may find via google.

> Just want to highlight one thing.
> 
> I’m not getting this error every time. Sometime, my application works without any error, but sometime we get this decoding error after processing few messages.
> 
> Also, I have skipped first bit (message length) before decoding.
> 
> …
> 
> return new MessageBlockReader() {  
> @Override  
> public void messageRead(InputStream in, Message message) {  
> }
> 
> ```
> @Override
> public boolean readBlock(InputStream in) {
> try {
> in.skip(offset);
> return true;
> } catch (IOException e) {
> e.printStackTrace();
> return false;
> }
> }
> 
> @Override
> public String toString() {
> return "(default block reader, offset=" + offset + ")";
> }
> };
> 
> ```
> 
> …
> 
> Do you see any issues on above code?
> 
> Thanks;
> 
> > Thank you very much Janaka.
> > 
> > I checked XML Templates, both are identical.
> > 
> > Could you please let me know how to archive 2nd and 3rd points, as I’m new to OpenFast? It would be really great if you share some resources to understand this.
> > 
> > Thanks a lot again.
> > 
> > > As per the error message this is not a issue which related to data rate.  
> > > This relates to message decoding and template miss-matching.
> > > 
> > > So Check the following points,
> > > 
> > > 1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.
> > > 
> > > 2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.
> > > 
> > > 3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.
> > > 
> > > > Thanks a lot Janaka for replying.
> > > > 
> > > > Actually, we get thousands messages within few seconds on TCP channel.
> > > > 
> > > > I have copied my classes below.
> > > > 
> > > > This is my message reader class  
> > > > …
> > > > 
> > > > public class MessageReader {
> > > > 
> > > > ```
> > > > private final MessageInputStream messageIn;
> > > > protected MessageBlockReaderFactory messageBlockReaderFactory;
> > > > 
> > > > public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> > > > 
> > > > messageIn = new MessageInputStream(inputStream);
> > > > messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> > > > messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> > > > MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> > > > messageIn.setBlockReader(msgBlockReader);
> > > > messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> > > > messageIn.reset();
> > > > 
> > > > }
> > > > 
> > > > public synchronized Message readMessage() {
> > > > 
> > > > Message m = messageIn.readMessage();
> > > > 
> > > > return m;
> > > > 
> > > > }
> > > > 
> > > > public void reset() {
> > > > messageIn.reset();
> > > > }
> > > > 
> > > > public void close() {
> > > > messageIn.close();
> > > > }
> > > > 
> > > > public int getRemainingBytes() {
> > > > try {
> > > > return messageIn.getUnderlyingStream().available();
> > > > } catch (IOException e) {
> > > > }
> > > > return -1;
> > > > }
> > > > 
> > > > private static final MessageHandler RESET_HANDLER = new MessageHandler() {
> > > > @Override
> > > > public void handleMessage(Message readMessage, Context context, Coder coder) {
> > > > coder.reset();
> > > > }
> > > > };
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > …
> > > > 
> > > > This is how I read messages
> > > > 
> > > > …
> > > > 
> > > > final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> > > > 
> > > > ```
> > > > new Thread() {
> > > > public void run() {
> > > > while (true) {
> > > > 
> > > > try {
> > > >   				
> > > > Message message = reader.readMessage();
> > > > 
> > > > if (message == null) {
> > > > break;
> > > > }
> > > > 
> > > > handleMessage(message);
> > > > 
> > > > } catch (FastException exception) {
> > > > exception.printStackTrace();
> > > >   				
> > > > }
> > > > }
> > > > }
> > > > }.start();
> > > > 
> > > > ```
> > > > 
> > > > …
> > > > 
> > > > Error messages we received when reading messages on TCP channel.
> > > > 
> > > > …
> > > > 
> > > > org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> > > > at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> > > > at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> > > > Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> > > > at org.openfast.template.Scalar.decode(Scalar.java:246)  
> > > > at org.openfast.template.Sequence.decode(Sequence.java:200)  
> > > > at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> > > > … 3 more  
> > > > Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> > > > at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> > > > at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> > > > at org.openfast.Global.handleError(Global.java:41)  
> > > > at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> > > > at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> > > > at org.openfast.template.Scalar.decode(Scalar.java:240)  
> > > > … 6 more
> > > > 
> > > > …
> > > > 
> > > > It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> > > > 
> > > > Thanks,
> > > > 
> > > > > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > > > > 
> > > > > I don’t think data rate will impact on the functionality of OpenFast library.
> > > > > 
> > > > > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > > > > 
> > > > > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > > > > 
> > > > > > > OpenFAST is better (I can’t say this is the best).
> > > > > > > 
> > > > > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > > > > 
> > > > > > > > Hi All,
> > > > > > > > 
> > > > > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > > > > 
> > > > > > > > Really appreciate if you can share your experience.
> > > > > > > > 
> > > > > > > > Thanks;

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 12, 2012, 7:53am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/11 "2012-09-12T07:53:31Z")

</div>

Do i need to write my own decoder?

> Do not skip one byte always it may vary as per the length of the message. That length field is encoded as a unsigned integer. If message length \> 128 then it length field consist with 2 bytes.
> 
> You can use unsigned field decoding functions in OPEN FAST and get the length of message length. Then skip those bytes and decode the message.
> 
> Field decoding code samples may find via google.
> 
> > Just want to highlight one thing.
> > 
> > I’m not getting this error every time. Sometime, my application works without any error, but sometime we get this decoding error after processing few messages.
> > 
> > Also, I have skipped first bit (message length) before decoding.
> > 
> > …
> > 
> > return new MessageBlockReader() {  
> > @Override  
> > public void messageRead(InputStream in, Message message) {  
> > }
> > 
> > ```
> > @Override
> > public boolean readBlock(InputStream in) {
> > try {
> > in.skip(offset);
> > return true;
> > } catch (IOException e) {
> > e.printStackTrace();
> > return false;
> > }
> > }
> > 
> > @Override
> > public String toString() {
> > return "(default block reader, offset=" + offset + ")";
> > }
> > };
> > 
> > ```
> > 
> > …
> > 
> > Do you see any issues on above code?
> > 
> > Thanks;
> > 
> > > Thank you very much Janaka.
> > > 
> > > I checked XML Templates, both are identical.
> > > 
> > > Could you please let me know how to archive 2nd and 3rd points, as I’m new to OpenFast? It would be really great if you share some resources to understand this.
> > > 
> > > Thanks a lot again.
> > > 
> > > > As per the error message this is not a issue which related to data rate.  
> > > > This relates to message decoding and template miss-matching.
> > > > 
> > > > So Check the following points,
> > > > 
> > > > 1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.
> > > > 
> > > > 2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.
> > > > 
> > > > 3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.
> > > > 
> > > > > Thanks a lot Janaka for replying.
> > > > > 
> > > > > Actually, we get thousands messages within few seconds on TCP channel.
> > > > > 
> > > > > I have copied my classes below.
> > > > > 
> > > > > This is my message reader class  
> > > > > …
> > > > > 
> > > > > public class MessageReader {
> > > > > 
> > > > > ```
> > > > > private final MessageInputStream messageIn;
> > > > > protected MessageBlockReaderFactory messageBlockReaderFactory;
> > > > > 
> > > > > public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> > > > > 
> > > > > messageIn = new MessageInputStream(inputStream);
> > > > > messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> > > > > messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> > > > > MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> > > > > messageIn.setBlockReader(msgBlockReader);
> > > > > messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> > > > > messageIn.reset();
> > > > > 
> > > > > }
> > > > > 
> > > > > public synchronized Message readMessage() {
> > > > > 
> > > > > Message m = messageIn.readMessage();
> > > > > 
> > > > > return m;
> > > > > 
> > > > > }
> > > > > 
> > > > > public void reset() {
> > > > > messageIn.reset();
> > > > > }
> > > > > 
> > > > > public void close() {
> > > > > messageIn.close();
> > > > > }
> > > > > 
> > > > > public int getRemainingBytes() {
> > > > > try {
> > > > > return messageIn.getUnderlyingStream().available();
> > > > > } catch (IOException e) {
> > > > > }
> > > > > return -1;
> > > > > }
> > > > > 
> > > > > private static final MessageHandler RESET_HANDLER = new MessageHandler() {
> > > > > @Override
> > > > > public void handleMessage(Message readMessage, Context context, Coder coder) {
> > > > > coder.reset();
> > > > > }
> > > > > };
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > …
> > > > > 
> > > > > This is how I read messages
> > > > > 
> > > > > …
> > > > > 
> > > > > final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> > > > > 
> > > > > ```
> > > > > new Thread() {
> > > > > public void run() {
> > > > > while (true) {
> > > > > 
> > > > > try {
> > > > >   				
> > > > > Message message = reader.readMessage();
> > > > > 
> > > > > if (message == null) {
> > > > > break;
> > > > > }
> > > > > 
> > > > > handleMessage(message);
> > > > > 
> > > > > } catch (FastException exception) {
> > > > > exception.printStackTrace();
> > > > >   				
> > > > > }
> > > > > }
> > > > > }
> > > > > }.start();
> > > > > 
> > > > > ```
> > > > > 
> > > > > …
> > > > > 
> > > > > Error messages we received when reading messages on TCP channel.
> > > > > 
> > > > > …
> > > > > 
> > > > > org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> > > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> > > > > at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> > > > > at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> > > > > Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> > > > > at org.openfast.template.Scalar.decode(Scalar.java:246)  
> > > > > at org.openfast.template.Sequence.decode(Sequence.java:200)  
> > > > > at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> > > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> > > > > … 3 more  
> > > > > Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> > > > > at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> > > > > at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> > > > > at org.openfast.Global.handleError(Global.java:41)  
> > > > > at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> > > > > at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> > > > > at org.openfast.template.Scalar.decode(Scalar.java:240)  
> > > > > … 6 more
> > > > > 
> > > > > …
> > > > > 
> > > > > It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > > > > > 
> > > > > > I don’t think data rate will impact on the functionality of OpenFast library.
> > > > > > 
> > > > > > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > > > > > 
> > > > > > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > > > > > 
> > > > > > > > OpenFAST is better (I can’t say this is the best).
> > > > > > > > 
> > > > > > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > > > > > 
> > > > > > > > > Hi All,
> > > > > > > > > 
> > > > > > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > > > > > 
> > > > > > > > > Really appreciate if you can share your experience.
> > > > > > > > > 
> > > > > > > > > Thanks;

---

<div class="post-metadata">

**Author:** ![fplpo\_x](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@fplpo\_x](https://forum.fixtrading.org/u/fplpo_x)\
**Post date:** [September 12, 2012, 8:02am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/12 "2012-09-12T08:02:28Z")

</div>

[original email was from janaka Sooriyaarachchi - [janakas@millenniumit.com](mailto:janakas@millenniumit.com) ]  
Decoding function available in library. You can use it.

> Do i need to write my own decoder?
> 
> > Do not skip one byte always it may vary as per the length of the message. That length field is encoded as a unsigned integer. If message length \> 128 then it length field consist with 2 bytes.
> > 
> > You can use unsigned field decoding functions in OPEN FAST and get the length of message length. Then skip those bytes and decode the message.
> > 
> > Field decoding code samples may find via google.
> > 
> > > Just want to highlight one thing.
> > > 
> > > I’m not getting this error every time. Sometime, my application works without any error, but sometime we get this decoding error after processing few messages.
> > > 
> > > Also, I have skipped first bit (message length) before decoding.
> > > 
> > > …
> > > 
> > > return new MessageBlockReader() {  
> > > @Override  
> > > public void messageRead(InputStream in, Message message) {  
> > > }
> > > 
> > > ```
> > > @Override
> > > public boolean readBlock(InputStream in) {
> > > try {
> > > in.skip(offset);
> > > return true;
> > > } catch (IOException e) {
> > > e.printStackTrace();
> > > return false;
> > > }
> > > }
> > > 
> > > @Override
> > > public String toString() {
> > > return "(default block reader, offset=" + offset + ")";
> > > }
> > > };
> > > 
> > > ```
> > > 
> > > …
> > > 
> > > Do you see any issues on above code?
> > > 
> > > Thanks;
> > > 
> > > > Thank you very much Janaka.
> > > > 
> > > > I checked XML Templates, both are identical.
> > > > 
> > > > Could you please let me know how to archive 2nd and 3rd points, as I’m new to OpenFast? It would be really great if you share some resources to understand this.
> > > > 
> > > > Thanks a lot again.
> > > > 
> > > > > As per the error message this is not a issue which related to data rate.  
> > > > > This relates to message decoding and template miss-matching.
> > > > > 
> > > > > So Check the following points,
> > > > > 
> > > > > 1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.
> > > > > 
> > > > > 2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.
> > > > > 
> > > > > 3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.
> > > > > 
> > > > > > Thanks a lot Janaka for replying.
> > > > > > 
> > > > > > Actually, we get thousands messages within few seconds on TCP channel.
> > > > > > 
> > > > > > I have copied my classes below.
> > > > > > 
> > > > > > This is my message reader class  
> > > > > > …
> > > > > > 
> > > > > > public class MessageReader {
> > > > > > 
> > > > > > ```
> > > > > > private final MessageInputStream messageIn;
> > > > > > protected MessageBlockReaderFactory messageBlockReaderFactory;
> > > > > > 
> > > > > > public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> > > > > > 
> > > > > > messageIn = new MessageInputStream(inputStream);
> > > > > > messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> > > > > > messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> > > > > > MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> > > > > > messageIn.setBlockReader(msgBlockReader);
> > > > > > messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> > > > > > messageIn.reset();
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > public synchronized Message readMessage() {
> > > > > > 
> > > > > > Message m = messageIn.readMessage();
> > > > > > 
> > > > > > return m;
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > public void reset() {
> > > > > > messageIn.reset();
> > > > > > }
> > > > > > 
> > > > > > public void close() {
> > > > > > messageIn.close();
> > > > > > }
> > > > > > 
> > > > > > public int getRemainingBytes() {
> > > > > > try {
> > > > > > return messageIn.getUnderlyingStream().available();
> > > > > > } catch (IOException e) {
> > > > > > }
> > > > > > return -1;
> > > > > > }
> > > > > > 
> > > > > > private static final MessageHandler RESET_HANDLER = new MessageHandler() {
> > > > > > @Override
> > > > > > public void handleMessage(Message readMessage, Context context, Coder coder) {
> > > > > > coder.reset();
> > > > > > }
> > > > > > };
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > …
> > > > > > 
> > > > > > This is how I read messages
> > > > > > 
> > > > > > …
> > > > > > 
> > > > > > final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> > > > > > 
> > > > > > ```
> > > > > > new Thread() {
> > > > > > public void run() {
> > > > > > while (true) {
> > > > > > 
> > > > > > try {
> > > > > >   				
> > > > > > Message message = reader.readMessage();
> > > > > > 
> > > > > > if (message == null) {
> > > > > > break;
> > > > > > }
> > > > > > 
> > > > > > handleMessage(message);
> > > > > > 
> > > > > > } catch (FastException exception) {
> > > > > > exception.printStackTrace();
> > > > > >   				
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > }.start();
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > …
> > > > > > 
> > > > > > Error messages we received when reading messages on TCP channel.
> > > > > > 
> > > > > > …
> > > > > > 
> > > > > > org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> > > > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> > > > > > at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> > > > > > at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> > > > > > Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> > > > > > at org.openfast.template.Scalar.decode(Scalar.java:246)  
> > > > > > at org.openfast.template.Sequence.decode(Sequence.java:200)  
> > > > > > at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> > > > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> > > > > > … 3 more  
> > > > > > Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> > > > > > at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> > > > > > at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> > > > > > at org.openfast.Global.handleError(Global.java:41)  
> > > > > > at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> > > > > > at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> > > > > > at org.openfast.template.Scalar.decode(Scalar.java:240)  
> > > > > > … 6 more
> > > > > > 
> > > > > > …
> > > > > > 
> > > > > > It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> > > > > > 
> > > > > > Thanks,
> > > > > > 
> > > > > > > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > > > > > > 
> > > > > > > I don’t think data rate will impact on the functionality of OpenFast library.
> > > > > > > 
> > > > > > > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > > > > > > 
> > > > > > > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > > > > > > 
> > > > > > > > > OpenFAST is better (I can’t say this is the best).
> > > > > > > > > 
> > > > > > > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > > > > > > 
> > > > > > > > > > Hi All,
> > > > > > > > > > 
> > > > > > > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > > > > > > 
> > > > > > > > > > Really appreciate if you can share your experience.
> > > > > > > > > > 
> > > > > > > > > > Thanks;

---

<div class="post-metadata">

**Author:** ![kapilawitharana\_x](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kapilawitharana\_x](https://forum.fixtrading.org/u/kapilawitharana_x)\
**Post date:** [September 18, 2012, 4:10am UTC](https://forum.fixtrading.org/t/best-java-api-for-fast/757/13 "2012-09-18T04:10:42Z")

</div>

Finally I was able to decode messages successfully.

Thank you very much Janaka for your support and guidance extended to resolve this issue.

Thanks again!

> Decoding function available in library. You can use it.
> 
> > Do i need to write my own decoder?
> > 
> > > Do not skip one byte always it may vary as per the length of the message. That length field is encoded as a unsigned integer. If message length \> 128 then it length field consist with 2 bytes.
> > > 
> > > You can use unsigned field decoding functions in OPEN FAST and get the length of message length. Then skip those bytes and decode the message.
> > > 
> > > Field decoding code samples may find via google.
> > > 
> > > > Just want to highlight one thing.
> > > > 
> > > > I’m not getting this error every time. Sometime, my application works without any error, but sometime we get this decoding error after processing few messages.
> > > > 
> > > > Also, I have skipped first bit (message length) before decoding.
> > > > 
> > > > …
> > > > 
> > > > return new MessageBlockReader() {  
> > > > @Override  
> > > > public void messageRead(InputStream in, Message message) {  
> > > > }
> > > > 
> > > > ```
> > > > @Override
> > > > public boolean readBlock(InputStream in) {
> > > > try {
> > > > in.skip(offset);
> > > > return true;
> > > > } catch (IOException e) {
> > > > e.printStackTrace();
> > > > return false;
> > > > }
> > > > }
> > > > 
> > > > @Override
> > > > public String toString() {
> > > > return "(default block reader, offset=" + offset + ")";
> > > > }
> > > > };
> > > > 
> > > > ```
> > > > 
> > > > …
> > > > 
> > > > Do you see any issues on above code?
> > > > 
> > > > Thanks;
> > > > 
> > > > > Thank you very much Janaka.
> > > > > 
> > > > > I checked XML Templates, both are identical.
> > > > > 
> > > > > Could you please let me know how to archive 2nd and 3rd points, as I’m new to OpenFast? It would be really great if you share some resources to understand this.
> > > > > 
> > > > > Thanks a lot again.
> > > > > 
> > > > > > As per the error message this is not a issue which related to data rate.  
> > > > > > This relates to message decoding and template miss-matching.
> > > > > > 
> > > > > > So Check the following points,
> > > > > > 
> > > > > > 1. XML template file is comply with the target Data Source. If you try to decode FAST Message with incorrect Template you will get this Error. Consider the versions.
> > > > > > 
> > > > > > 2. Check whether FAST message contains a Preamble data. Because some data providers add Non-FAST fix Length Headers to Message. You need to remove those data before decode the message.
> > > > > > 
> > > > > > 3. Check that Data feed contains a Message length field at the begining of the message. Open FAST dose not work with such Data Feeds. You need to decode Message length manually(you can use field decoding functions in OPEN FAST library for that task) and try to decode only the message segment.
> > > > > > 
> > > > > > > Thanks a lot Janaka for replying.
> > > > > > > 
> > > > > > > Actually, we get thousands messages within few seconds on TCP channel.
> > > > > > > 
> > > > > > > I have copied my classes below.
> > > > > > > 
> > > > > > > This is my message reader class  
> > > > > > > …
> > > > > > > 
> > > > > > > public class MessageReader {
> > > > > > > 
> > > > > > > ```
> > > > > > > private final MessageInputStream messageIn;
> > > > > > > protected MessageBlockReaderFactory messageBlockReaderFactory;
> > > > > > > 
> > > > > > > public MessageReader(InputStream inputStream, TemplateStore templateStore, int readOffset) {
> > > > > > > 
> > > > > > > messageIn = new MessageInputStream(inputStream);
> > > > > > > messageIn.setTemplateRegistry(templateStore.getTemplateRegistry());
> > > > > > > messageBlockReaderFactory = new MessageBlockReaderFactory(readOffset);
> > > > > > > MessageBlockReader msgBlockReader = messageBlockReaderFactory.create();
> > > > > > > messageIn.setBlockReader(msgBlockReader);
> > > > > > > messageIn.addMessageHandler(templateStore.getTemplateRegistry().get("Reset"), RESET_HANDLER);
> > > > > > > messageIn.reset();
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > public synchronized Message readMessage() {
> > > > > > > 
> > > > > > > Message m = messageIn.readMessage();
> > > > > > > 
> > > > > > > return m;
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > public void reset() {
> > > > > > > messageIn.reset();
> > > > > > > }
> > > > > > > 
> > > > > > > public void close() {
> > > > > > > messageIn.close();
> > > > > > > }
> > > > > > > 
> > > > > > > public int getRemainingBytes() {
> > > > > > > try {
> > > > > > > return messageIn.getUnderlyingStream().available();
> > > > > > > } catch (IOException e) {
> > > > > > > }
> > > > > > > return -1;
> > > > > > > }
> > > > > > > 
> > > > > > > private static final MessageHandler RESET_HANDLER = new MessageHandler() {
> > > > > > > @Override
> > > > > > > public void handleMessage(Message readMessage, Context context, Coder coder) {
> > > > > > > coder.reset();
> > > > > > > }
> > > > > > > };
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > …
> > > > > > > 
> > > > > > > This is how I read messages
> > > > > > > 
> > > > > > > …
> > > > > > > 
> > > > > > > final MessageReader reader = new MessageReader(bufferedInputStream, templateStore, 1);
> > > > > > > 
> > > > > > > ```
> > > > > > > new Thread() {
> > > > > > > public void run() {
> > > > > > > while (true) {
> > > > > > > 
> > > > > > > try {
> > > > > > >   				
> > > > > > > Message message = reader.readMessage();
> > > > > > > 
> > > > > > > if (message == null) {
> > > > > > > break;
> > > > > > > }
> > > > > > > 
> > > > > > > handleMessage(message);
> > > > > > > 
> > > > > > > } catch (FastException exception) {
> > > > > > > exception.printStackTrace();
> > > > > > >   				
> > > > > > > }
> > > > > > > }
> > > > > > > }
> > > > > > > }.start();
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > …
> > > > > > > 
> > > > > > > Error messages we received when reading messages on TCP channel.
> > > > > > > 
> > > > > > > …
> > > > > > > 
> > > > > > > org.openfast.error.FastException: An error occurred while decoding SecurityDefinition  
> > > > > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:133)  
> > > > > > > at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:82)  
> > > > > > > at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:65)  
> > > > > > > Caused by: org.openfast.error.FastException: Error occurred while decoding Scalar [name=NoSecurityAltID, operator=none, type=uInt32, dictionary=SecurityDefinition]  
> > > > > > > at org.openfast.template.Scalar.decode(Scalar.java:246)  
> > > > > > > at org.openfast.template.Sequence.decode(Sequence.java:200)  
> > > > > > > at org.openfast.template.Group.decodeFieldValues(Group.java:293)  
> > > > > > > at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)  
> > > > > > > … 3 more  
> > > > > > > Caused by: org.openfast.error.FastException: The value 3486042861337320496 is out of range for type uInt32  
> > > > > > > at org.openfast.error.ErrorCode.throwException(ErrorCode.java:45)  
> > > > > > > at org.openfast.error.ErrorHandler$1.error(ErrorHandler.java:26)  
> > > > > > > at org.openfast.Global.handleError(Global.java:41)  
> > > > > > > at org.openfast.template.type.IntegerType.validateValue(IntegerType.java:88)  
> > > > > > > at org.openfast.template.Scalar.validateDecodedValueIsCorrectForType(Scalar.java:260)  
> > > > > > > at org.openfast.template.Scalar.decode(Scalar.java:240)  
> > > > > > > … 6 more
> > > > > > > 
> > > > > > > …
> > > > > > > 
> > > > > > > It would be really great if you can help me to resolve this issue as I have already spent 3 weeks to solve this issue.
> > > > > > > 
> > > > > > > Thanks,
> > > > > > > 
> > > > > > > > How is message rate of your data feed and what is the protocol (tcp/udp) ?
> > > > > > > > 
> > > > > > > > I don’t think data rate will impact on the functionality of OpenFast library.
> > > > > > > > 
> > > > > > > > > I have used OpenFast but it does not decode message when data load is high. That’s why I thought to use other FAST framework or API.
> > > > > > > > > 
> > > > > > > > > If you can let me know any other good Java API for FAST, it will be really helpful.
> > > > > > > > > 
> > > > > > > > > > OpenFAST is better (I can’t say this is the best).
> > > > > > > > > > 
> > > > > > > > > > [http://www.openfast.org/](http://www.openfast.org/)
> > > > > > > > > > 
> > > > > > > > > > > Hi All,
> > > > > > > > > > > 
> > > > > > > > > > > What is the BEST (in-terms of performance/data load) Java API/Lib for FAST (commercial/non-commercial)?
> > > > > > > > > > > 
> > > > > > > > > > > Really appreciate if you can share your experience.
> > > > > > > > > > > 
> > > > > > > > > > > Thanks;
