Package net.timewalker.ffmq3.storage.message

Examples of net.timewalker.ffmq3.storage.message.MessageStore


   */
  public void checkPermission(String resourceName, String action) throws JMSException
  {
    for (int i = 0; i < privileges.size(); i++)
    {
      Privilege privilege = (Privilege)privileges.get(i);
      if (privilege.matches(resourceName, action))
        return;
    }
    throw new FFMQException("Access denied to resource '"+resourceName+"' for action '"+action+"'","ACCESS_DENIED");
  }
View Full Code Here


            currentUser.setName(getRequired(attributes, "name"));
            currentUser.setPassword(getRequired(attributes, "password"));
        }
        if (currentPath.equals("security/users/user/privilege"))
        {
            currentPrivilege = new Privilege();
            currentPrivilege.setResourcePattern(getRequired(attributes, "resource"));
            currentPrivilege.setActions(getRequired(attributes, "actions"));
        }
    }
View Full Code Here

      fail("Not ordered !");
  }
 
  public void testPriorityBasic() throws Exception
  {
    MessageStore msgStore = createMessageStore();
   
    Random rand = new Random(System.currentTimeMillis());
   
    long start = System.currentTimeMillis();
    int msgCount = 178;
    for (int i = 0; i < msgCount; i++)
    {
      AbstractMessage msg = new TextMessageImpl("msg"+i);
      msg.setJMSMessageID("ID:FOO"+i);
      msg.setJMSPriority(rand.nextInt(10));
      assertTrue(msgStore.store(msg) != -1);
      //msgStore.commitChanges();
    }
    msgStore.commitChanges();
    long end = System.currentTimeMillis();
    System.out.println("testPriorityBasic: "+(end-start));
    assertEquals(msgCount, msgStore.size());
   
    assertOrdered(msgStore);
   
    // Delete half the queue
    int count = 0;
    int current = msgStore.first();
    while (current != -1 && count < (msgCount/2))
    {
      int next = msgStore.next(current);
      msgStore.delete(current);
      count++;
      current = next;
    }
    msgStore.commitChanges();
    assertEquals(msgCount/2, msgStore.size());
   
    assertOrdered(msgStore);
   
    //System.out.println(msgStore.toString());
   
    for (int i = 0; i < msgCount/2; i++)
    {
      AbstractMessage msg = new TextMessageImpl("other_msg"+i);
      msg.setJMSMessageID("ID:BAR"+i);
      msg.setJMSPriority(rand.nextInt(10));
      assertTrue(msgStore.store(msg) != -1);
    }
    msgStore.commitChanges();
    assertEquals(msgCount, msgStore.size());
   
    System.out.println(msgStore);
    assertOrdered(msgStore);
   
    msgStore.close();
  }
View Full Code Here

    msgStore.close();
  }
 
  public void testPriorityInterlaced() throws Exception
  {
    MessageStore msgStore = createMessageStore();

    for (int i = 0; i < 10; i++)
    {   
      AbstractMessage msg = new TextMessageImpl("msg"+i);
      msg.setJMSMessageID("ID:FOO"+i);
      msg.setJMSPriority(i);
      msg.setJMSCorrelationID("ID"+i);
      msgStore.store(msg);
      msgStore.commitChanges();
    }
    assertEquals(10, msgStore.size());
   
    assertOrdered(msgStore);
   
    int current = msgStore.first();
    for(int n=0;n<5;n++)
      current = msgStore.next(current);
    Message removedMsg = msgStore.retrieve(current);
    msgStore.delete(current);
    msgStore.commitChanges();
   
    assertOrdered(msgStore);
   
    AbstractMessage msg = new TextMessageImpl("msgNEW");
    msg.setJMSMessageID("ID:XXX");
    msg.setJMSPriority(removedMsg.getJMSPriority()+1);
    msgStore.store(msg);
    msgStore.commitChanges();
   
    msg = new TextMessageImpl("msgNEW2");
    msg.setJMSMessageID("ID:YYY");
    msg.setJMSPriority(removedMsg.getJMSPriority());
    msgStore.store(msg);
    msgStore.commitChanges();
   
    //System.out.println(msgStore);
   
    assertOrdered(msgStore);
    msgStore.close();
  }
View Full Code Here

      Settings settings = new Settings();
        settings.setStringProperty("name", getClass().getName());
        settings.setIntProperty("memoryStore.maxMessages", 10000);
        QueueDefinition queueDef = new QueueDefinition(settings);
     
        MessageStore store = new InMemoryMessageStore(queueDef);
        store.init();
       
        return store;
  }
View Full Code Here

        settings.setStringProperty("name", id);
        settings.setStringProperty("persistentStore.dataFolder", new File("target/test").getAbsolutePath());
        settings.setBooleanProperty("persistentStore.useJournal", false);
        QueueDefinition queueDef = new QueueDefinition(settings);
   
        MessageStore store = new BlockFileMessageStore(queueDef,asyncTaskManager);
        store.init();
       
        return store;
  }
View Full Code Here

        settings.setStringProperty("name", id);
        settings.setStringProperty("persistentStore.dataFolder", new File("target/test").getAbsolutePath());
        settings.setBooleanProperty("persistentStore.useJournal", true);
        QueueDefinition queueDef = new QueueDefinition(settings);
       
        MessageStore store = new BlockFileMessageStore(queueDef,asyncTaskManager);
        store.init();
     
      return store;
  }
View Full Code Here

      // Consistency check
      if (!message.isInternalCopy())
        throw new FFMQException("Message instance is not an FFMQ internal copy !","CONSISTENCY_ERROR");
     
      // Dispatch message to the adequate store
      MessageStore targetStore;
      if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT)
      {
          // Use volatile store if possible, otherwise fallback to persistent store
          targetStore = volatileStore != null ? volatileStore : persistentStore;
      }
      else
          targetStore = persistentStore;
         
      if (targetStore == null)
          throw new FFMQException("Queue does not support this delivery mode : "+
                                  (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT ?
                                  "DeliveryMode.NON_PERSISTENT" : "DeliveryMode.PERSISTENT"),
                                  "INVALID_DELIVERY_MODE");
     
      int newHandle;
        synchronized (storeLock)
        {
            newHandle = targetStore.store(message);
            if (newHandle == -1)
            {
              // No space left for this message in the target store
              if (targetStore == volatileStore && persistentStore != null)
              {
                // Fallback to persistent store if possible
                targetStore = persistentStore;
                newHandle = targetStore.store(message);
              }
              // Cannot store the message anywhere
              if (newHandle == -1)
                throw new DataStoreFullException("Cannot store message : queue is full : "+getName());
            }
           
            if (locks != null)
          {
              targetStore.lock(newHandle);
              locks.add(newHandle, targetStore.getDeliveryMode(), this);
          }
        }
        sentToQueueCount++;
       
        // Wake up waiting consumers
View Full Code Here

     * Unlock a message.
     * Listeners are automatically notified of the new message availability.
     */
    public void unlockAndDeliver( MessageLock lockRef ) throws JMSException
    {
      MessageStore targetStore;
      if (lockRef.getDeliveryMode() == DeliveryMode.NON_PERSISTENT)
          targetStore = volatileStore;
      else
          targetStore = persistentStore;
     
      AbstractMessage message;
      synchronized (storeLock)
        {
        int handle = lockRef.getHandle();
        message = targetStore.retrieve(handle);
        targetStore.unlock(handle);
        }
     
      messageAvailable(message);
    }
View Full Code Here

    /**
     * Remove a locked message from the queue
     */
    public void removeLocked( MessageLock lockRef ) throws JMSException
    {
      MessageStore targetStore;
      if (lockRef.getDeliveryMode() == DeliveryMode.NON_PERSISTENT)
          targetStore = volatileStore;
      else
          targetStore = persistentStore;
     
      synchronized (storeLock)
        {
        targetStore.delete(lockRef.getHandle());
        }
    }
View Full Code Here

TOP

Related Classes of net.timewalker.ffmq3.storage.message.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.