Package org.apache.activemq.command

Examples of org.apache.activemq.command.ActiveMQTextMessage


        // publish a message
        Xid tid = createXid();
        resource.start(tid, XAResource.TMNOFLAGS);
        MessageProducer producer = session.createProducer(dest);
        ActiveMQTextMessage message  = new ActiveMQTextMessage();
        message.setText(getName());
        producer.send(message);

        connection.close();

        assertTransactionGoneFromBroker(tid);
View Full Code Here


    protected ActiveMQDestination createActiveMQDestination(String string) {
        return new ActiveMQQueue(string);
    }

    protected Message createMessage(String string) throws Exception {
        ActiveMQTextMessage message = (ActiveMQTextMessage)ActiveMQTextMessageTest.SINGLETON.createObject();
        message.setText(string);
        return message;
    }
View Full Code Here

        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

                }

                activeMessage = msg;
            } else if (message instanceof TextMessage) {
                TextMessage textMsg = (TextMessage)message;
                ActiveMQTextMessage msg = new ActiveMQTextMessage();
                msg.setConnection(connection);
                msg.setText(textMsg.getText());
                activeMessage = msg;
            } else {
                activeMessage = new ActiveMQMessage();
                activeMessage.setConnection(connection);
            }
View Full Code Here

        try {

            connection = cf.createConnection(userName,password);
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(dest);
            ActiveMQTextMessage msg = (ActiveMQTextMessage)session.createTextMessage(body);

            for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry)iter.next();
                msg.setObjectProperty((String)entry.getKey(), entry.getValue());
            }

            producer.setDeliveryMode(msg.getJMSDeliveryMode());
            producer.setPriority(msg.getPriority());
            long ttl = msg.getExpiration() - System.currentTimeMillis();
            producer.setTimeToLive(ttl > 0 ? ttl : 0);
            producer.send(msg);

            return msg.getJMSMessageID();

        } finally {
            connection.close();
        }
View Full Code Here

    }

    private static ActiveMQMessage createActiveMQMessage(Exchange exchange) throws JMSException {
        Object body = exchange.getIn().getBody();
        if (body instanceof String) {
            ActiveMQTextMessage answer = new ActiveMQTextMessage();
            answer.setText((String) body);
            return answer;
        } else if (body instanceof Serializable) {
            ActiveMQObjectMessage answer = new ActiveMQObjectMessage();
            answer.setObject((Serializable) body);
            return answer;
        } else {
            return new ActiveMQMessage();
        }
View Full Code Here

        assertSelector(message, "(trueProp OR falseProp) AND falseProp", false);

    }

    public void testXPathSelectors() throws Exception {
        ActiveMQTextMessage message = new ActiveMQTextMessage();

        message.setJMSType("xml");
        message.setText("<root><a key='first'/><b key='second'/></root>");

        assertSelector(message, "XPATH 'root/a'", true);
        assertSelector(message, "XPATH '//root/b'", true);
        assertSelector(message, "XPATH 'root/c'", false);
View Full Code Here

        assertEquals("getJMSPriority", 3, message.getJMSPriority());
        assertEquals("foo", "abc", message.getStringProperty("foo"));
        assertEquals("bar", "123", message.getStringProperty("bar"));

        assertEquals("JMSXGroupID", "abc", message.getStringProperty("JMSXGroupID"));
        ActiveMQTextMessage amqMessage = (ActiveMQTextMessage)message;
        assertEquals("GroupID", "abc", amqMessage.getGroupID());
    }
View Full Code Here

        assertEquals("getJMSPriority", 3, message.getJMSPriority());
        assertEquals("foo", "abc", message.getStringProperty("foo"));
        assertEquals("bar", "123", message.getStringProperty("bar"));

        assertEquals("JMSXGroupID", "abc", message.getStringProperty("JMSXGroupID"));
        ActiveMQTextMessage amqMessage = (ActiveMQTextMessage)message;
        assertEquals("GroupID", "abc", amqMessage.getGroupID());
    }
View Full Code Here

        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

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.