Package org.apache.activemq.command

Examples of org.apache.activemq.command.ActiveMQMessage


        conn.start();
        Destination dest = sess.createQueue("test");

        brokerMbean.addQueue("test");

        ActiveMQMessage msg = (ActiveMQMessage)consumer.receive(1000);
        assertNotNull(msg);
        assertTrue(msg.getDataStructure() instanceof DestinationInfo);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getDestination(), dest);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 0);

        brokerMbean.removeQueue("test");

        msg = (ActiveMQMessage)consumer.receive(1000);
        assertNotNull(msg);
        assertTrue(msg.getDataStructure() instanceof DestinationInfo);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getDestination(), dest);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 1);


        brokerMbean.addQueue("test");
        msg = (ActiveMQMessage)consumer.receive(1000);
        assertNotNull(msg);
        assertTrue(msg.getDataStructure() instanceof DestinationInfo);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getDestination(), dest);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 0);
        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 0);
    }
View Full Code Here


    public void close() throws IOException {
        if (!closed) {
            flushBuffer();
            try {
                // Send an EOS style empty message to signal EOS.
                send(new ActiveMQMessage(), true);
                dispose();
                this.connection.asyncSendPacket(info.createRemoveCommand());
            } catch (JMSException e) {
                IOExceptionSupport.create(e);
            }
View Full Code Here

       
        Thread.sleep(1000);

        createBroker2();
       
        ActiveMQMessage advisory = (ActiveMQMessage)consumer.receive(2000);
        assertNotNull(advisory);
        assertTrue(advisory.getDataStructure() instanceof BrokerInfo);
        assertTrue(advisory.getBooleanProperty("started"));
        assertCreatedByDuplex(advisory.getBooleanProperty("createdByDuplex"));
       
        broker2.stop();
        broker2.waitUntilStopped();

        advisory = (ActiveMQMessage)consumer.receive(2000);
        assertNotNull(advisory);
        assertTrue(advisory.getDataStructure() instanceof BrokerInfo);
        assertFalse(advisory.getBooleanProperty("started"));
    }
View Full Code Here

     * @return an ActiveMQMessage
     * @throws JMSException if the JMS provider fails to create this message due
     *                 to some internal error.
     */
    public Message createMessage() throws JMSException {
        ActiveMQMessage message = new ActiveMQMessage();
        configureMessage(message);
        return message;
    }
View Full Code Here

     */
    public void run() {
        MessageDispatch messageDispatch;
        while ((messageDispatch = executor.dequeueNoWait()) != null) {
            final MessageDispatch md = messageDispatch;
            ActiveMQMessage message = (ActiveMQMessage)md.getMessage();
            if (message.isExpired() || connection.isDuplicate(ActiveMQSession.this, message)) {
                // TODO: Ack it without delivery to client
                continue;
            }

            if (isClientAcknowledge()||isIndividualAcknowledge()) {
                message.setAcknowledgeCallback(new Callback() {
                    public void execute() throws Exception {
                    }
                });
            }

View Full Code Here

            message.setJMSExpiration(expiration);
            message.setJMSPriority(priority);
            message.setJMSRedelivered(false);

            // transform to our own message format here
            ActiveMQMessage msg = ActiveMQMessageTransformation.transformMessage(message, connection);

            // Set the message id.
            if (msg == message) {
                msg.setMessageId(new MessageId(producer.getProducerInfo().getProducerId(), sequenceNumber));
            } else {
                msg.setMessageId(new MessageId(producer.getProducerInfo().getProducerId(), sequenceNumber));
                message.setJMSMessageID(msg.getMessageId().toString());
            }
            //clear the brokerPath in case we are re-sending this message
            msg.setBrokerPath(null);
            // destination format is provider specific so only set on transformed message
            msg.setJMSDestination(destination);

            msg.setTransactionId(txid);
            if (connection.isCopyMessageOnSend()) {
                msg = (ActiveMQMessage)msg.copy();
            }
            msg.setConnection(connection);
            msg.onSend();
            msg.setProducerId(msg.getMessageId().getProducerId());
            if (LOG.isTraceEnabled()) {
                LOG.trace(getSessionId() + " sending message: " + msg);
            }
            if (sendTimeout <= 0 && !msg.isResponseRequired() && !connection.isAlwaysSyncSend() && (!msg.isPersistent() || connection.isUseAsyncSend() || txid != null)) {
                this.connection.asyncSendPacket(msg);
                if (producerWindow != null) {
                    // Since we defer lots of the marshaling till we hit the
                    // wire, this might not
                    // provide and accurate size. We may change over to doing
                    // more aggressive marshaling,
                    // to get more accurate sizes.. this is more important once
                    // users start using producer window
                    // flow control.
                    int size = msg.getSize();
                    producerWindow.increaseUsage(size);
                }
            } else {
                if (sendTimeout > 0) {
                    this.connection.syncSendPacket(msg,sendTimeout);
View Full Code Here

        if (eosReached || (buffer != null && buffer.length > pos)) {
            return;
        }
        try {
            while (true) {
                ActiveMQMessage m = receive();
                if (m != null && m.getDataStructureType() == CommandTypes.ACTIVEMQ_BYTES_MESSAGE) {
                    // First message.
                    long producerSequenceId = m.getMessageId().getProducerSequenceId();
                    if (producerId == null) {
                        // We have to start a stream at sequence id = 0
                        if (producerSequenceId != 0) {
                            continue;
                        }
                        nextSequenceId++;
                        producerId = m.getMessageId().getProducerId();
                    } else {
                        // Verify it's the next message of the sequence.
                        if (!m.getMessageId().getProducerId().equals(producerId)) {
                            throw new IOException("Received an unexpected message: invalid producer: " + m);
                        }
                        if (producerSequenceId != nextSequenceId++) {
                            throw new IOException("Received an unexpected message: expected ID: " + (nextSequenceId - 1) + " but was: " + producerSequenceId + " for message: " + m);
                        }
View Full Code Here

                    ConnectionError ce = (ConnectionError) command;
                    serviceRemoteException(ce.getException());
                } else {
                    if (isDuplex()) {
                        if (command.isMessage()) {
                            ActiveMQMessage message = (ActiveMQMessage) command;
                            if (AdvisorySupport.isConsumerAdvisoryTopic(message.getDestination())
                                || AdvisorySupport.isDestinationAdvisoryTopic(message.getDestination())) {
                                serviceRemoteConsumerAdvisory(message.getDataStructure());
                            } else {
                                if (!isPermissableDestination(message.getDestination(), true)) {
                                    return;
                                }
                                if (message.isResponseRequired()) {
                                    Response reply = new Response();
                                    reply.setCorrelationId(message.getCommandId());
                                    localBroker.oneway(message);
                                    remoteBroker.oneway(reply);
                                } else {
                                    localBroker.oneway(message);
                                }
View Full Code Here

        return compareComparators(getComparable(getDestination(message1)), getComparable(getDestination(message2)));
    }

    protected Destination getDestination(Message message) {
        if (message instanceof ActiveMQMessage) {
            ActiveMQMessage amqMessage = (ActiveMQMessage)message;
            return amqMessage.getDestination();
        }
        try {
            return message.getJMSDestination();
        } catch (JMSException e) {
            return null;
View Full Code Here

        assertNotNull(msg);

        msg = advisoryConsumer.receive(1000);
        assertNotNull(msg);

        ActiveMQMessage message = (ActiveMQMessage) msg;
        ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
        String originalId = payload.getJMSMessageID();
        assertEquals(originalId, id);
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.command.ActiveMQMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.