Search in sources :

Example 1 with CoreMessage

use of org.apache.activemq.artemis.core.message.impl.CoreMessage in project activemq-artemis by apache.

the class PostOfficeImpl method createQueueInfoMessage.

private Message createQueueInfoMessage(final NotificationType type, final SimpleString queueName) {
    Message message = new CoreMessage().initBuffer(50).setMessageID(storageManager.generateID());
    message.setAddress(queueName);
    String uid = UUIDGenerator.getInstance().generateStringUUID();
    message.putStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE, new SimpleString(type.toString()));
    message.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, System.currentTimeMillis());
    message.putStringProperty(new SimpleString("foobar"), new SimpleString(uid));
    return message;
}
Also used : LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) Message(org.apache.activemq.artemis.api.core.Message) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage)

Example 2 with CoreMessage

use of org.apache.activemq.artemis.core.message.impl.CoreMessage in project activemq-artemis by apache.

the class ServerPacketDecoder method decodeSessionSendMessage.

private SessionSendMessage decodeSessionSendMessage(final ActiveMQBuffer in, CoreRemotingConnection connection) {
    final SessionSendMessage sendMessage;
    if (connection.isVersionBeforeAddressChange()) {
        sendMessage = new SessionSendMessage_1X(new CoreMessage(this.coreMessageObjectPools));
    } else {
        sendMessage = new SessionSendMessage(new CoreMessage(this.coreMessageObjectPools));
    }
    sendMessage.decode(in);
    return sendMessage;
}
Also used : SessionSendMessage_1X(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage_1X) SessionSendMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage)

Example 3 with CoreMessage

use of org.apache.activemq.artemis.core.message.impl.CoreMessage in project activemq-artemis by apache.

the class ServerPacketDecoder method slowPathDecode.

// separating for performance reasons
private Packet slowPathDecode(ActiveMQBuffer in, byte packetType, CoreRemotingConnection connection) {
    Packet packet;
    switch(packetType) {
        case SESS_SEND_LARGE:
            {
                packet = new SessionSendLargeMessage(new CoreMessage());
                break;
            }
        case REPLICATION_APPEND:
            {
                packet = new ReplicationAddMessage();
                break;
            }
        case REPLICATION_APPEND_TX:
            {
                packet = new ReplicationAddTXMessage();
                break;
            }
        case REPLICATION_DELETE:
            {
                packet = new ReplicationDeleteMessage();
                break;
            }
        case REPLICATION_DELETE_TX:
            {
                packet = new ReplicationDeleteTXMessage();
                break;
            }
        case REPLICATION_PREPARE:
            {
                packet = new ReplicationPrepareMessage();
                break;
            }
        case REPLICATION_COMMIT_ROLLBACK:
            {
                packet = new ReplicationCommitMessage();
                break;
            }
        case REPLICATION_RESPONSE:
            {
                packet = new ReplicationResponseMessage();
                break;
            }
        case REPLICATION_RESPONSE_V2:
            {
                packet = new ReplicationResponseMessageV2();
                break;
            }
        case REPLICATION_PAGE_WRITE:
            {
                packet = new ReplicationPageWriteMessage();
                break;
            }
        case REPLICATION_PAGE_EVENT:
            {
                packet = new ReplicationPageEventMessage();
                break;
            }
        case REPLICATION_LARGE_MESSAGE_BEGIN:
            {
                packet = new ReplicationLargeMessageBeginMessage();
                break;
            }
        case REPLICATION_LARGE_MESSAGE_END:
            {
                packet = new ReplicationLargeMessageEndMessage();
                break;
            }
        case REPLICATION_LARGE_MESSAGE_WRITE:
            {
                packet = new ReplicationLargeMessageWriteMessage();
                break;
            }
        case PacketImpl.BACKUP_REGISTRATION:
            {
                packet = new BackupRegistrationMessage();
                break;
            }
        case PacketImpl.BACKUP_REGISTRATION_FAILED:
            {
                packet = new BackupReplicationStartFailedMessage();
                break;
            }
        case PacketImpl.REPLICATION_START_FINISH_SYNC:
            {
                packet = new ReplicationStartSyncMessage();
                break;
            }
        case PacketImpl.REPLICATION_SYNC_FILE:
            {
                packet = new ReplicationSyncFileMessage();
                break;
            }
        case PacketImpl.REPLICATION_SCHEDULED_FAILOVER:
            {
                packet = new ReplicationLiveIsStoppingMessage();
                break;
            }
        case CLUSTER_CONNECT:
            {
                packet = new ClusterConnectMessage();
                break;
            }
        case CLUSTER_CONNECT_REPLY:
            {
                packet = new ClusterConnectReplyMessage();
                break;
            }
        case NODE_ANNOUNCE:
            {
                packet = new NodeAnnounceMessage();
                break;
            }
        case BACKUP_REQUEST:
            {
                packet = new BackupRequestMessage();
                break;
            }
        case BACKUP_REQUEST_RESPONSE:
            {
                packet = new BackupResponseMessage();
                break;
            }
        case QUORUM_VOTE:
            {
                packet = new QuorumVoteMessage();
                break;
            }
        case QUORUM_VOTE_REPLY:
            {
                packet = new QuorumVoteReplyMessage();
                break;
            }
        case SCALEDOWN_ANNOUNCEMENT:
            {
                packet = new ScaleDownAnnounceMessage();
                break;
            }
        default:
            {
                packet = super.decode(packetType, connection);
            }
    }
    packet.decode(in);
    return packet;
}
Also used : QuorumVoteMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.QuorumVoteMessage) ReplicationAddTXMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage) ReplicationLargeMessageWriteMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageWriteMessage) ReplicationLargeMessageBeginMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageBeginMessage) BackupRequestMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRequestMessage) ReplicationCommitMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage) ReplicationPageWriteMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageWriteMessage) ReplicationLargeMessageEndMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageEndMessage) ReplicationAddMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddMessage) BackupResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupResponseMessage) ReplicationLiveIsStoppingMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage) SessionSendLargeMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendLargeMessage) BackupRegistrationMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage) Packet(org.apache.activemq.artemis.core.protocol.core.Packet) ClusterConnectReplyMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterConnectReplyMessage) BackupReplicationStartFailedMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage) ReplicationDeleteMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteMessage) ScaleDownAnnounceMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ScaleDownAnnounceMessage) QuorumVoteReplyMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.QuorumVoteReplyMessage) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ReplicationPageEventMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageEventMessage) NodeAnnounceMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NodeAnnounceMessage) ReplicationSyncFileMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationSyncFileMessage) ClusterConnectMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterConnectMessage) ReplicationPrepareMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPrepareMessage) ReplicationDeleteTXMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteTXMessage) ReplicationStartSyncMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationStartSyncMessage) ReplicationResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessage) ReplicationResponseMessageV2(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessageV2)

Example 4 with CoreMessage

use of org.apache.activemq.artemis.core.message.impl.CoreMessage 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 5 with CoreMessage

use of org.apache.activemq.artemis.core.message.impl.CoreMessage in project activemq-artemis by apache.

the class CoreMessageTest method internalDecode.

private CoreMessage internalDecode(ByteBuf bufferOrigin) {
    CoreMessage coreMessage = new CoreMessage();
    // System.out.println("Bytes from test " + ByteUtil.bytesToHex(bufferOrigin.array(), 1));
    coreMessage.receiveBuffer(bufferOrigin);
    return coreMessage;
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage)

Aggregations

CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)48 Test (org.junit.Test)20 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)17 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)16 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)11 Message (org.apache.activemq.artemis.api.core.Message)11 Configuration (org.apache.activemq.artemis.core.config.Configuration)6 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)6 ByteBuf (io.netty.buffer.ByteBuf)5 LinkedList (java.util.LinkedList)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)3 PagingStoreImpl (org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl)3 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)3 RoutingContext (org.apache.activemq.artemis.core.server.RoutingContext)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 MBeanRegistrationException (javax.management.MBeanRegistrationException)2 PageCursorProvider (org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider)2 PageSubscription (org.apache.activemq.artemis.core.paging.cursor.PageSubscription)2