<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coral Blocks &#187; FAQ</title>
	<atom:link href="https://www.coralblocks.com/index.php/category/faq/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.coralblocks.com/index.php</link>
	<description>Building amazing software, one piece at a time.</description>
	<lastBuildDate>Tue, 21 Apr 2026 23:44:16 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>CoralFIX FAQ</title>
		<link>https://www.coralblocks.com/index.php/coralfix-faq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralfix-faq</link>
		<comments>https://www.coralblocks.com/index.php/coralfix-faq/#comments</comments>
		<pubDate>Mon, 27 Apr 2015 18:47:24 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[coralfix]]></category>
		<category><![CDATA[faq]]></category>
		<category><![CDATA[resent request]]></category>
		<category><![CDATA[retransmission]]></category>
		<category><![CDATA[sequence reset]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1458</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below some frequently asked questions about CoralFIX. <span id="more-1458"></span></p>
<style>
.li_faq { margin: 0 0 30px 0; }
</style>
<ol style="padding: 12px 40px">
<li class="li_faq"><font color="#26619b"><strong>How to get string values from a FIX message without producing garbage?</strong></font><br />
You can simply call <code>getCharSequence(FixTag)</code>. CoralFIX maintains a <code>StringBuilder</code> pool under-the-hood and will always return a different instance with the string contents as a <code>CharSequence</code>. Just keep in mind that the pool is reset on every new FIX message, in other words, the StringBuilders from the pool will be re-used/overwritten on the following FIX message received. Therefore, although that&#8217;s seldom the use-case, if you need to store/save the string value across multiple FIX messages you must copy the contents from the CharSequence returned to somewhere else.</li>
<li class="li_faq"><font color="#26619b"><strong>Can I get string values as a byte array so I can use them as keys to a ByteArrayMap?</strong></font><br />
Yes! Below an example:</p>
<pre class="brush: java; title: ; notranslate">
// first write a space (' ') to all bytes of the byte array
ByteArrayUtils.clear(orderIdByteArray);

// read the string value into the byte array
int orderIdLength = fixMsg.readBytes(FixTags.OrderID, orderIdByteArray);

if (orderIdLength &lt;= 0) {
    // OrderID tag not present... nothing was read...
} else {
    // use the byte array as the key to a ByteArrayMap
    Order order = orderByteArrayMap.get(orderIdByteArray);
    // (...)
}
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralfix-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralReactor FAQ</title>
		<link>https://www.coralblocks.com/index.php/coralreactor-faq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralreactor-faq</link>
		<comments>https://www.coralblocks.com/index.php/coralreactor-faq/#comments</comments>
		<pubDate>Mon, 27 Apr 2015 03:21:08 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[coralreactor]]></category>
		<category><![CDATA[faq]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nio]]></category>
		<category><![CDATA[non-blocking]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1440</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below some frequently asked questions about CoralReactor. <span id="more-1440"></span></p>
<style>
.li_faq { margin: 0 0 30px 0; }
</style>
<ol style="padding: 12px 40px">
<li class="li_faq"><font color="#26619b"><strong>How do I change the underlying socket send and receive buffer size?</strong></font><br />
You can set the underlying kernel socket send and receive buffer size from Java. By default, CoralReactor will try to set the size of these buffers to 12Mb. If it is unable to change the size, it will alert you with an error log. The size limit of these buffers is configured in the OS level, so you might have to tweak your OS configuration to allow bigger buffers. To pass your own size, you can do:</p>
<pre class="brush: java; title: ; notranslate">
config.add(&quot;readSocketBufferSize&quot;, 24 * 1024 * 1024);
config.add(&quot;writeSocketBufferSize&quot; 24 * 1024 * 1024);

Client client = new MyClient(nio, &quot;localhost&quot;, 44444, config);
</pre>
<p>You can also overwrite the default value from 12Mb to whatever you want with with the JVM command-line option: <code>-DreadSocketBufferSize</code> and <code>-DwriteSocketBufferSize</code>. Just keep in mind that this will affect only the clients and servers that have not set their own size through the config.
</li>
<li class="li_faq"><font color="#26619b"><strong>Does AbstractUdpClient support multicast?</strong></font><br />
Yes. Just pass a multicast address and it will join and work automatically. You can also specify the nic name/address to join through the client config:</p>
<pre class="brush: java; title: ; notranslate">
config.add(&quot;nic&quot;, &quot;p1p4&quot;);

Client client = new MyMulticastClient(nio, &quot;224.4.4.4&quot;, 44444, config);
</pre>
<p>By default, a multicast client will join/leave automatically. If you want to join/leave the multicast group yourself you can call the methods <code>join()</code> and <code>leave()</code> manually. To do that pass in the client config:</p>
<pre class="brush: java; title: ; notranslate">
config.add(&quot;joinAutomatically&quot;, false);
</pre>
</li>
<li class="li_faq"><font color="#26619b"><strong>Does AbstractUdpClient support broadcast?</strong></font><br />
Yes. Just pass a broadcast address and the client will receive broadcast packets. To send packets to a broadcast address you must remember to set the SO_BROADCAST option on the client. To do that, simply set <i>isBroadcastAddr</i> to true int the client config:</p>
<pre class="brush: java; title: ; notranslate">
config.add(&quot;isBroadcastAddr&quot;, true);
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralreactor-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralStore FAQ</title>
		<link>https://www.coralblocks.com/index.php/coralstore-faq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralstore-faq</link>
		<comments>https://www.coralblocks.com/index.php/coralstore-faq/#comments</comments>
		<pubDate>Sat, 25 Apr 2015 17:45:58 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[async store]]></category>
		<category><![CDATA[asynchronous store]]></category>
		<category><![CDATA[coralqueue]]></category>
		<category><![CDATA[CoralStore]]></category>
		<category><![CDATA[lock-free]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[store]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1422</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below some frequently asked questions about CoralStore. <span id="more-1422"></span></p>
<style>
.li_faq { margin: 0 0 30px 0; }
</style>
<ol style="padding: 12px 40px">
<li class="li_faq"><font color="#26619b"><strong>When using an asynchronous store, don&#8217;t you lose messages in the queue in the event of a crash?</strong></font><br />
No. CoralStore will automatically drain the queue using a shutdown hook in the event of a crash. You can also control the queue explicitly if you want to with the methods below, but you don&#8217;t have to.</p>
<pre class="brush: java; title: ; notranslate">
// this method will block, wait for the store queue to be drained and then return
asyncStore.drainAndWait();

// drain and close the the store gracefully
// this method will NOT block, returning immediately, but all messages from the store will
// be processed before the store is closed
asyncStore.close(); // returns immediately, but adds a close event in the queue for this store
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralstore-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralLog FAQ</title>
		<link>https://www.coralblocks.com/index.php/corallog-faq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=corallog-faq</link>
		<comments>https://www.coralblocks.com/index.php/corallog-faq/#comments</comments>
		<pubDate>Fri, 24 Apr 2015 21:23:43 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[corallog]]></category>
		<category><![CDATA[faq]]></category>
		<category><![CDATA[garbage collector]]></category>
		<category><![CDATA[gc]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1392</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below some frequently asked questions about CoralLog. <span id="more-1392"></span></p>
<style>
.li_faq { margin: 0 0 30px 0; }
</style>
<ol style="padding: 12px 40px">
<li class="li_faq"><font color="#26619b"><strong>Does CoralLog use off-heap memory?</strong></font><br />
No. <strong>CoralLog does not allocate any off-heap memory through <code>sun.misc.Unsafe</code></strong>. You can log as many gigabytes as you want to your log files and CoralLog never produces any garbage for the GC. CoralLog does extensively use <i>direct byte buffers</i> which is off-heap memory allocated by the JVM in a more <em>standard</em> way.
</li>
<li class="li_faq"><font color="#26619b"><strong>Does CoralLog use memory-mapped files?</strong></font><br />
Memory-mapped files can be used for <i>asynchronous</i> logging since you write to memory and the OS is the one performing file I/O in the background, from memory to disk. <strong>CoralLog uses a different approach for asynchronous logging.</strong> It uses CoralQueue under the hood for blazing fast and garbage-free inter-thread communication. Therefore, instead of writing to a memory-mapped file, messages are written in nanoseconds to a high-performance queue that later passes them to a dedicated file I/O thread. CoralLog does support memory-mapped files for log files, but this option is off by default as it offers little gains for latency. It does help a bit for throughput and you can turn it on easily if throughput is important to you.
</li>
<li class="li_faq"><font color="#26619b"><strong>Because CoralLog is asynchronous, don&#8217;t you lose messages in the queue in the event of a crash?</strong></font><br />
No. CoralLog will automatically drain the queue using a shutdown hook in the event of a crash. You can also control the queue explicitly if you want with the methods below, but you don&#8217;t have to.</p>
<pre class="brush: java; title: ; notranslate">
// drain and close the the logger gracefully
// this method will block, wait for the queue to be drained, wait for the logger to be closed and then return
 myLogger.drainCloseAndWait();
 
// if you don't want to close, but just want to drain, you can do:
// this method will block, wait for the queue to be drained and then return
myLogger.drainAndWait();

// drain and close the the logger gracefully
// this method will NOT block, returning immediately, but all messages from this logger will
// be processed before the logger is closed
myLogger.close(); // returns immediately, but adds a close event in the queue for this logger
</pre>
</li>
<li class="li_faq"><font color="#26619b"><strong>Because CoralLog uses varargs, don&#8217;t you create garbage there?</strong></font><br />
No. CoralLog implements its own <i>varargs</i> and supports up to 16 objects without creating any garbage.
</li>
<li class="li_faq"><font color="#26619b"><strong>What about autoboxing? You will be creating garbage there, right?</strong></font><br />
No. CoralLog offers a straightforward way to avoid autoboxing as the code below demonstrates.</p>
<pre class="brush: java; title: ; notranslate">
long id = 2342342342;

// autoboxing will happen for id and garbage will be created
myLogger.log(&quot;This is a log message!&quot;, &quot;user=&quot;, &quot;foo&quot;, &quot;id=&quot;, id);

// NO AUTOBOXING ANYMORE
myLogger.log(&quot;This is a log message!&quot;, &quot;user=&quot;, &quot;foo&quot;, &quot;id=&quot;, to_sb(id));
</pre>
</li>
<li class="li_faq"><font color="#26619b"><strong>Doesn&#8217;t CoralLog call <code>toString()</code> on objects creating garbage?</strong></font><br />
No. For common objects, CoralLog knows how to log them without creating strings and garbage. That&#8217;s the case for: <code>CharSequence</code>, <code>byte[]</code>, <code>char[]</code>, <code>ByteBuffer</code> and <code>Throwable</code>. You can also add your own <i>encoders</i> for your objects so you can pass them by reference to a logger without having to worry about generating garbage through a <code>toString()</code> call.
</li>
<li class="li_faq"><font color="#26619b"><strong>Can CoralLog be used in multithreaded environments?</strong></font><br />
Yes. You can have multiple loggers being accessed by multiple threads as long as the same logger instance is not accessed concurrently by two different threads. If you want to access the same logger concurrently, then you can make the logger thread-safe. For level logging, the level loggers (Info, Warn, Debug, etc.) are already thread-safe by default. For event sourcing you can make a logger thread-safe when you create it through a <code>LogConfig</code>.</p>
<pre class="brush: java; title: ; notranslate">
LogConfig logConfig = new LogConfig(myDir, myFilename);

// make the logger thread-safe
logConfig.isSynchronized = true; // default is false
 
Logger myLogger = Log.createLogger(logConfig);

// feel free to share myLogger among threads now
</pre>
</li>
<li class="li_faq"><font color="#26619b"><strong>Is CoralLog compatible with SLF4J?</strong></font><br />
Yes. CoralLog provides a wrapper for <code>org.slf4j.Logger</code> by extending the <code>org.slf4j.helpers.MarkerIgnoringBase</code>. To inject CoralLog in your application without any dependencies to CoralLog code or classes you just need to add the CoralLog jar in the front of your classpath (i.e. in front of any other SLF4J implementation). Below a simple SLF4J example that uses the CoralLog implementation under the hood. Note that there are no references to CoralLog in the code.</p>
<pre class="brush: java; title: ; notranslate">
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestSlf4j {
	
	private final Logger logger = LoggerFactory.getLogger(TestSlf4j.class);
	
	public void logSomething() {
		logger.info(&quot;This is a intergration test between CoralLog and Slf4j!&quot;);
	}
	
	public static void main(String[] args) {
		TestSlf4j test = new TestSlf4j();
		test.logSomething();
	}
}
</pre>
</li>
<li class="li_faq"><font color="#26619b"><strong>Can I configure CoralLog through a properties file?</strong></font><br />
Yes. CoralLog can scan the classpath (when <code>-DcoralLogScanClasspath=true</code>) for a file named <i>CoralLogConfig.properties</i>. If it finds it, it uses it. You can also use the command-line option <code>-DcoralLogConfigFile</code> to specify a different name/location for the config file. Note that the precedence for CoralLog configs is: file config > JVM command-line config > programmatically config. Below a simple properties file with some CoralLog configuration:</p>
<pre>
# CoralLog configuration
logFile = true
logDir = /var/logs/myapps/
logPattern = %p (%D/%M/%Y) - %T - %m%n
</pre>
</li>
<li class="li_faq"><font color="#26619b"><strong>What are the options for pattern defintion?</strong></font>
<pre style="margin-top: 10px;">
    D - day of the month (ex: 23)
    M - month of the year (ex: 02)
    Y - year (ex: 2015)
    T - time in the format HH:MM:SS.SSSSSS (microsecond precision)
    m - the message
    n - carriage return / new line
    p - the log level (INFO, DEBUG, WARN, etc)
    l - the class and line number where the log call was issued (if enabled)
    r - time in milliseconds since the application has started
    e - epoch in microseconds
    i - epoch in milliseconds
</pre>
<p>So for example the pattern:
<pre>---> %p (%D/%M/%Y) - %T - %m%n</pre>
<p> would produce:</p>
<pre class="brush: java; title: ; notranslate">
logger.info(&quot;This is a test!&quot;); // output below:
// ---&gt; INFO (05/10/2015) - 12:42:11.080161 - This is a test!&quot;
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/corallog-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
