
com.github.ddth.queue.impl.BaseUniversalRocksDbQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ddth-queue-core Show documentation
Show all versions of ddth-queue-core Show documentation
DDTH's Libary to interact with various queue implementations
package com.github.ddth.queue.impl;
import com.github.ddth.queue.IQueueMessage;
import com.github.ddth.queue.utils.QueueException;
/**
* Base class for universal RocksDB queue implementations.
*
* @author Thanh Nguyen
*
* @param
* @since 0.4.0
*/
public abstract class BaseUniversalRocksDbQueue
extends RocksDbQueue {
/**
* {@inheritDoc}
*/
@Override
protected byte[] serialize(IQueueMessage _msg) throws QueueException {
if (_msg == null) {
return null;
}
if (!(_msg instanceof BaseUniversalQueueMessage)) {
throw new IllegalArgumentException("This method requires an argument of type ["
+ BaseUniversalQueueMessage.class.getName() + "]!");
}
BaseUniversalQueueMessage msg = (BaseUniversalQueueMessage) _msg;
try {
return msg.toBytes();
} catch (Exception e) {
throw new QueueException.CannotSerializeQueueMessage(e);
}
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public T take() {
return (T) super.take();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy