Package org.jboss.messaging.core.contract

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


         List messages = getMessages(new ArrayList(msgIds));

         for (Iterator iter = messages.iterator(); iter.hasNext();)
         {
            Message msg = (Message) iter.next();

            messageMap.put(new Long(msg.getMessageID()), msg);
         }

         List returnList = new ArrayList();

         for (Iterator iter = holders.iterator(); iter.hasNext();)
         {
            Holder holder = (Holder) iter.next();

            Message msg = (Message) messageMap.get(new Long(holder.messageId));

            if (msg == null) { throw new IllegalStateException(
                  "Cannot find message " + holder.messageId); }

            MessageChannelPair pair = new MessageChannelPair(msg,
View Full Code Here


  
   private static boolean checkExpiredOrReachedMaxdeliveries(MessageProxy proxy,
                                                             SessionDelegate del,
                                                             int maxDeliveries, boolean shouldCancel)
   {
      Message msg = proxy.getMessage();
     
      boolean expired = msg.isExpired();
     
      boolean reachedMaxDeliveries = proxy.getDeliveryCount() == maxDeliveries;
     
      if (expired || reachedMaxDeliveries)
      {
View Full Code Here

    */
   public void handleMessage(final Object message) throws Exception
   {
      ClientDelivery del = (ClientDelivery)message;
     
      Message msg = del.getMessage();
     
      MessageProxy proxy = JBossMessage.
         createThinDelegate(del.getDeliveryId(), (JBossMessage)msg, del.getDeliveryCount());

      //TODO - we temporarily need to execute on a different thread to avoid a deadlock situation in
View Full Code Here

         public Object doTransaction() throws Exception
         {
            PreparedStatement psReference = null;
            PreparedStatement psInsertMessage = null;

            Message m = ref.getMessage();

            try
            {
               psReference = conn
                     .prepareStatement(getSQLStatement("INSERT_MESSAGE_REF"));

               // Add the reference
               addReference(channelID, ref, psReference, false);

               int rows = psReference.executeUpdate();

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

               if (!m.isPersisted())
               {
                  // First time so persist the message
                  psInsertMessage = conn
                        .prepareStatement(getSQLStatement("INSERT_MESSAGE"));

                  storeMessage(m, psInsertMessage, true);
                  rows = psInsertMessage.executeUpdate();

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

                  log.trace("message Inserted/updated " + rows + " rows");

                  // Needs to be at the end - in case an exception is thrown in
                  // which case retry will be attempted and we want to insert it
                  // again
                  m.setPersisted(true);
               }

               return null;
            }
            finally
View Full Code Here

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

                  Message m = ref.getMessage();

                  synchronized (m)
                  {
                     if (!m.isPersisted())
                     {
                        if (psInsertMessage == null)
                        {
                           psInsertMessage = conn
                                 .prepareStatement(getSQLStatement("INSERT_MESSAGE"));
                        }

                        // First time so add message
                        // And in case of clustered queues/topics, the message
                        // could possibly be already persisted on the different
                        // node
                        // so we persist also using the Conditional Update
                        if (trace)
                        {
                           log
                                 .trace("Message does not already exist so inserting it");
                        }
                        storeMessage(m, psInsertMessage, true);
                        rows = psInsertMessage.executeUpdate();
                        if (trace)
                        {
                           log.trace("Inserted " + rows + " rows");
                        }

                        m.setPersisted(true);

                        messagesStored.add(m);
                     }
                  }
               }

               // Now the removes

               for (Iterator i = refsToRemove.iterator(); i.hasNext();)
               {
                  ChannelRefPair pair = (ChannelRefPair) i.next();

                  if (psDeleteReference == null)
                  {
                     psDeleteReference = conn
                           .prepareStatement(getSQLStatement("DELETE_MESSAGE_REF"));
                  }

                  removeReference(pair.channelID, pair.ref, psDeleteReference);

                  int rows = psDeleteReference.executeUpdate();

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

               }

               return null;
            }
            catch (Exception e)
            {
               for (Iterator i = messagesStored.iterator(); i.hasNext();)
               {
                  Message msg = (Message) i.next();

                  msg.setPersisted(false);
               }
               throw e;
            }
            finally
            {
View Full Code Here

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

                  Message m = pair.ref.getMessage();

                  synchronized (m)
                  {
                     if (!m.isPersisted())
                     {
                        if (psInsertMessage == null)
                        {
                           psInsertMessage = conn
                                 .prepareStatement(getSQLStatement("INSERT_MESSAGE"));
                        }

                        storeMessage(m, psInsertMessage, true);
                        rows = psInsertMessage.executeUpdate();

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

                        m.setPersisted(true);

                        messagesStored.add(m);
                     }
                  }
               }

               // Now the removes

               iter = refsToRemove.iterator();

               while (iter.hasNext())
               {
                  if (psUpdateReference == null)
                  {
                     psUpdateReference = conn
                           .prepareStatement(getSQLStatement("UPDATE_MESSAGE_REF"));
                  }

                  ChannelRefPair pair = (ChannelRefPair) iter.next();

                  prepareToRemoveReference(pair.channelID, pair.ref, tx,
                        psUpdateReference);

                  int rows = psUpdateReference.executeUpdate();

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

               return null;
            }
            catch (Exception e)
            {
               for (Iterator i = messagesStored.iterator(); i.hasNext();)
               {
                  Message msg = (Message) i.next();

                  msg.setPersisted(false);
               }
               throw e;
            }
            finally
            {
View Full Code Here

                        byte[] payload = getBytes(rs, 7);

                        byte type = rs.getByte(8);

                        Message m = MessageFactory.createMessage(messageId,
                              reliable, expiration, timestamp, priority,
                              headers, payload, type);
                        msgs.add(m);
                     }
View Full Code Here

                  {
                     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

         public Object doTransaction() throws Exception
         {
            PreparedStatement psReference = null;
            PreparedStatement psInsertMessage = null;

            Message m = ref.getMessage();

            try
            {
               psReference = conn
                     .prepareStatement(getSQLStatement("INSERT_MESSAGE_REF"));

               // Add the reference
               addReference(channelID, ref, psReference, false);

               int rows = psReference.executeUpdate();

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

               if (!m.isPersisted())
               {
                  // First time so persist the message
                  psInsertMessage = conn
                        .prepareStatement(getSQLStatement("INSERT_MESSAGE"));

                  storeMessage(m, psInsertMessage, true);
                  rows = psInsertMessage.executeUpdate();

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

                  log.trace("message Inserted/updated " + rows + " rows");

                  // Needs to be at the end - in case an exception is thrown in
                  // which case retry will be attempted and we want to insert it
                  // again
                  m.setPersisted(true);
               }

               return null;
            }
            finally
View Full Code Here

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

                  Message m = ref.getMessage();

                  synchronized (m)
                  {
                     if (!m.isPersisted())
                     {
                        if (psInsertMessage == null)
                        {
                           psInsertMessage = conn
                                 .prepareStatement(getSQLStatement("INSERT_MESSAGE"));
                        }

                        // First time so add message
                        // And in case of clustered queues/topics, the message
                        // could possibly be already persisted on the different
                        // node
                        // so we persist also using the Conditional Update
                        if (trace)
                        {
                           log
                                 .trace("Message does not already exist so inserting it");
                        }
                        storeMessage(m, psInsertMessage, true);
                        rows = psInsertMessage.executeUpdate();
                        if (trace)
                        {
                           log.trace("Inserted " + rows + " rows");
                        }

                        m.setPersisted(true);

                        messagesStored.add(m);
                     }
                  }
               }

               // Now the removes

               for (Iterator i = refsToRemove.iterator(); i.hasNext();)
               {
                  ChannelRefPair pair = (ChannelRefPair) i.next();

                  if (psDeleteReference == null)
                  {
                     psDeleteReference = conn
                           .prepareStatement(getSQLStatement("DELETE_MESSAGE_REF"));
                  }

                  removeReference(pair.channelID, pair.ref, psDeleteReference);

                  int rows = psDeleteReference.executeUpdate();

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

               }

               return null;
            }
            catch (Exception e)
            {
               for (Iterator i = messagesStored.iterator(); i.hasNext();)
               {
                  Message msg = (Message) i.next();

                  msg.setPersisted(false);
               }
               throw e;
            }
            finally
            {
View Full Code Here

TOP

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

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.