Package org.hornetq.api.core.client

Examples of org.hornetq.api.core.client.ClientSessionFactory


      server.start();
      embeddedServerRunning = true;
    }

    TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getCanonicalName(), connectionParams);
    ClientSessionFactory factory = HornetQClient.createClientSessionFactory(transportConfiguration);
    session = factory.createSession();
    try {
      session.createQueue(SERVER_TASK_COMMANDS_QUEUE, SERVER_TASK_COMMANDS_QUEUE, true);
    }
    catch (HornetQException e) {
      if (e.getCode()!=HornetQException.QUEUE_EXISTS) {
View Full Code Here


      }
      connectionParams.put(TransportConstants.PORT_PROP_NAME, port);
      connectionParams.put(TransportConstants.HOST_PROP_NAME, address);

      TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getCanonicalName(), connectionParams);
      ClientSessionFactory factory = HornetQClient.createClientSessionFactory(transportConfiguration);
      session = factory.createSession();
      producer = session.createProducer(HornetQTaskServer.SERVER_TASK_COMMANDS_QUEUE);

      createClientQueue();

      Thread responsesThread = new Thread(new Runnable() {
View Full Code Here

    public static void main(String[] args) throws Exception {

        final String queueName = "queue.standalone";

        final ClientSessionFactory sf = createClientSessionFactory("localhost", 5445);
        final ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);

        try {
            // Check that the queue does not exist
            if(queueExists(queueName, sf)) {
                throw new IllegalStateException();
            }

            // Create a new core queue using the standalone client


            ModelNode op = new ModelNode();
            op.get("operation").set("add");
            op.get("address").add("subsystem", "messaging");
            op.get("address").add("queue", queueName);
            op.get("queue-address").set(queueName);
            applyUpdate(op, client);

            // Check if the queue exists
            if(! queueExists(queueName, sf)) {
                throw new IllegalStateException();
            }

            ClientSession session = null;
            try {
               session = sf.createSession();
               ClientProducer producer = session.createProducer(queueName);
               ClientMessage message = session.createMessage(false);

               final String propName = "myprop";
               message.putStringProperty(propName, "Hello sent at " + new Date());
View Full Code Here

      server.createQueue(new SimpleString("q1"), new SimpleString("q1"), null, true, false);
      server.createQueue(new SimpleString("q2"), new SimpleString("q2"), null, true, false);

      ServerLocator locator = createInVMNonHALocator();

      ClientSessionFactory sf = locator.createSessionFactory();

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

      ClientProducer prod1 = session.createProducer("q1");

      for (int i = 0; i < 10; i++)
      {
View Full Code Here

      server.createQueue(new SimpleString("q1"), new SimpleString("q1"), null, true, false);
      server.createQueue(new SimpleString("q2"), new SimpleString("q2"), null, true, false);

      ServerLocator locator = createInVMNonHALocator();

      ClientSessionFactory sf = locator.createSessionFactory();

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

      ClientProducer prod1 = session.createProducer("q1");

      int NUMBER_OF_MSGS = 10;
View Full Code Here

      locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
      locator.setBlockOnNonDurableSend(true);
      locator.setBlockOnNonDurableSend(true);
      locator.setConsumerWindowSize(0);
      ClientSessionFactory sf = locator.createSessionFactory();
      session = sf.createSession(false, true, false);
      session.start();
   }
View Full Code Here

   protected void setUp() throws Exception
   {
      super.setUp();

      locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
      ClientSessionFactory sf = locator.createSessionFactory();
      session = sf.createSession(false, true, true);
      session.start();
   }
View Full Code Here

         largeMessageCache = File.createTempFile("tmp-large-message-" + largeMessage.getMessageID() + "-",
                                                 ".tmp");
         largeMessageCache.deleteOnExit();
      }

      ClientSessionFactory sf = session.getSessionFactory();
      ServerLocator locator = sf.getServerLocator();
      long callTimeout = locator.getCallTimeout();

      currentLargeMessageController = new LargeMessageControllerImpl(this, largeMessage.getLargeMessageSize(), callTimeout, largeMessageCache);
      currentLargeMessageController.setLocal(true);
View Full Code Here

         largeMessageCache = File.createTempFile("tmp-large-message-" + currentChunkMessage.getMessageID() + "-",
                                                 ".tmp");
         largeMessageCache.deleteOnExit();
      }

      ClientSessionFactory sf = session.getSessionFactory();
      ServerLocator locator = sf.getServerLocator();
      long callTimeout = locator.getCallTimeout();

      currentLargeMessageController = new LargeMessageControllerImpl(this, packet.getLargeMessageSize(), callTimeout, largeMessageCache);

      if (currentChunkMessage.isCompressed())
View Full Code Here

      serverManager.createQueue(false, otherQueueName, null, true, otherQueueName);
      HornetQDestination otherQueue = (HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);

      ServerLocator locator = createInVMNonHALocator();

      ClientSessionFactory sf = locator.createSessionFactory();

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

      ClientProducer prod1 = session.createProducer(queue.getAddress());
      ClientProducer prod2 = session.createProducer(otherQueue.getAddress());

      for (int i = 0; i < 10; i++)
      {
         ClientMessage msg = session.createMessage(true);

         msg.putStringProperty(org.hornetq.api.core.Message.HDR_DUPLICATE_DETECTION_ID, new SimpleString("dupl-" + i));

         prod1.send(msg);
         if (i < 5)
         {
            prod2.send(msg);
         }
      }

      session.commit();

      JMSQueueControl queueControl = createManagementControl();
      JMSQueueControl otherQueueControl = ManagementControlHelper.createJMSQueueControl((HornetQQueue)otherQueue,
                                                                                        mbeanServer);

      Assert.assertEquals(10, queueControl.getMessageCount());

      int moved = queueControl.moveMessages(null, otherQueueName, true);

      assertEquals(10, moved);

      assertEquals(0, queueControl.getDeliveringCount());

      session.start();

      ClientConsumer cons1 = session.createConsumer(queue.getAddress());

      assertNull(cons1.receiveImmediate());

      cons1.close();

      ClientConsumer cons2 = session.createConsumer(otherQueue.getAddress());

      for (int i = 0; i < 10; i++)
      {
         ClientMessage msg = cons2.receive(10000);

         assertNotNull(msg);

         msg.acknowledge();
      }

      cons2.close();

      session.close();

      sf.close();

      locator.close();

      Assert.assertEquals(0, queueControl.getMessageCount());
View Full Code Here

TOP

Related Classes of org.hornetq.api.core.client.ClientSessionFactory

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.