Package org.jboss.messaging.core.contract

Examples of org.jboss.messaging.core.contract.MessageReference


      Channel channel = new SimpleChannel(0, ms);

      Message[] m = createMessages(10);

      MessageReference ref1 = ms.reference(m[0]);
      MessageReference ref2 = ms.reference(m[1]);
      MessageReference ref3 = ms.reference(m[2]);
      MessageReference ref4 = ms.reference(m[3]);
      MessageReference ref5 = ms.reference(m[4]);
      MessageReference ref6 = ms.reference(m[5]);
      MessageReference ref7 = ms.reference(m[6]);
      MessageReference ref8 = ms.reference(m[7]);
      MessageReference ref9 = ms.reference(m[8]);
      MessageReference ref10 = ms.reference(m[9]);

      pm.addReference(channel.getChannelID(), ref1, null);
      pm.addReference(channel.getChannelID(), ref2, null);
      pm.addReference(channel.getChannelID(), ref3, null);
      pm.addReference(channel.getChannelID(), ref4, null);
      pm.addReference(channel.getChannelID(), ref5, null);
      pm.addReference(channel.getChannelID(), ref6, null);
      pm.addReference(channel.getChannelID(), ref7, null);
      pm.addReference(channel.getChannelID(), ref8, null);
      pm.addReference(channel.getChannelID(), ref9, null);
      pm.addReference(channel.getChannelID(), ref10, null);

      List refIds = getReferenceIds(channel.getChannelID());
      assertNotNull(refIds);
      assertEquals(10, refIds.size());
      assertTrue(refIds.contains(new Long(ref1.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref2.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref3.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref4.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref5.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref6.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref7.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref8.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref9.getMessage().getMessageID())));
      assertTrue(refIds.contains(new Long(ref10.getMessage().getMessageID())));

      List msgs = getMessageIds();
      assertNotNull(msgs);
      assertEquals(10, msgs.size());
      assertTrue(msgs.contains(new Long(ref1.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref2.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref3.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref4.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref5.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref6.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref7.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref8.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref9.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref10.getMessage().getMessageID())));

      List msgIds = new ArrayList();
      msgIds.add(new Long(ref3.getMessage().getMessageID()));
      msgIds.add(new Long(ref4.getMessage().getMessageID()));
      msgIds.add(new Long(ref7.getMessage().getMessageID()));
View Full Code Here


      else
      {
        assertEquals(0,txRep.getNumberOfRegisteredTransactions());
      }

      MessageReference ref1 = ms.reference(m1);
      MessageReference ref2 = ms.reference(m2);
      MessageReference ref3 = ms.reference(m3);
      MessageReference ref4 = ms.reference(m4);
      MessageReference ref5 = ms.reference(m5);

      log.debug("adding references non-transactionally");

      // Add first two refs non transactionally
      pm.addReference(channel.getChannelID(), ref1, null);
      pm.addReference(channel.getChannelID(), ref2, null);

      //check they're there
      List refs = getReferenceIds(channel.getChannelID());
      assertNotNull(refs);
      assertEquals(2, refs.size());
      assertTrue(refs.contains(new Long(ref1.getMessage().getMessageID())));
      assertTrue(refs.contains(new Long(ref2.getMessage().getMessageID())));

      List msgs = getMessageIds();
      assertNotNull(msgs);
      assertEquals(2, msgs.size());
      assertTrue(msgs.contains(new Long(ref1.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref2.getMessage().getMessageID())));

      log.debug("ref1 and ref2 are there");

      //Add the next 3 refs transactionally
      pm.addReference(channel.getChannelID(), ref3, tx);
      pm.addReference(channel.getChannelID(), ref4, tx);
      pm.addReference(channel.getChannelID(), ref5, tx);

      //Remove the other 2 transactionally
      pm.removeReference(channel.getChannelID(), ref1, tx);
      pm.removeReference(channel.getChannelID(), ref2, tx);

      //Check the changes aren't visible
      refs = getReferenceIds(channel.getChannelID());
      assertNotNull(refs);
      assertEquals(2, refs.size());
      assertTrue(refs.contains(new Long(ref1.getMessage().getMessageID())));
      assertTrue(refs.contains(new Long(ref2.getMessage().getMessageID())));

      msgs = getMessageIds();
      assertNotNull(msgs);
      assertEquals(2, msgs.size());
      assertTrue(msgs.contains(new Long(ref1.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref2.getMessage().getMessageID())));

      //commit transaction
      tx.commit();

      assertEquals("numberOfRegisteredTransactions",0,txRep.getNumberOfRegisteredTransactions());

      //check we can see only the last 3 refs
      refs = getReferenceIds(channel.getChannelID());
      assertNotNull(refs);
      assertEquals(3, refs.size());
      assertTrue(refs.contains(new Long(ref3.getMessage().getMessageID())));
      assertTrue(refs.contains(new Long(ref4.getMessage().getMessageID())));
      assertTrue(refs.contains(new Long(ref5.getMessage().getMessageID())));

      msgs = getMessageIds();
      assertNotNull(msgs);
      assertEquals(3, msgs.size());
      assertTrue(msgs.contains(new Long(ref3.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref4.getMessage().getMessageID())));
      assertTrue(msgs.contains(new Long(ref5.getMessage().getMessageID())));
   }
View Full Code Here

      else
      {
         tx = txRep.createTransaction();
      }

      MessageReference ref1 = ms.reference(m1);
      MessageReference ref2 = ms.reference(m2);
      MessageReference ref3 = ms.reference(m3);
      MessageReference ref4 = ms.reference(m4);
      MessageReference ref5 = ms.reference(m5);

      //Add first two refs non transactionally
      pm.addReference(channel.getChannelID(), ref1, null);
      pm.addReference(channel.getChannelID(), ref2, null);
View Full Code Here

               }

               while (iter.hasNext())
               {
                  // We may need to persist the message itself
                  MessageReference ref = (MessageReference) iter.next();

                  // For non reliable refs we insert the ref (and maybe the
                  // message) itself

                  // Now store the reference
                   
                  log.trace("Paged ref with page order " + ref.getPagingOrder());

                  addReference(channelID, ref, psInsertReference, page);

                  int rows = psInsertReference.executeUpdate();

                  if (trace)
                  {
                     log.trace("Inserted " + rows + " rows");
                  }
                 
                  // Maybe we need to persist the message itself
                  Message m = ref.getMessage();

                  rows = storeMessage(m, psInsertMessage, psUpdateMessage);

                  if (trace)
                  {
View Full Code Here

               Iterator iter = references.iterator();

               while (iter.hasNext())
               {
                  MessageReference ref = (MessageReference) iter.next();

                  removeReference(channelID, ref, psDeleteReference);

                  int rows = psDeleteReference.executeUpdate();
View Full Code Here

               psUpdateReference = conn
                     .prepareStatement(getSQLStatement("UPDATE_PAGE_ORDER"));

               while (iter.hasNext())
               {
                  MessageReference ref = (MessageReference) iter.next();

                  psUpdateReference.setLong(1, ref.getPagingOrder());

                  psUpdateReference.setLong(2, ref.getMessage().getMessageID());

                  psUpdateReference.setLong(3, channelID);

                  int rows = psUpdateReference.executeUpdate();
View Full Code Here

               boolean first = true;

               for (Iterator i = refsToAdd.iterator(); i.hasNext();)
               {
                  ChannelRefPair pair = (ChannelRefPair) i.next();
                  MessageReference ref = pair.ref;

                  if (psReference == null)
                  {
                     psReference = conn
                           .prepareStatement(getSQLStatement("INSERT_MESSAGE_REF"));
                  }

                  // Now store the reference
                  addReference(pair.channelID, ref, psReference, false);

                  int rows = psReference.executeUpdate();

                  if (trace)
                  {
                     log.trace("Inserted " + rows + " rows");
                  }

                  Message m = ref.getMessage();

                  synchronized (m)
                  {
                     if (!m.isPersisted())
                     {
View Full Code Here

               while (iter.hasNext())
               {
                  Object obj = iter.next();

                  MessageReference ref;
                  if (obj instanceof MessageReference)
                  {
                     ref = (MessageReference) obj;
                  }
                  else
                  {
                     ref = ((ChannelRefPair) obj).ref;
                  }

                  psMessage.setLong(1, ref.getMessage().getMessageID());
                  psMessage.setLong(2, ref.getMessage().getMessageID());

                  int rows = psMessage.executeUpdate();

                  if (trace)
                  {
View Full Code Here

   {
      static MessageOrderComparator instance = new MessageOrderComparator();

      public int compare(Object o1, Object o2)
      {
         MessageReference ref1;
         MessageReference ref2;

         if (o1 instanceof MessageReference)
         {
            ref1 = (MessageReference) o1;
            ref2 = (MessageReference) o2;
         }
         else
         {
            ref1 = ((ChannelRefPair) o1).ref;
            ref2 = ((ChannelRefPair) o2).ref;
         }

         long id1 = ref1.getMessage().getMessageID();
         long id2 = ref2.getMessage().getMessageID();

         return (id1 < id2 ? -1 : (id1 == id2 ? 0 : 1));
      }
View Full Code Here

                  iter = messages.iterator();
                 
                  while (iter.hasNext())
                  {
                     Message m = (Message)iter.next();
                     MessageReference mref = ms.reference(m);
                    
                     ReferenceInfo mInfo = refInfoMap.get(m.getMessageID());
                     mref.setDeliveryCount(mInfo.getDeliveryCount());
                     mref.setScheduledDeliveryTime(mInfo.getScheduledDelivery());
                    
                     Delivery del = new SimpleDelivery(ch, mref, true, true);
                     del.cancel();
                  }
               }
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.contract.MessageReference

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.