Chronicle Queue : How to have declare a object that is to be persisted with one of the field as byte[]

60 views
Skip to first unread message

Lata

unread,
Jun 30, 2015, 7:40:45 AM6/30/15
to java-ch...@googlegroups.com
Hi,

I am using ChronicleQueue. I have to persist a object that has multiple fields and byte[] is one of the field in the object. The object that I have to persist is:

public interface Event extends Byteable {

boolean compareAndSwapOwner(int expected, int value);

int getOwner();

void setOwner(int meta);


void setId(long id);

long getId();


void setType(long id);

long getType();


void setTimestamp(long timestamp);

long getTimestamp();


byte[] getBytes();

 

void setBytes(@MaxSize(8) byte[] bytes);


}





When I run my test code to create the queue the above object, I am getting following error for byte[] field

Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgument
Exception: type must be an interface, was class [B



Want to know what is the right way to declare a byte[] field for persisting in queue


Thanks,

Lata

















 

 


Peter Lawrey

unread,
Jun 30, 2015, 1:40:30 PM6/30/15
to java-ch...@googlegroups.com
Hello Lata,

The generated data values don't support byte[] at the moment.  If you want to write this data I suggest you write it directly to the queue.

appender.startExcerpt();
appender.writeInt(owner);
appender.writeLong(id);
appender.writeLong(type);
appender.writeLong(timestamp);
appender.write(bytes);
appender.finish();

To read you do the same but with tailer.readXXX

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.

Reply all
Reply to author
Forward
0 new messages