Package org.activemq.util

Examples of org.activemq.util.Callback


    protected boolean topic = false;
    private String destinationName;
    protected TransactionTemplate transactionTemplate;

    public void testWriteLoop() throws Exception {
        transactionTemplate.run(new Callback() {
            public void execute() throws Throwable {
                writeMessage(0);

                // lets delete using a String which should cause a warning
                MessageIdentity messageIdentity = new MessageIdentity(messageIds[0]);
                container.delete(messageIdentity, createMessageAck(messageIdentity));
            }
        });

        System.out.println("About to write: " + messageCount + " messages to the container: " + container);

        transactionTemplate.run(new Callback() {
            public void execute() throws Throwable {
                for (int i = 0; i < messageCount; i++) {
                    writeMessage(i + 1);
                }
            }
        });


        System.out.println("About to read: " + messageCount + " messages");

        transactionTemplate.run(new Callback() {
            public void execute() throws Throwable {
                for (int i = 0; i < messageCount; i++) {
                    readMessage(i + 1);
                }
            }
        });

        System.out.println("About to delete: " + messageCount + " messages");

        transactionTemplate.run(new Callback() {
            public void execute() throws Throwable {
                for (int i = 0; i < messageCount; i++) {
                    deleteMessage(i + 1);
                }
            }
        });

        if (!topic) {
            System.out.println("About to check that all the messages are consumed");
            transactionTemplate.run(new Callback() {
                public void execute() throws Throwable {
                    for (int i = 0; i < messageCount; i++) {
                        assertNoMessage(i + 1);
                    }
                }
View Full Code Here


    protected abstract ActiveMQMessage[] getMessagesToDispatch() throws JMSException;


    protected void doAcknowledgeMessage(final int i) throws JMSException {
        template.run(new Callback() {
            public void execute() throws Throwable {
                acknowledgeMessage(i);
            }
        });
    }
View Full Code Here

        });
    }

    protected void doAddMessage(int i) throws JMSException {
        final ActiveMQMessage message = getMessage(i);
        template.run(new Callback() {
            public void execute() throws Throwable {
                container.addMessage(message);
            }
        });
    }
View Full Code Here

            return new DurableQueueMessageContainerManager(persistenceAapter, new DurableTopicSubscriptionContainerImpl(new RedeliveryPolicy(),new DeadLetterPolicy()), new FilterFactoryImpl(), new DispatcherImpl());
        }
    }

    protected void assertDeliveryList(final int startIndex, final int lastIndex) throws JMSException {
        template.run(new Callback() {
            public void execute() throws Throwable {
                ActiveMQMessage[] messagesToDispatch = getMessagesToDispatch();
                int count = lastIndex - startIndex;
                assertTrue("Not enough messages available to dispatch. Expected: " + count
                        + " messages but was: " + messagesToDispatch.length, messagesToDispatch.length >= count);
View Full Code Here

        container = messageContainerManager.getContainer(destination.getPhysicalName());

        this.subscription = createSubscription();

        template.run(new Callback() {
            public void execute() throws Throwable {
                recover();
            }
        });
    }
View Full Code Here

        ExceptionTemplate template = new ExceptionTemplate();

        if (containerManagers != null) {
            for (int i = 0; i < containerManagers.length; i++) {
                final MessageContainerManager containerManager = containerManagers[i];
                template.run(new Callback() {
                    public void execute() throws Throwable {
                        containerManager.stop();
                    }
                });
            }
        }
        if (transactionManager != null) {
            template.run(new Callback() {
                public void execute() throws Throwable {
                    transactionManager.stop();
                }
            });
        }

        template.run(new Callback() {
            public void execute() throws Throwable {
                persistenceAdapter.stop();
            }
        });
View Full Code Here

        if( log.isDebugEnabled() ) {
            log.debug("Checkpoint acknowledgments: "+cpAckedLastAckLocations);
        }
   
    transactionTemplate.run(new Callback() {
      public void execute() throws Throwable {
       
        // Checkpoint the acknowledged messages.
        Iterator iterator = cpAckedLastAckLocations.keySet().iterator();
        while (iterator.hasNext()) {         
View Full Code Here

        ExceptionTemplate template = new ExceptionTemplate();

        if (containerManagers != null) {
            for (int i = 0; i < containerManagers.length; i++) {
                final MessageContainerManager containerManager = containerManagers[i];
                template.run(new Callback() {
                    public void execute() throws Throwable {
                        containerManager.stop();
                    }
                });
            }
        }
        if (transactionManager != null) {
            template.run(new Callback() {
                public void execute() throws Throwable {
                    transactionManager.stop();
                }
            });
        }

        template.run(new Callback() {
            public void execute() throws Throwable {
                persistenceAdapter.stop();
            }
        });
View Full Code Here

        }
       
        final int messagesAdded[]=new int[]{0};
        final int messagesRemoved[]=new int[]{0};

        transactionTemplate.run(new Callback() {
            public void execute() throws Throwable {

                // Checkpoint the added messages.
                Iterator iterator = cpAddedMessageIds.keySet().iterator();
                while (iterator.hasNext()) {
View Full Code Here

    synchronized(this) {
        cpAckedLastAckLocations = this.ackedLastAckLocations;
        this.ackedLastAckLocations = new HashMap();
    }
   
    transactionTemplate.run(new Callback() {
      public void execute() throws Throwable {
       
        // Checkpoint the acked messages.
        Iterator iterator = cpAckedLastAckLocations.keySet().iterator();
        while (iterator.hasNext()) {         
View Full Code Here

TOP

Related Classes of org.activemq.util.Callback

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.