Package org.codehaus.activemq.util

Examples of org.codehaus.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


    }

    public void stop() {
        ExceptionTemplate template = new ExceptionTemplate();
        if (sendConnection != null) {
            template.run(new Callback() {
                public void execute() throws Throwable {
                    sendConnection.disconnect();
                }
            });
        }
        if (receiveConnection != null) {
            template.run(new Callback() {
                public void execute() throws Throwable {
                    receiveConnection.disconnect();
                }
            });
        }
View Full Code Here

TOP

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