Package org.jboss.soa.esb.services.persistence

Examples of org.jboss.soa.esb.services.persistence.MessageStore


  }

    @Test
  public void testDBConnectionManager ()
  {
    MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
    assertEquals((store != null), true);
    ConnectionManager mgr=null;
    try {
      mgr = ConnectionManagerFactory.getConnectionManager();
    } catch (ConnectionManagerException e) {
View Full Code Here


     */
    @Test
    public void redeliverOneThread() throws Exception
    {
        log.info("** redeliverOneThreads");
        MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
        assertEquals((store != null), true);
        //first lets create an undeliverable message
        Service service = new Service("cat", "service");
        URI uid = createMessages(1, service, store);
        RedeliverClient redeliverClient = new RedeliverClient();
        Thread t1 = new Thread(redeliverClient, "CLIENT-1");
        t1.start();
       
        long deadline=System.currentTimeMillis() + 20000;
        boolean waiting=true;
        while(waiting) {
            if (redeliverClient.isDone()) {
                waiting=false;
            } else if (System.currentTimeMillis() > deadline){
                //We're timing out for some reason. This is bad.
                assertTrue(false);
            }
        }
        assertEquals(redeliverClient.getCount(),1);
        Message message = store.getMessage(uid)
        assertNull(message);
    }
View Full Code Here

    @Test
    public void redeliverTwoThreads() throws Exception
    {
        log.info("** redeliverTwoThreads");
        //first lets create an undeliverable message
        MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
        assertEquals((store != null), true);
        //first lets create an undeliverable message
        Service service = new Service("cat", "service");
        URI uid = createMessages(1, service, store);
        RedeliverClient client1 = new RedeliverClient();
        RedeliverClient client2 = new RedeliverClient();
        Thread t1 = new Thread(client1, "CLIENT-1");
        Thread t2 = new Thread(client2, "CLIENT-2");
        t1.start();
        t2.start();
       
        long deadline=System.currentTimeMillis() + 20000;
        boolean waiting=true;
        while(waiting) {
           
            if (client1.isDone() && client2.isDone()) {
                waiting=false;
            } else if (System.currentTimeMillis() > deadline){
                //We're timing out for some reason. This is bad.
                assertTrue(false);
            }
        }
        log.info("Client1 processed " + client1.getCount() + " messages");
        log.info("Client2 processed " + client2.getCount() + " messages");
        //only *one* message should be delivered
        assertEquals(1, client1.getCount() + client2.getCount());
        //the  message is delivered so should no longer be in the store
        Message message = store.getMessage(uid)
        assertNull(message);
    }
View Full Code Here

    public void redeliverFiftyTwoThreads() throws Exception
    {
        int numberOfMessages=50;
        log.info("** redeliverFiftyTwoThreads");
        //first lets create an undeliverable message
        MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
        assertEquals((store != null), true);
        //first lets create an undeliverable message
        Service service = new Service("cat", "service");
        URI uid = createMessages(numberOfMessages, service, store);
        RedeliverClient client1 = new RedeliverClient();
        RedeliverClient client2 = new RedeliverClient();
        Thread t1 = new Thread(client1, "CLIENT-1");
        Thread t2 = new Thread(client2, "CLIENT-2");
        t1.start();
        t2.start();
       
        final long deadline = System.currentTimeMillis() + 20000 ;
        waitForThread(t1, deadline) ;
        waitForThread(t2, deadline) ;
        if (!client1.isDone() || !client2.isDone()) {
            //We're timing out for some reason. This is bad.
            fail("Timeout waiting for client threads to terminate");
        }
        log.info("Client1 processed " + client1.getCount() + " messages");
        log.info("Client2 processed " + client2.getCount() + " messages");
        assertEquals(numberOfMessages, client1.getCount() + client2.getCount());
        //make sure the last message was send (and removed from the store)
        Message message = store.getMessage(uid)
        assertNull(message);
    }
View Full Code Here

     */
    public void processSuccess(final Message originalMessage)
    {
        //I can call the messagestore API directory if it is deployed in the same JVM
        String messageStoreClass = "org.jboss.internal.soa.esb.persistence.format.db.DBMessageStoreImpl";
        MessageStore messageStore = MessageStoreFactory.getInstance().getMessageStore(messageStoreClass);
        //Try to pull the message out
        try
        {
            Message message = messageStore.getMessage((URI) originalMessage.getProperties().getProperty(MessageStore.MESSAGE_URI));
            //Print out the content of the message
            System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
            System.out.println("Body (from the stored message): " + message.getBody().get()) ;
            System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
        }
View Full Code Here

    public Message process(Message message) throws ActionProcessingException
    {
        //The DeadLetterService is custom configurable Service. It is defined in
        //the jbossesb.esb an by default it stores the message in the
        //MessageStore under the DLQ categorization.
        MessageStore ms = MessageStoreFactory.getInstance().getMessageStore();
        Message rdlvrMessage = null;      
        message.getBody().add(ID, "ID:" + Integer.toHexString(System.identityHashCode(message))) ;
        message.getBody().add(DATE, new Date()) ;
        try {
            //empty out the DLQ
            Map<URI, Message> messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
            for (URI key : messageMap.keySet()) {
                ms.removeMessage(key, MessageStore.CLASSIFICATION_RDLVR);
            }
            Service noneExistingService = new Service("none-exising-category", "none-existing-service-name");
            ServiceInvoker si = new ServiceInvoker(noneExistingService);
            si.deliverAsync(message);
          
            //Adding this control code to show where the message now is.
            Map<URI, Message> rdlvrMessageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
            while (rdlvrMessageMap.size() == 0) { //we may have to wait for the DLQService to act.
                logger.info("...Waiting for the DLQ Service to act.");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ie) {
                    logger.error(ie);
                }
                rdlvrMessageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
            }
            for (URI key : rdlvrMessageMap.keySet()) {
                rdlvrMessage = rdlvrMessageMap.get(key);
                logger.info("*******************************");
                logger.info("Message in the RDLVR should be the same message: " + compare(message.getBody(), rdlvrMessage.getBody()));
                logger.info("Message=" + message.getBody());
                logger.info("rdlvrMessage=" + rdlvrMessage.getBody());
                logger.info("*******************************");
                logger.info("Removing message to avoid future redeliveries");
                ms.removeMessage(key, MessageStore.CLASSIFICATION_RDLVR);
            }
        } catch (MessageStoreException mse) {
            throw new ActionProcessingException(mse.getMessage(), mse);
        } catch (MessageDeliverException mde) {
            throw new ActionProcessingException(mde.getMessage(), mde);
View Full Code Here

    public Message process(Message message) throws ActionProcessingException
    {
        //The DeadLetterService is custom configurable Service. It is defined in
        //the jbossesb.esb an by default it stores the message in the
        //MessageStore under the DLQ categorization.
        MessageStore ms = MessageStoreFactory.getInstance().getMessageStore();
         Message dlqMessage = null;
         message.getBody().add(ID, "ID:" + Integer.toHexString(System.identityHashCode(message))) ;
        message.getBody().add(DATE, new Date()) ;
        try {
            //empty out the DLQ
            Map<URI, Message> messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_DLQ);
            for (URI key : messageMap.keySet()) {
                ms.removeMessage(key, MessageStore.CLASSIFICATION_DLQ);
            }
            Service noneExistingService = new Service("none-exising-category", "none-existing-service-name");
            ServiceInvoker si = new ServiceInvoker(noneExistingService);
            si.deliverSync(message, 1000);
        } catch (MessageStoreException mse) {
            throw new ActionProcessingException(mse.getMessage(), mse);
        } catch (MessageDeliverException mde) {
            //Adding this control code to show where the message now is.
            //We should get here on and we should have a message in the DLQ.
            try {
                Map<URI, Message> messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_DLQ);
                while (messageMap.size() == 0) { //we may have to wait for the DLQ Service to act.
                    logger.info("...Waiting for the DLQ Service to act.");
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ie) {
                        logger.error(ie);
                    }
                    messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_DLQ);
                }
                for (URI key : messageMap.keySet()) {
                    dlqMessage = messageMap.get(key);
                    logger.info("*******************************");
                    logger.info("Message in the DLQ queue should be the same message: " + compare(message.getBody(), dlqMessage.getBody()));
View Full Code Here

            persister.process(msg);
           
             //now we can check the messageStore to see if our message made it in there.
            System.out.println("Reading the messages in the messageStore");
           
            MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
            Map<URI, Message> messages = store.getAllMessages("TEST");
            messages = store.getAllMessages("TEST");
            Iterator<Message> iter=messages.values().iterator();
            while (iter.hasNext()) {
                Message message=iter.next();
                String bodyFromStore = new String((byte[]) message.getBody().get());
                System.out.println("Body=" + bodyFromStore);
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.services.persistence.MessageStore

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.