use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class LargeMessageTXFailureCallback method failedTransaction.
@Override
public void failedTransaction(final long transactionID, final List<RecordInfo> records, final List<RecordInfo> recordsToDelete) {
for (RecordInfo record : records) {
if (record.userRecordType == ADD_LARGE_MESSAGE) {
byte[] data = record.data;
ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(data);
try {
LargeServerMessage serverMessage = journalStorageManager.parseLargeMessage(messages, buff);
serverMessage.decrementDelayDeletionCount();
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.journalError(e);
}
}
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class CoreMessageTest method testChangeBodyString.
public void testChangeBodyString(String newString) {
CoreMessage coreMessage = decodeMessage();
coreMessage.putStringProperty("newProperty", "newValue");
ActiveMQBuffer legacyBuffer = coreMessage.getBodyBuffer();
legacyBuffer.resetWriterIndex();
legacyBuffer.clear();
TextMessageUtil.writeBodyText(legacyBuffer, SimpleString.toSimpleString(newString));
ByteBuf newbuffer = Unpooled.buffer(150000);
coreMessage.sendBuffer(newbuffer, 0);
newbuffer.readerIndex(0);
CoreMessage newCoreMessage = new CoreMessage();
newCoreMessage.receiveBuffer(newbuffer);
SimpleString newText = TextMessageUtil.readBodyText(newCoreMessage.getReadOnlyBodyBuffer());
Assert.assertEquals(newString, newText.toString());
// coreMessage.putStringProperty()
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class JDBCSequentialFile method write.
@Override
public void write(EncodingSupport bytes, boolean sync, IOCallback callback) throws Exception {
ActiveMQBuffer data = ActiveMQBuffers.fixedBuffer(bytes.getEncodeSize());
bytes.encode(data);
scheduleWrite(data, callback);
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class PagedMessageImpl method initMessage.
@Override
public void initMessage(StorageManager storage) {
if (largeMessageLazyData != null) {
LargeServerMessage lgMessage = storage.createLargeMessage();
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(largeMessageLazyData);
lgMessage = LargeMessagePersister.getInstance().decode(buffer, lgMessage);
lgMessage.incrementDelayDeletionCount();
lgMessage.setPaged();
this.message = lgMessage;
largeMessageLazyData = null;
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class PagingStoreFactoryDatabase method newFileFactory.
private synchronized SequentialFileFactory newFileFactory(final String directoryName, boolean writeToDirectory) throws Exception {
JDBCSequentialFile directoryList = (JDBCSequentialFile) pagingFactoryFileFactory.createSequentialFile(DIRECTORY_NAME);
directoryList.open();
SimpleString simpleString = SimpleString.toSimpleString(directoryName);
ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(simpleString.sizeof());
buffer.writeSimpleString(simpleString);
if (writeToDirectory)
directoryList.write(buffer, true);
directoryList.close();
final SQLProvider sqlProvider;
if (dbConf.getDataSource() != null) {
final SQLProvider.Factory sqlProviderFactory;
if (dbConf.getSqlProviderFactory() != null) {
sqlProviderFactory = dbConf.getSqlProviderFactory();
} else {
sqlProviderFactory = new PropertySQLProvider.Factory(dbConf.getDataSource());
}
sqlProvider = sqlProviderFactory.create(getTableNameForGUID(directoryName), SQLProvider.DatabaseStoreType.PAGE);
} else {
sqlProvider = JDBCUtils.getSQLProvider(dbConf.getJdbcDriverClassName(), getTableNameForGUID(directoryName), SQLProvider.DatabaseStoreType.PAGE);
}
final JDBCSequentialFileFactory fileFactory = new JDBCSequentialFileFactory(pagingFactoryFileFactory.getDbDriver().getConnection(), sqlProvider, executorFactory.getExecutor(), criticalErrorListener);
final int jdbcNetworkTimeout = dbConf.getJdbcNetworkTimeout();
if (jdbcNetworkTimeout >= 0) {
fileFactory.setNetworkTimeout(this.executorFactory.getExecutor(), jdbcNetworkTimeout);
}
return fileFactory;
}
Aggregations