Package org.activemq.message

Examples of org.activemq.message.ActiveMQTextMessage


    /**
     * @throws Exception
     */
    public void testSendReceive() throws Exception {
        for (int i = 0;i < MESSAGE_COUNT;i++) {
            TextMessage textMessage = new ActiveMQTextMessage();
            textMessage.setText("MSG-NO:" + i);
            for (int x = 0;x < producers.length;x++) {
                producers[x].send(textMessage);
            }
        }
        synchronized (receivedMessageCount) {
View Full Code Here


        }
        return messages[i];
    }

    protected ActiveMQMessage createMessage(int i) throws JMSException {
        ActiveMQTextMessage answer = new ActiveMQTextMessage();
        answer.setJMSMessageID(idGenerator.generateId());
        answer.setJMSClientID(getClientID());
        answer.setJMSDestination(destination);
        answer.setText("message index: " + i);
        return answer;
    }
View Full Code Here

        container.addMessage(message);
        messageIdenties[i] = message.getJMSMessageIdentity();
    }

    protected void readMessage(int i) throws JMSException {
        ActiveMQTextMessage message = (ActiveMQTextMessage) container.getMessage(messageIdenties[i]);
        assertTrue("Message should not be null", message != null);

        String text = message.getText();
        assertEquals("Message text should be equal", messageTexts[i], text);
        assertEquals(messageIds[i], message.getJMSMessageID());
    }
View Full Code Here

        ActiveMQMessage message = container.getMessage(messageIdenties[i]);
        assertTrue("Message should be null", message == null);
    }

    protected ActiveMQMessage createMessage(int i) throws JMSException {
        ActiveMQTextMessage answer = new ActiveMQTextMessage();
        String text = "Message: " + i;
        messageTexts[i] = text;
        answer.setText(text);
        return answer;
    }
View Full Code Here

        }

        if (packet.getPacketType() == Packet.ACTIVEMQ_TEXT_MESSAGE)
        {
            assert(packet instanceof ActiveMQTextMessage);
            ActiveMQTextMessage msg = (ActiveMQTextMessage) packet;
            Subscription sub = (Subscription) subscriptions.get(msg.getJMSDestination());
            sub.receive(msg, out);
        }
        return null;
    }
View Full Code Here

    public PacketEnvelope build(String commandLine, DataInput in) throws IOException
    {
        Properties headers = parser.parse(in);
        String destination = headers.getProperty(Stomp.Headers.Send.DESTINATION);

        ActiveMQTextMessage text = new ActiveMQTextMessage();
        text.setJMSMessageID(StompWireFormat.PACKET_IDS.generateId());

        ActiveMQDestination d = DestinationNamer.convert(destination);
        text.setJMSDestination(d);
        text.setJMSClientID(format.getClientId());
        if (format.isInTransaction())
        {
            text.setTransactionIDString(format.getTransactionId());
        }

        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        byte b;
        while ((b = in.readByte()) != 0)
        {
            bytes.write(b);
        }
        bytes.close();
        String body = new String(bytes.toByteArray());
        try
        {
            text.setText(body);
        }
        catch (JMSException e)
        {
            throw new RuntimeException("Something is really wrong, we instantiated this thing!");
        }
View Full Code Here

        writer.println("  id='" + clientID + "'>");
        writer.flush();
   }

    protected Packet readMessage(XMLStreamReader reader) throws XMLStreamException, JMSException {
        ActiveMQTextMessage message = new ActiveMQTextMessage();
        message.setJMSMessageID(idGenerator.generateId());
        QName name = reader.getName();
        String to = getAttributeValue("to", reader);
        String type = getAttributeValue("type",reader);
              
        if (type != null){
            message.setJMSType(type);
        }
              
        if (to != null && to.length() > 0) {
            message.setJMSDestination(createDestination(type,to));
        }
       
        if (this.userName != null && this.userName .length() > 0) {
            message.setJMSReplyTo(createDestination("chat",this.userName));
        }

        while (reader.hasNext()) {
            switch (reader.nextTag()) {
                case XMLStreamConstants.START_ELEMENT:
View Full Code Here

*/
public class JabberWireFormatTest extends TestCase {
    protected JabberWireFormat format = new JabberWireFormat();

    public void testWrite() throws Exception {
        ActiveMQTextMessage message = new ActiveMQTextMessage();
        //message.setJMSType("id");
        message.setJMSReplyTo(new ActiveMQTopic("my.source"));
        message.setJMSDestination(new ActiveMQTopic("my.target"));
        message.setJMSCorrelationID("abc123");
        message.setText("hello there");

        StringWriter buffer = new StringWriter();
        PrintWriter out = new PrintWriter(buffer);
        format.setWriter(out);
        format.writePacket(message, null);
View Full Code Here

* @version $Revision: 1.1.1.1 $
*/
public class SelectorTest extends TestCase {

    public void testXPathSelectors() throws Exception {
        TextMessage 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

        writer.println("  id='" + clientID + "'>");
        writer.flush();
   }

    protected Packet readMessage(XMLStreamReader reader) throws XMLStreamException, JMSException {
        ActiveMQTextMessage message = new ActiveMQTextMessage();
        message.setJMSMessageID(idGenerator.generateId());
        QName name = reader.getName();
        String to = getAttributeValue("to", reader);
        String type = getAttributeValue("type",reader);
              
        if (type != null){
            message.setJMSType(type);
        }
              
        if (to != null && to.length() > 0) {
            message.setJMSDestination(createDestination(type,to));
        }
       
        if (this.userName != null && this.userName .length() > 0) {
            message.setJMSReplyTo(createDestination("chat",this.userName));
        }

        while (reader.hasNext()) {
            switch (reader.nextTag()) {
                case XMLStreamConstants.START_ELEMENT:
View Full Code Here

TOP

Related Classes of org.activemq.message.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.