Chronicle queue synchronous replication

315 views
Skip to first unread message

Dmitry Shilovich

unread,
Nov 26, 2015, 9:47:49 AM11/26/15
to Chronicle
Hi.

I have some questions about Chronicle queue and replication.

How replication works? Do you have any design document (picture) that shows how it works (there is no much info in the docs)? Is it asynchronous?

I have a use case where there are two servers SERVER-1 and SERVER-2. 
SERVER-1 is primary (accept new messages) and SERVER-2 is backup (used during failover). 
When I receive new message on SERVER-1 I want to write it into Chronicle

appender.startExcerpt(message.length);
appender.write(message);
appender.finish();

wait until this message is replicated to SERVER-2, persisted on disk and only after I get an acknowledge from SERVER-2 about successful operation appender.finish() returns on SERVER-1. 
If replication fails (there is no acknowledge from SERVER-2) I want to get something like a ReplicationException. Its like ChronicleQueueBuilder.synchronous(true) but for replication.

Is this possible to implement with Chronicle queue?

Peter Lawrey

unread,
Nov 26, 2015, 10:35:53 AM11/26/15
to java-ch...@googlegroups.com
Hello,
  For diagrams I suggest you have a look at https://github.com/OpenHFT/Chronicle-Queue#replication

  Replication is asynchronous.  For this reason we suggest you have SERVER-2 perform the operation.  This way it knows it has a copy as does SERVER-1 and you don't have to wait for a message to be sent back to SERVER-1.  Once the message has been processed you can replicate what action was take from SERVER-2 back to SERVER-1.  Obviously when one server fails you may want to have it to continue to work, in which case the remaining 

Regards,

   Peter.


--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitry Shilovich

unread,
Nov 26, 2015, 12:18:02 PM11/26/15
to Chronicle

Thank you. I think I get what you mean. You are talking about this picture, aren't you?  =)

Is there any sample code (or unit test) which illustrates this situation?

Peter Lawrey

unread,
Nov 26, 2015, 1:12:44 PM11/26/15
to java-ch...@googlegroups.com

The closest is the GWMain/PEMain demo. This doesn't have replication configured but that would not require a code change.

Peter.

Dmitry Shilovich

unread,
Nov 27, 2015, 7:22:02 AM11/27/15
to Chronicle
Thank you very much. I have additional question about RequireAck property of remote appender. 
Chronicle chronicle = ChronicleQueueBuilder
    .remoteAppender()
    .connectAddress("localhost", 1234)
    .appendRequireAck(true)
    .build();
As far as I can see it blocks until ack received and there is no any timeout, right? 
There is selectTimeout property in Chronicle conf but looks like it used for something else.

Luca Burgazzoli

unread,
Nov 27, 2015, 11:05:15 AM11/27/15
to java-ch...@googlegroups.com
Yes correct, appendRequireAck blocks till ack or timeout message are received.
Reply all
Reply to author
Forward
0 new messages