Package org.hornetq.api.core.client

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


               ClientSessionFactory sf = null;

               ClientSession session = null;

               ClientProducer producer = null;

               try
               {
                  sf = locator.createSessionFactory();

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

                  producer = session.createProducer(new SimpleString(testAddress));

                  for (int i = 0; i < nmsg; i++)
                  {
                     assertEquals(0, errors.get());
                     ClientMessage message = session.createMessage(true);

                     message.putIntProperty("seq", i);
                    
                    
                     if (i % 100 == 0)
                     {
                        message.setPriority((byte)(RandomUtil.randomPositiveInt() % 9));
                     }
                     else
                     {
                        message.setPriority((byte)5);
                     }

                     message.getBodyBuffer().writeBytes(new byte[50]);

                     producer.send(message);
                     assertTrue(semop.tryAcquire(1, 10, TimeUnit.SECONDS));
                  }
               }
               catch (Throwable e)
               {
View Full Code Here


         ClientSession session0 = sf0.createSession(false, true, true);

         ClientSession session1 = sf1.createSession(false, true, true);

         ClientProducer producer0 = session0.createProducer(new SimpleString(testAddress));

         ClientConsumer consumer1 = session1.createConsumer(queueName1);

         session1.start();

         final int numMessages = 500;

         final SimpleString propKey = new SimpleString("testkey");

         for (int i = 0; i < numMessages; i++)
         {
            ClientMessage message = session0.createMessage(false);

            message.putIntProperty(propKey, i);

            producer0.send(message);
         }

         for (int i = 0; i < numMessages; i++)
         {
            ClientMessage message = consumer1.receive(5000);
View Full Code Here

         ClientSession session0 = sf0.createSession(false, true, true);

         ClientSession session1 = sf1.createSession(false, true, true);

         ClientProducer producer0 = session0.createProducer(new SimpleString(testAddress));

         ClientConsumer consumer1 = session1.createConsumer(queueName1);

         session1.start();

         final byte[] bytes = new byte[messageSize];

         final SimpleString propKey = new SimpleString("testkey");

         for (int i = 0; i < numMessages; i++)
         {
            ClientMessage message = session0.createMessage(false);

            message.putIntProperty(propKey, i);

            message.getBodyBuffer().writeBytes(bytes);

            producer0.send(message);
         }

         for (int i = 0; i < numMessages; i++)
         {
            ClientMessage message = consumer1.receive(200);
View Full Code Here

               ClientSessionFactory sf = null;

               ClientSession session = null;

               ClientProducer producer = null;

               try
               {
                  sf = locator.createSessionFactory();

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

                  producer = session.createProducer(new SimpleString(testAddress));

                  for (int i = 0; i < nmsg; i++)
                  {
                     assertEquals(0, errors.get());
                     ClientMessage message = session.createMessage(true);

                     message.putIntProperty("seq", i);
                    
                    
                     if (i % 100 == 0)
                     {
                        message.setPriority((byte)(RandomUtil.randomPositiveInt() % 9));
                     }
                     else
                     {
                        message.setPriority((byte)5);
                     }

                     message.getBodyBuffer().writeBytes(new byte[50]);

                     producer.send(message);
                     assertTrue(semop.tryAcquire(1, 10, TimeUnit.SECONDS));
                  }
               }
               catch (Throwable e)
               {
View Full Code Here

            {
               ClientSession sessionProducer = null;
               try
               {
                  sessionProducer = sf.createSession(false, false);
                  ClientProducer producer = sessionProducer.createProducer(ADDRESS);

                  for (int i = 0; i < numberOfMessages; i++)
                  {
                     ClientMessage msg = sessionProducer.createMessage(true);
                     msg.getBodyBuffer().writeBytes(body);
                     msg.putIntProperty("count", i);
                     producer.send(msg);

                     if (i % 100 == 0 && i != 0)
                     {
                        sessionProducer.commit();
                        // Thread.sleep(500);
View Full Code Here

            {
               ClientSession sessionProducer = null;
               try
               {
                  sessionProducer = sf.createSession(true, true);
                  ClientProducer producer = sessionProducer.createProducer(ADDRESS);

                  for (int i = 0; i < numberOfMessages; i++)
                  {
                     ClientMessage msg = sessionProducer.createMessage(true);
                     msg.getBodyBuffer().writeBytes(body);
                     msg.putIntProperty("count", i);
                     producer.send(msg);

                     if (i == 1000)
                     {
                        // The session is not TX, but we do this just to perform a round trip to the server
                        // and make sure there are no pending messages
View Full Code Here

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession session = sf.createSession(null, null, false, true, true, false, 0);

         session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);

         ClientProducer producer = session.createProducer(PagingTest.ADDRESS);

         ClientMessage message = null;

         byte[] body = new byte[numberOfBytes];

         for (int j = 0; j < numberOfBytes; j++)
         {
            body[j] = UnitTestCase.getSamplebyte(j);
         }

         long scheduledTime = System.currentTimeMillis() + 5000;

         for (int i = 0; i < numberOfMessages; i++)
         {
            message = session.createMessage(true);

            message.getBodyBuffer().writeBytes(body);
            message.putIntProperty(new SimpleString("id"), i);

            TestSupportPageStore store = (TestSupportPageStore)server.getPostOffice()
                                                                     .getPagingManager()
                                                                     .getPageStore(PagingTest.ADDRESS);

            // Worse scenario possible... only schedule what's on pages
            if (store.getCurrentPage() != null)
            {
               message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, scheduledTime);
            }

            producer.send(message);
         }

         if (restart)
         {
            session.close();
View Full Code Here

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession session = sf.createSession(null, null, false, false, true, false, 0);

         session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);

         ClientProducer producer = session.createProducer(PagingTest.ADDRESS);

         ClientMessage message = null;

         for (int i = 0; i < numberOfMessages; i++)
         {
            message = session.createMessage(true);

            HornetQBuffer bodyLocal = message.getBodyBuffer();

            for (int j = 1; j <= numberOfIntegers; j++)
            {
               bodyLocal.writeInt(j);
            }

            message.putIntProperty(new SimpleString("id"), i);

            producer.send(message);
         }

         session.rollback();

         ClientConsumer consumer = session.createConsumer(PagingTest.ADDRESS);
View Full Code Here

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession session = sf.createSession(null, null, false, false, false, false, 0);

         session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);

         ClientProducer producer = session.createProducer(PagingTest.ADDRESS);

         ClientMessage message = null;

         for (int i = 0; i < numberOfMessages; i++)
         {
            message = session.createMessage(true);

            HornetQBuffer bodyLocal = message.getBodyBuffer();

            for (int j = 1; j <= numberOfIntegers; j++)
            {
               bodyLocal.writeInt(j);
            }

            message.putIntProperty(new SimpleString("id"), i);

            producer.send(message);
         }

         session.commit();

         session.close();
View Full Code Here

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession session = sf.createSession(null, null, false, false, false, false, 0);

         session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);

         ClientProducer producer = session.createProducer(PagingTest.ADDRESS);

         ClientMessage message = null;

         for (int i = 0; i < numberOfMessages; i++)
         {
            message = session.createMessage(true);

            HornetQBuffer bodyLocal = message.getBodyBuffer();

            bodyLocal.writeBytes(new byte[1024]);

            message.putIntProperty(new SimpleString("id"), i);

            producer.send(message);
         }

         session.commit();

         session.close();
View Full Code Here

TOP

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

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.