Package org.codehaus.activemq.util

Examples of org.codehaus.activemq.util.Callback


        }
    }

    public synchronized void start() throws JMSException {
        final QueueMessageContainer container = this;
        transactionTemplate.run(new Callback() {
            public void execute() throws Throwable {
                messageStore.start();
                messageStore.recover(container);
            }
        });
View Full Code Here


        super.start();
    }

    public void stop() {
        ExceptionTemplate template = new ExceptionTemplate();
        template.run(new Callback() {
            public void execute() throws Throwable {
                discoveryAgent.stop();
            }
        });
        template.run(new Callback() {
            public void execute() throws Throwable {
                DiscoveryTransportChannel.super.stop();
            }
        });
        Throwable e = template.getFirstException();
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

    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 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

    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

      addedMessageIdentitys = new ArrayList(this.addedMessageLocations.keySet());
      removedMessageLocations = this.removedMessageLocations;
      this.removedMessageLocations = new ArrayList();
    }
   
    transactionTemplate.run(new Callback() {
      public void execute() throws Throwable {
       
        // Checkpoint the added messages.
        Iterator iterator = addedMessageIdentitys.iterator();
        while (iterator.hasNext()) {         
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.