Package org.apache.activemq.command

Examples of org.apache.activemq.command.ActiveMQTextMessage


        info.setClientId(info.getConnectionId().getValue());
        return info;
    }

    protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
        ActiveMQTextMessage message = new ActiveMQTextMessage();
        message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
        message.setDestination(destination);
        message.setPersistent(false);
        try {
            message.setText("Test Message Payload.");
        } catch (MessageNotWriteableException e) {
        }
        return message;
    }
View Full Code Here


        assertEquals("store count is correct", count - removeIndex,
                queueMessageStore.getMessageCount());
    }

    private Message getMessage(int i) throws Exception {
        ActiveMQTextMessage message = new ActiveMQTextMessage();
        message.setMessageId(new MessageId(mesageIdRoot + i));
        message.setDestination(destination);
        message.setPersistent(true);
        message.setResponseRequired(true);
        message.setText("Msg:" + i + " " + text);
        assertEquals(message.getMessageId().getProducerSequenceId(), i);
        return message;
    }
View Full Code Here

               String point = "activemq:"
                 + ((ActiveMQDestination)destination).getPhysicalName().replace("//", "")
                 + "?requestTimeout=" + requestTimeout;
               try {
                 String body = (String)client.getProducerTemplate().requestBody(point, text);
                   ActiveMQTextMessage answer = new ActiveMQTextMessage();
                   answer.setText(body);
                 writeMessageResponse(response.getWriter(), answer);
               } catch (Exception e) {
                 IOException ex = new IOException();
                 ex.initCause(e);
                 throw ex;
View Full Code Here

        answer.setFrom(from);
        answer.setTo(to);

        // answer.setType(message.getType());
        if (message instanceof ActiveMQTextMessage) {
            ActiveMQTextMessage activeMQTextMessage = (ActiveMQTextMessage)message;
            Body body = new Body();
            String text = activeMQTextMessage.getText();
            LOG.info("Setting the body text to be: " + text);
            body.setValue(text);
            answer.getAny().add(body);
        } else {
            // TODO support other message types
View Full Code Here

        }
        return new ActiveMQTopic(name);
    }

    protected ActiveMQMessage createActiveMQMessage(Message message) throws JMSException {
        ActiveMQTextMessage answer = new ActiveMQTextMessage();
        String text = "";
        List<Object> list = message.getSubjectOrBodyOrThread();
        for (Object object : list) {
            if (object instanceof Body) {
                Body body = (Body)object;
                text = body.getValue();
                break;
            }
        }
        answer.setText(text);
        return answer;
    }
View Full Code Here

        underTest.start();
        assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

        final ConnectionContext contextNotInTx = new ConnectionContext();
        for (int i = 0; i < count; i++) {
            ActiveMQTextMessage msg = getMessage(i);
            msg.setMemoryUsage(systemUsage.getMemoryUsage());

            queueMessageStore.addMessage(contextNotInTx, msg);
            underTest.addMessageLast(msg);
        }
View Full Code Here

        underTest.release();
        assertEquals(count, dequeueCount);
    }

    private ActiveMQTextMessage getMessage(int i) throws Exception {
        ActiveMQTextMessage message = new ActiveMQTextMessage();
        MessageId id = new MessageId(mesageIdRoot + i);
        id.setBrokerSequenceId(i);
        id.setProducerSequenceId(i);
        message.setMessageId(id);
        message.setDestination(destination);
        message.setPersistent(true);
        message.setResponseRequired(true);
        message.setText("Msg:" + i + " " + text);
        assertEquals(message.getMessageId().getProducerSequenceId(), i);
        return message;
    }
View Full Code Here

                    if (consume) {
                        if (count != 0) {
                            MessageConsumer consumer = createSyncConsumer(broker, dest);
                            totalCount += count;
                            for (int i = 0; i < count; i++) {
                                ActiveMQTextMessage message = (ActiveMQTextMessage)consumer.receive(1000);
                                if (message == null) break;
                                LOG.info(broker + " consumer: " + message.getText() + " " + message.getDestination() " " + message.getMessageId() + " " + Arrays.toString(message.getBrokerPath()));
                            }
                        }
                    } else {
                        totalCount = count;
                    }
View Full Code Here

    protected int browseMessages(QueueBrowser browser, String name) throws Exception {
        Enumeration<?> msgs = browser.getEnumeration();
        int browsedMessage = 0;
        while (msgs.hasMoreElements()) {
            browsedMessage++;
            ActiveMQTextMessage message = (ActiveMQTextMessage)msgs.nextElement();
            LOG.info(name + " browsed: " + message.getText() + " " + message.getDestination() " " + message.getMessageId() + " " + Arrays.toString(message.getBrokerPath()));
        }
        return browsedMessage;
    }
View Full Code Here

        ConnectionFactory factory = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI());
        Connection connection = factory.createConnection();
        connection.start();
        MessageProducer producer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createProducer(activeMQQueue);
        for (int i=0; i<numMessages; i++) {
            producer.send(new ActiveMQTextMessage());
        }

        MessageConsumer consumer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(activeMQQueue);
        try {
            for (int i=0; i< numMessages * numDests; i++) {
View Full Code Here

TOP

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

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.