Package org.activemq.message

Examples of org.activemq.message.ActiveMQMessage


    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


                    synchronized (subscriptionsMutex) {
                        if (!subscriptions.isEmpty()) {
                            messagePointer = (DurableMessagePointer) queue
                                    .dequeue(sleepTime);
                            if (messagePointer != null) {
                                ActiveMQMessage message = messagePointer
                                        .getMessage();
                                if (!message.isExpired()) {

                                    QueueListEntry entry = subscriptions
                                            .getFirstEntry();
                                    while (entry != null) {
                                        DurableQueueSubscription ts = (DurableQueueSubscription) entry
                                                .getElement();
                                        if (ts.isTarget(message)) {
                                            targeted = true;
                                            if (message.isMessagePart()) {
                                                DurableQueueSubscription sameTarget = (DurableQueueSubscription) messageParts
                                                        .get(message
                                                                .getParentMessageID());
                                                if (sameTarget == null) {
                                                    sameTarget = ts;
                                                    messageParts
                                                            .put(
                                                                    message
                                                                            .getParentMessageID(),
                                                                    sameTarget);
                                                }
                                                sameTarget
                                                        .doDispatch(messagePointer);
                                                if (message.isLastMessagePart()) {
                                                    messageParts
                                                            .remove(message
                                                                    .getParentMessageID());
                                                }
                                                messagePointer = null;
                                                dispatched = true;
                                                notDispatchedCount = 0;
View Full Code Here

    protected void removeExpiredMessages() {
        long currentTime = System.currentTimeMillis();
        List list = queue.getContents();
        for (int i = 0;i < list.size();i++) {
            DurableMessagePointer msgPointer = (DurableMessagePointer) list.get(i);
            ActiveMQMessage message = msgPointer.getMessage();
            if (message.isExpired(currentTime)) {
                // TODO: remove message from message store.
                queue.remove(msgPointer);
                if (log.isDebugEnabled()) {
                    log.debug("expired message: " + msgPointer);
                }
View Full Code Here

    /**
     * Dispatch an Advisory Message
     * @param messagePointer
     */
    private synchronized void doAdvisoryDispatchMessage(DurableMessagePointer messagePointer) {
        ActiveMQMessage message = messagePointer.getMessage();
        try {

            if (message.isAdvisory() && !message.isExpired()) {
                synchronized (subscriptionsMutex) {
                    QueueListEntry entry = subscriptions.getFirstEntry();
                    while (entry != null) {
                        DurableQueueSubscription ts = (DurableQueueSubscription) entry
                                .getElement();
View Full Code Here

    /**
     * do some dispatching
     */
    public void run() {
        int count = 0;
        ActiveMQMessage message = null;
        while (started.get()) {
            try {
                message = (ActiveMQMessage) queue.dequeue(2000);
                if (message != null) {
                    if (!message.isExpired()) {
                        client.dispatch(message);
                        if (++count == 250) {
                            count = 0;
                            Thread.yield();
                        }
View Full Code Here

        return res;
    }

    public void onMessage(Message message) {
        try {
            ActiveMQMessage amsg = (ActiveMQMessage) message;
            TextMessage textMessage = (TextMessage) message;

            StringBuffer sb = new StringBuffer();
            sb.append(textMessage.getText());
            sb.append("#");
            sb.append(amsg.getConsumerIdentifer());

            addToMap(sb.toString());

        } catch (JMSException e) {
            log.error("Unable to force deserialize the content", e);
View Full Code Here

     *
     * @throws JMSException
     */
    public ActiveMQMessage receive(long timeout) throws JMSException {
        try {
            ActiveMQMessage message = (ActiveMQMessage) messageQueue.dequeue(timeout);
            return message;
        } catch (InterruptedException ioe) {
            return null;
        }
    }
View Full Code Here

     *
     * @param message - message received by the listener.
     */
    public void onMessage(Message message) {
        try {
            ActiveMQMessage amsg = (ActiveMQMessage) message;
            TextMessage textMessage = (TextMessage) message;

            StringBuffer sb = new StringBuffer();
            sb.append(textMessage.getText());
            sb.append("#");
            sb.append(amsg.getConsumerIdentifer());

            msgCounter++;
            String strMsgCounter = String.valueOf(msgCounter);
            ProducerMap.put(strMsgCounter, sb.toString());

View Full Code Here

        synchronized (messageListenerGuard) {
            this.messageListener = listener;
            if (listener != null) {
                session.setSessionConsumerDispatchState(ActiveMQSession.CONSUMER_DISPATCH_ASYNC);
                //messages may already be enqueued
                ActiveMQMessage msg = null;
                try {
                    while ((msg = (ActiveMQMessage)messageQueue.dequeueNoWait()) != null) {
                        processMessage(msg);
                    }
                }
View Full Code Here

    public Message receive() throws JMSException {
        checkClosed();
        session.setSessionConsumerDispatchState(ActiveMQSession.CONSUMER_DISPATCH_SYNC);
        try {
            this.accessThread = Thread.currentThread();
            ActiveMQMessage message = (ActiveMQMessage) messageQueue.dequeue();
            this.accessThread = null;
            if (message != null) {
                boolean expired = message.isExpired();
                messageDelivered(message, true, expired);
                if (!expired) {
                    message = message.shallowCopy();
                }
                else {
                    message = (ActiveMQMessage) receiveNoWait(); //this will remove any other expired messages held in the queue
                }
            }
View Full Code Here

TOP

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