Package org.hornetq.core.persistence.impl.journal

Examples of org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl$DecodingContext


      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }

         // The server would be doing this
         fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, LARGE_MESSAGE_SIZE);

         fileMessage.releaseResources();

         session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);

         ClientProducer prod = session.createProducer(LargeMessageTest.ADDRESS);

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();
View Full Code Here


   {
   }

   public int sendMessage(ServerMessage serverMessage, long consumerID, int deliveryCount)
   {
      LargeServerMessageImpl largeMessage = null;
      ServerMessage newServerMessage = serverMessage;
      try
      {
         StompSubscription subscription = subscriptions.get(consumerID);
         StompFrame frame = null;
         if (serverMessage.isLargeMessage())
         {
            newServerMessage = serverMessage.copy();

            largeMessage = (LargeServerMessageImpl)serverMessage;
            BodyEncoder encoder = largeMessage.getBodyEncoder();
            encoder.open();
            int bodySize = (int)encoder.getLargeBodySize();

            //large message doesn't have a body.
            ((ServerMessageImpl)newServerMessage).createBody(bodySize);
            encoder.encode(newServerMessage.getBodyBuffer(), bodySize);
            encoder.close();
         }

         if (serverMessage.getBooleanProperty(Message.HDR_LARGE_COMPRESSED))
         {
            //decompress
            HornetQBuffer qbuff = newServerMessage.getBodyBuffer();
            int bytesToRead = qbuff.writerIndex() - MessageImpl.BODY_OFFSET;
            Inflater inflater = new Inflater();
            inflater.setInput(qbuff.readBytes(bytesToRead).toByteBuffer().array());
           
           
            //get the real size of large message
            long sizeBody = newServerMessage.getLongProperty(Message.HDR_LARGE_BODY_SIZE);

            byte[] data = new byte[(int)sizeBody];
            inflater.inflate(data);
            inflater.end();
            qbuff.resetReaderIndex();
            qbuff.resetWriterIndex();
            qbuff.writeBytes(data);
         }

         frame = connection.createStompMessage(newServerMessage, subscription, deliveryCount);

         int length = frame.getEncodedSize();

         if (subscription.getAck().equals(Stomp.Headers.Subscribe.AckModeValues.AUTO))
         {
            if (manager.send(connection, frame))
            {
               //we ack and commit only if the send is successful
               session.acknowledge(consumerID, newServerMessage.getMessageID());
               session.commit();
            }
         }
         else
         {
            messagesToAck.put(newServerMessage.getMessageID(), new Pair<Long, Integer>(consumerID, length));
            // Must send AFTER adding to messagesToAck - or could get acked from client BEFORE it's been added!
            manager.send(connection, frame);
         }

         return length;
      }
      catch (Exception e)
      {
         return 0;
      }
      finally
      {
         if (largeMessage != null)
         {
            largeMessage.releaseResources();
            largeMessage = null;
         }
      }

   }
View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }

         // The server would be doing this
         fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, LARGE_MESSAGE_SIZE);

         fileMessage.releaseResources();

         session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);

         ClientProducer prod = session.createProducer(LargeMessageTest.ADDRESS);

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();
View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < 2 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }

         fileMessage.releaseResources();

         session.createQueue("A", "A");

         ClientProducer prod = session.createProducer("A");

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();

View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }

         fileMessage.releaseResources();

         session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);

         ClientProducer prod = session.createProducer(LargeMessageTest.ADDRESS);

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();
View Full Code Here

      server.start();
      ServerLocator locator = createInVMNonHALocator();
      ClientSessionFactory factory = locator.createSessionFactory();
      ClientSession session = factory.createSession(false, false);

      LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager) server.getStorageManager());

      fileMessage.setMessageID(1005);
      fileMessage.setDurable(true);

      for (int i = 0; i < 2 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++)
      {
         fileMessage.addBytes(new byte[]{UnitTestCase.getSamplebyte(i)});
      }

      fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, 2 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);

      fileMessage.releaseResources();

      session.createQueue("A", "A");

      ClientProducer prod = session.createProducer("A");

      prod.send(fileMessage);

      fileMessage.deleteFile();

      session.commit();

      session.close();
      locator.close();
View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }

         // The server would be doing this
         fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, LARGE_MESSAGE_SIZE);

         fileMessage.releaseResources();

         session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);

         ClientProducer prod = session.createProducer(LargeMessageTest.ADDRESS);

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();
View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }

         // The server would be doing this
         fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, LARGE_MESSAGE_SIZE);

         fileMessage.releaseResources();

         session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);

         ClientProducer prod = session.createProducer(LargeMessageTest.ADDRESS);

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();
View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());

         fileMessage.setMessageID(1005);

         for (int i = 0; i < 2 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }
         // The server would be doing this
         fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, 2 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);


         fileMessage.releaseResources();

         session.createQueue("A", "A");

         ClientProducer prod = session.createProducer("A");

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();

View Full Code Here

      ClientSession session = sf.createSession(false, false);

      try
      {
         LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());
        
         fileMessage.setMessageID(1005);

         for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
         {
            fileMessage.addBytes(new byte[] { UnitTestCase.getSamplebyte(i) });
         }
        
         // The server would be doing this
         fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, LARGE_MESSAGE_SIZE);

         fileMessage.releaseResources();

         session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);

         ClientProducer prod = session.createProducer(LargeMessageTest.ADDRESS);

         prod.send(fileMessage);

         fileMessage.deleteFile();

         session.commit();

         session.start();
View Full Code Here

TOP

Related Classes of org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl$DecodingContext

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.