Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.ActiveMQMessage


            TupleBrowser iter = getOrderedIndex().browse();
            while (iter.getNext(tuple)) {
                Long sequenceNumber = (Long) tuple.getKey();
                if (sequenceNumber.compareTo(lastAckedSequenceNumber) > 0) {
                    ActiveMQMessage message = null;

                    // TODO we could probably tune this some more since we have tuple.getValue() already
                    message = getMessageBySequenceNumber(sequenceNumber);
                    if (message != null) {
                        subscription.addMessage(getContainer(), message);
View Full Code Here


  }

  public void testReadPacket() throws Exception{
    ActiveMQMessageReader reader = new ActiveMQMessageReader();
    ActiveMQMessageWriter writer = new ActiveMQMessageWriter();
    ActiveMQMessage msg1 = new ActiveMQMessage();
    initializeMessage(msg1);
   
    byte[] data = writer.writePacketToByteArray(msg1);
    ActiveMQMessage msg2 = (ActiveMQMessage) reader.readPacketFromByteArray(data);
    testEquals(msg1, msg2);
         ActiveMQMessage msg3 = msg2.shallowCopy();
         testEquals(msg1,msg3);
         data = writer.writePacketToByteArray(msg3);
         ActiveMQMessage msg4 = (ActiveMQMessage) reader.readPacketFromByteArray(data);
         testEquals(msg1,msg4);
   

  }
View Full Code Here

        }
    }

    public synchronized ActiveMQMessage getMessage(MessageIdentity identity) throws JMSException {
        String messageID = identity.getMessageID();
        ActiveMQMessage message = null;
        try {
            MessageEntry entry = (MessageEntry) getMessageTable().find(messageID);
            if (entry != null) {
                message = entry.getMessage();
                message.getJMSMessageIdentity().setSequenceNumber(identity.getSequenceNumber());
            }
        }
        catch (IOException e) {
            throw JMSExceptionHelper.newJMSException("Failed to get message for messageID: " + messageID + " " + e, e);
        }
View Full Code Here

    /**
     * Looks up the message using the given sequence number
     */
    protected ActiveMQMessage getMessageBySequenceNumber(Long sequenceNumber) throws IOException, JMSException {
        ActiveMQMessage message = null;
        String messageID = (String) getOrderedIndex().find(sequenceNumber);
        if (messageID != null) {
            message = getMessage(new MessageIdentity(messageID, sequenceNumber));
        }
        return message;
View Full Code Here

    protected ConsumerInfo consumerInfo;


    public void testDispatch() throws Exception {
        // now lets dispatch a message
        ActiveMQMessage message = createMessage(getDestination());

        List messages = client.flushMessages();
        assertEquals("No messages received yet", 0, messages.size());

        // now lets send it
View Full Code Here

        sender.setClientID("sender");
        sender.start();

        packets = new ArrayList(TEST_SIZE);
        for (int i = 0; i < TEST_SIZE; i++) {
            Packet test = new ActiveMQMessage();
            test.setId("test:" + i);
            packets.add(test);
        }
    }
View Full Code Here

        return null;
    }


    protected void writeMessage(int i) throws JMSException {
        ActiveMQMessage message = createMessage(i);
        String id = idGenerator.generateId();
        messageIds[i] = id;
        message.setJMSMessageID(id);
        messageIdenties[i] = container.addMessage(message);
    }
View Full Code Here

    protected void deleteMessage(int i) throws JMSException {
        container.delete(messageIdenties[i], createMessageAck(messageIdenties[i]));
    }

    protected void assertNoMessage(int i) throws JMSException {
        ActiveMQMessage message = container.getMessage(messageIdenties[i]);
        assertTrue("Message should be null", message == null);
    }
View Full Code Here

     * @throws JMSException
     */
    public void redeliverMessage(BrokerClient client, MessageAck ack) throws JMSException {
        TransientQueueSubscription ts = (TransientQueueSubscription) subscriptions.get(ack.getConsumerId());
        if (ts != null) {
            ActiveMQMessage message = ts.acknowledgeMessage(ack.getMessageID());
            if (message != null){
                message.setJMSRedelivered(true);
                Set set = destinationMap.get(message.getJMSActiveMQDestination());
                for (Iterator i = set.iterator();i.hasNext();) {
                    TransientQueueBoundedMessageContainer container = (TransientQueueBoundedMessageContainer) i.next();
                    container.enqueueFirst(message);
                    break;
                }
View Full Code Here

                    packet.addBrokerVisited(remoteBrokerName); //got from the remote broker
                    packet.addBrokerVisited(brokerName);
                }
              
                if (packet.isJMSMessage()) {
                    ActiveMQMessage message = (ActiveMQMessage) packet;
                    // lets mark all messages from where they came from so that NoLocal can filter out loops
                    // e.g. when receiving messages over multicast, we don't want to publish them back out again
                    if (connectionInfo != null) {
                        message.setProducerID(connectionInfo.getClientId());
                    }
                    else {
                        log.warn("No connection info available! Maybe the client forgot to start() the Connection?");
                    }
                    if (!brokerConnection){
                        message.setEntryBrokerName(brokerName);
                        message.setEntryClusterName(clusterName);
                    }
                    consumeActiveMQMessage(message);
                }
                else {
                    switch (packet.getPacketType()) {
View Full Code Here

TOP

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