Package org.jboss.jms.message

Examples of org.jboss.jms.message.JBossMessage




   public void testExpirationOnReceive() throws Exception
   {
      expectedMessage = new JBossMessage(123456);

      queueProducer.send(queueProducerSession.createMessage(), DeliveryMode.NON_PERSISTENT, 4, 2000);

      // allow the message to expire
      Thread.sleep(3000);
View Full Code Here


      return new Integer(getState(invocation).getAcknowledgeMode());
   }
  
   public Object handleCreateMessage(Invocation invocation) throws Throwable
   {
      JBossMessage jbm = new JBossMessage(0);
      
      return new MessageProxy(jbm);
   }
View Full Code Here

      // Generate the message id
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();

      long id = -1;

      JBossMessage messageToSend;
      boolean foreign = false;

      if (!(m instanceof MessageProxy))
      {
         // it's a foreign message

         foreign = true;

         // JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
         // a message whose implementation is not one of its own.

         // create a matching JBossMessage Type from JMS Type
         if(m instanceof BytesMessage)
         {
            messageToSend = new JBossBytesMessage((BytesMessage)m,0);
         }
         else if(m instanceof MapMessage)
         {
            messageToSend = new JBossMapMessage((MapMessage)m,0);
         }
         else if(m instanceof ObjectMessage)
         {
            messageToSend = new JBossObjectMessage((ObjectMessage)m,0);
         }
         else if(m instanceof StreamMessage)
         {
            messageToSend = new JBossStreamMessage((StreamMessage)m,0);
         }
         else if(m instanceof TextMessage)
         {
            messageToSend = new JBossTextMessage((TextMessage)m,0);
         }
         else
         {
            messageToSend = new JBossMessage(m, 0);
         }

         messageToSend.setJMSMessageID(null);

         //We must set the destination *after* converting from foreign message
         messageToSend.setJMSDestination(destination);
         if(connectionState.getRemotingConnection().isStrictTck())
         {
            m.setJMSDestination(destination);
         }
      }
      else
      {
         // get the actual message
         MessageProxy proxy = (MessageProxy)m;

         m.setJMSDestination(destination);
        
         if (keepID)
         {
            id = proxy.getMessage().getMessageID();
         }

         //The following line executed on the proxy should cause a copy to occur
         //if it is necessary
         proxy.setJMSMessageID(null);

         //Get the underlying message
         messageToSend = proxy.getMessage();

         proxy.beforeSend();
      }

      // Set the new id

      if (!keepID)
      {
         id = connectionState.getIdGenerator().getId((ConnectionDelegate)connectionState.getDelegate());
      }
     
      messageToSend.setMessageId(id);
           
      // This only really used for BytesMessages and StreamMessages to reset their state
      messageToSend.doBeforeSend();
     
      // now that we know the messageID, set it also on the foreign message, if is the case
      if (foreign)
      {
         m.setJMSMessageID(messageToSend.getJMSMessageID());
      }
           
      // we now invoke the send(Message) method on the session, which will eventually be fielded
      // by connection endpoint
      ((SessionDelegate)sessionState.getDelegate()).send(messageToSend, false);
View Full Code Here

     
      if (expiryQueue != null)
      {
         if (trace) { log.trace(this + " sending expired message to expiry queue " + expiryQueue); }
        
         JBossMessage copy = makeCopyForDLQOrExpiry(true, del);
        
         moveInTransaction(copy, del, expiryQueue, true);
      }
      else
      {
View Full Code Here

      {                 
         if (expired)
         {
            //Sent to expiry queue
           
            JBossMessage copy = makeCopyForDLQOrExpiry(true, del);
           
            moveInTransaction(copy, del, rec.expiryQueue, false);
         }
         else
         {
            //Send to DLQ
          
            JBossMessage copy = makeCopyForDLQOrExpiry(false, del);
           
            moveInTransaction(copy, del, rec.dlq, true);
         }
      }     
     
View Full Code Here

      //subscriptions of a topic for example
      //We set headers that hold the original message destination, expiry time and original message id
     
     if (trace) { log.trace("Making copy of message for DLQ or expiry " + del); }
    
      JBossMessage msg = ((JBossMessage)del.getReference().getMessage());
     
      JBossMessage copy = msg.doCopy();
     
      long newMessageId = sp.getMessageIDManager().getID();
     
      copy.setMessageId(newMessageId);
     
      //reset expiry
      copy.setExpiration(0);
     
      String origMessageId = msg.getJMSMessageID();
     
      String origDest = msg.getJMSDestination().toString();
           
      copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID, origMessageId);
     
      copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION, origDest);
     
      if (expiry)
      {
         long actualExpiryTime = System.currentTimeMillis();
        
         copy.setLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME, actualExpiryTime);
      }
     
      return copy;
   }
View Full Code Here

         // send the messages

         for (Iterator j = sessionState.getMsgs().iterator(); j.hasNext(); )
         {
            JBossMessage message = (JBossMessage)j.next();

            sendMessage(message, tx, checkForDuplicates);
         }

         // send the acks
View Full Code Here

      String result = "<null>";
      if (ref == null) return result;
      Object rmsg = ref.getMessage();
      if (rmsg instanceof JBossMessage)
      {
         JBossMessage msg = (JBossMessage)ref.getMessage();
         if (msg instanceof TextMessage)
         {
            try
            {
               result = "(" + ((TextMessage)msg).getText() + ")";
View Full Code Here

      if (expiryQueue != null)
      {
         if (trace) { log.trace(this + " sending expired message to expiry queue " + expiryQueue); }

         JBossMessage copy = makeCopyForDLQOrExpiry(true, del);

         moveInTransaction(copy, del, expiryQueue, true);
      }
      else
      {
View Full Code Here

         if (expired)
         {
            //Sent to expiry queue

            if (debug) { log.debug("Sending expired message: " + rec.del.getReference() + " to expiry queue " + rec.expiryQueue); }
            JBossMessage copy = makeCopyForDLQOrExpiry(true, del);

            moveInTransaction(copy, del, rec.expiryQueue, false);
         }
         else
         {
            //Send to DLQ
            if (debug) { log.debug("Sending message: " + rec.del.getReference() + " to dlq " + rec.dlq); }

            JBossMessage copy = makeCopyForDLQOrExpiry(false, del);

            moveInTransaction(copy, del, rec.dlq, true);
         }
      }
View Full Code Here

TOP

Related Classes of org.jboss.jms.message.JBossMessage

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.