Package org.jboss.messaging.core.contract

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


  
   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


                        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

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

                        //We only cache the first id in a tx - this is enough to determine if the tx succeeded
                        if (first && m instanceof JBossMessage)
                        {
                           cacheID(conn, ((JBossMessage)m).getJMSMessageID());

                           first = false;
                        }
                     }
                  }
               }

               // 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 (SQLException e)
            {
               if (transactionDone)
               {
                  String sqlState = e.getSQLState();
                  //23000(XA) or 23xxx (SQL:2003)
                  if (sqlState.startsWith("23"))
                  {
                     //this is a constraint violation. i.e. the record identified by the same key already exists
                     //This is fine, log a warning and go ahead.
                     log.warn("We encountered a after-commit problem however messages have already been inserted.");
                     return null;
                  }
               }
               throw e;
            }
            finally
            {
               closeStatement(psReference);
               closeStatement(psDeleteReference);
               closeStatement(psInsertMessage);
            }
         }

         public void rollback()
         {
            if(messagesStored != null)
            {
               for (Iterator i = messagesStored.iterator(); i.hasNext();)
               {
                  Message msg = (Message) i.next();

                  msg.setPersisted(false);
               }
            }
         }
      }
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);

                        //We only cache the first id in a tx - this is enough to determine if the tx succeeded
                        if (first && m instanceof JBossMessage)
                        {
                           cacheID(conn, ((JBossMessage)m).getJMSMessageID());

                           first = false;
                        }
                     }
                  }
               }

               // 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 (SQLException e)
            {
               if (transactionDone)
               {
                  String sqlState = e.getSQLState();
                  //23000(XA) or 23xxx (SQL:2003)
                  if (sqlState.startsWith("23"))
                  {
                     //this is a constraint violation. i.e. the record identified by the same key already exists
                     //This is fine, log a warning and go ahead.
                     log.warn("We encountered a after-commit problem however messages have already been inserted.");
                     return null;
                  }
               }
               throw e;
            }
            finally
            {
               closeStatement(psReference);
               closeStatement(psInsertMessage);
               closeStatement(psUpdateReference);
            }
         }

         public void rollback()
         {
            if(messagesStored != null)
            {
               for (Iterator i = messagesStored.iterator(); i.hasNext();)
               {
                  Message msg = (Message) i.next();

                  msg.setPersisted(false);
               }
            }
         }
      }
View Full Code Here

         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

                        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

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

                        //We only cache the first id in a tx - this is enough to determine if the tx succeeded
                        if (first && m instanceof JBossMessage)
View Full Code Here

         {
            if(messagesStored != null)
            {
               for (Iterator i = messagesStored.iterator(); i.hasNext();)
               {
                  Message msg = (Message) i.next();

                  msg.setPersisted(false);
               }
            }
         }
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.