Search in sources :

Example 6 with ActiveMQBuffer

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);
            }
        }
    }
}
Also used : RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 7 with ActiveMQBuffer

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()
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ByteBuf(io.netty.buffer.ByteBuf) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 8 with ActiveMQBuffer

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);
}
Also used : ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 9 with ActiveMQBuffer

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;
    }
}
Also used : LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 10 with ActiveMQBuffer

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;
}
Also used : PropertySQLProvider(org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JDBCSequentialFile(org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile) SQLProvider(org.apache.activemq.artemis.jdbc.store.sql.SQLProvider) PropertySQLProvider(org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider) JDBCSequentialFileFactory(org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Aggregations

ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)150 Test (org.junit.Test)81 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)49 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)44 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)39 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)38 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)35 ByteBuffer (java.nio.ByteBuffer)34 Configuration (org.apache.activemq.artemis.core.config.Configuration)34 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)27 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)25 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)25 ArrayList (java.util.ArrayList)21 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)21 Queue (org.apache.activemq.artemis.core.server.Queue)18 HashMap (java.util.HashMap)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)15 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)15 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)14