Package org.hornetq.core.server.impl

Examples of org.hornetq.core.server.impl.ServerMessageImpl


      RoutingContext ctx = generateCTX(txImpl);

      for (int i = start; i < start + NUM_MESSAGES; i++)
      {
         HornetQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1l);
         ServerMessage msg = new ServerMessageImpl(storage.generateUniqueID(), buffer.writerIndex());
         msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
         msg.putIntProperty("key", i);
         pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS));
      }
     
      return txImpl;
View Full Code Here


      String destination = (String)headers.remove(Stomp.Headers.Send.DESTINATION);
      String txID = (String)headers.remove(Stomp.Headers.TRANSACTION);
      long timestamp = System.currentTimeMillis();
     
      SimpleString address = SimpleString.toSimpleString(destination);
      ServerMessageImpl message = new ServerMessageImpl(server.getStorageManager().generateUniqueID(), 512);
      message.setTimestamp(timestamp);
      message.setAddress(address);

      validateDestination(address);
     
      StompUtils.copyStandardHeadersFromFrameToMessage(frame, message);
      if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH))
      {
         message.setType(Message.BYTES_TYPE);
         message.getBodyBuffer().writeBytes(frame.getContent());
      }
      else
      {
         message.setType(Message.TEXT_TYPE);
         String text = new String(frame.getContent(), "UTF-8");
         message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(text));
      }

      StompSession stompSession = null;
      if (txID == null)
      {
         stompSession = getSession(connection);
      }
      else
      {
         stompSession = getTransactedSession(connection, txID);
      }
      if (stompSession.isNoLocal())
      {
         message.putStringProperty(CONNECTION_ID_PROP, connection.getID().toString());
      }
      stompSession.sendInternal(message, true);      
     
      return null;
   }
View Full Code Here

      // Need to lock to make sure all queue info and notifications are in the correct order with no gaps
      synchronized (notificationLock)
      {
         // First send a reset message

         ServerMessage message = new ServerMessageImpl(storageManager.generateUniqueID(), 50);

         message.setAddress(queueName);
         message.putBooleanProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA, true);
         routeQueueInfo(message, queue, false);

         for (QueueInfo info : queueInfos.values())
         {
            if (log.isTraceEnabled())
            {
               log.trace("QueueInfo on sendQueueInfoToQueue = " + info);
            }
            if (info.getAddress().startsWith(address))
            {
               message = createQueueInfoMessage(NotificationType.BINDING_ADDED, queueName);

               message.putStringProperty(ManagementHelper.HDR_ADDRESS, info.getAddress());
               message.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, info.getClusterName());
               message.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, info.getRoutingName());
               message.putLongProperty(ManagementHelper.HDR_BINDING_ID, info.getID());
               message.putStringProperty(ManagementHelper.HDR_FILTERSTRING, info.getFilterString());
               message.putIntProperty(ManagementHelper.HDR_DISTANCE, info.getDistance());

               routeQueueInfo(message, queue, true);

               int consumersWithFilters = info.getFilterStrings() != null ? info.getFilterStrings().size() : 0;

               for (int i = 0; i < info.getNumberOfConsumers() - consumersWithFilters; i++)
               {
                  message = createQueueInfoMessage(NotificationType.CONSUMER_CREATED, queueName);

                  message.putStringProperty(ManagementHelper.HDR_ADDRESS, info.getAddress());
                  message.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, info.getClusterName());  
                  message.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, info.getRoutingName());
                  message.putIntProperty(ManagementHelper.HDR_DISTANCE, info.getDistance());

                  routeQueueInfo(message, queue, true);
               }

               if (info.getFilterStrings() != null)
               {
                  for (SimpleString filterString : info.getFilterStrings())
                  {
                     message = createQueueInfoMessage(NotificationType.CONSUMER_CREATED, queueName);

                     message.putStringProperty(ManagementHelper.HDR_ADDRESS, info.getAddress());
                     message.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, info.getClusterName());
                     message.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, info.getRoutingName());
                     message.putStringProperty(ManagementHelper.HDR_FILTERSTRING, filterString);
                     message.putIntProperty(ManagementHelper.HDR_DISTANCE, info.getDistance());

                     routeQueueInfo(message, queue, true);
                  }
               }
            }
View Full Code Here

      }
   }

   private ServerMessage createQueueInfoMessage(final NotificationType type, final SimpleString queueName)
   {
      ServerMessage message = new ServerMessageImpl(storageManager.generateUniqueID(), 50);

      message.setAddress(queueName);

      String uid = UUIDGenerator.getInstance().generateStringUUID();

      message.putStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE, new SimpleString(type.toString()));
      message.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, System.currentTimeMillis());

      message.putStringProperty(new SimpleString("foobar"), new SimpleString(uid));

      return message;
   }
View Full Code Here

   public void testDeleteMessagesOnStartup() throws Exception
   {
      createStorage();

      ServerMessage msg = new ServerMessageImpl(1, 100);

      journal.storeMessage(msg);

      for (int i = 2; i < 100; i++)
      {
         journal.storeMessage(new ServerMessageImpl(i, 100));
      }
     
      journal.storeReference(1, 1, true);

      journal.stop();
View Full Code Here

         blockOnReplication(storage, manager);

         Assert.assertEquals(0, manager.getActiveTokens().size());

         ServerMessage msg = new ServerMessageImpl(1, 1024);

         SimpleString dummy = new SimpleString("dummy");
         msg.setAddress(dummy);

         replicatedJournal.appendAddRecordTransactional(23, 24, (byte)1, new FakeData());

         PagedMessage pgmsg = new PagedMessageImpl(msg, -1);
         manager.pageWrite(pgmsg, 1);
         manager.pageWrite(pgmsg, 2);
         manager.pageWrite(pgmsg, 3);
         manager.pageWrite(pgmsg, 4);

         blockOnReplication(storage, manager);

         PagingManager pagingManager = createPageManager(server.getStorageManager(),
                                                         server.getConfiguration(),
                                                         server.getExecutorFactory(),
                                                         server.getAddressSettingsRepository());

         PagingStore store = pagingManager.getPageStore(dummy);
         store.start();
         Assert.assertEquals(5, store.getNumberOfPages());
         store.stop();

         manager.pageDeleted(dummy, 1);
         manager.pageDeleted(dummy, 2);
         manager.pageDeleted(dummy, 3);
         manager.pageDeleted(dummy, 4);
         manager.pageDeleted(dummy, 5);
         manager.pageDeleted(dummy, 6);

         blockOnReplication(storage, manager);

         ServerMessageImpl serverMsg = new ServerMessageImpl();
         serverMsg.setMessageID(500);
         serverMsg.setAddress(new SimpleString("tttt"));

         HornetQBuffer buffer = HornetQBuffers.dynamicBuffer(100);
         serverMsg.encodeHeadersAndProperties(buffer);

         manager.largeMessageBegin(500);

         manager.largeMessageWrite(500, new byte[1024]);
View Full Code Here

      }
   }

   protected ServerMessage generateMessage(final long id)
   {
      ServerMessage message = new ServerMessageImpl(id, 1000);

      message.setMessageID(id);

      message.getBodyBuffer().writeString(UUID.randomUUID().toString());

      message.setAddress(new SimpleString("foo"));

      return message;
   }
View Full Code Here

      HornetQServer server = HornetQServers.newHornetQServer(conf, false);
      server.start();

      // invoke attribute and operation on the server
      ServerMessage message = new ServerMessageImpl(1, 100);
      ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "createQueue", queue, address);

      ServerMessage reply = server.getManagementService().handleMessage(message);

      Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
View Full Code Here

      HornetQServer server = HornetQServers.newHornetQServer(conf, false);
      server.start();

      // invoke attribute and operation on the server
      ServerMessage message = new ServerMessageImpl(1, 100);
      ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "thereIsNoSuchOperation");

      ServerMessage reply = server.getManagementService().handleMessage(message);

      Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
View Full Code Here

      HornetQServer server = HornetQServers.newHornetQServer(conf, false);
      server.start();

      // invoke attribute and operation on the server
      ServerMessage message = new ServerMessageImpl(1, 100);
      ManagementHelper.putOperationInvocation(message, "Resouce.Does.Not.Exist", "toString");

      ServerMessage reply = server.getManagementService().handleMessage(message);

      Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
View Full Code Here

TOP

Related Classes of org.hornetq.core.server.impl.ServerMessageImpl

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.