Package org.hornetq.api.core.client

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


  public void run() {
    try {
      start();
      while (running) {
        ClientMessage clientMessage = consumer.receive();
        if (clientMessage!=null) {
          Object object = readMessage(clientMessage);
          String clientId = clientMessage.getStringProperty("producerId");
          handler.messageReceived(session, object, clientId);
        }
      }
    }
    catch (HornetQException e) {
View Full Code Here


    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oout;
    try {
      oout = new ObjectOutputStream(baos);
      oout.writeObject(message);
      ClientMessage clientMessage = session.createMessage(true);
      clientMessage.getBodyBuffer().writeBytes(baos.toByteArray());
      producer.send(clientMessage);
    } catch (IOException e) {
      throw new IOException("Error creating message");
    } catch (HornetQException e) {
      throw new IOException("Unable to create message");
View Full Code Here

        public void run() {
          try {
            consumer = session.createConsumer(name);
            while (true) {
              ClientMessage serverMessage = consumer.receive();
              if (serverMessage!=null) {
                ((HornetQTaskClientHandler)handler).messageReceived(session, readMessage(serverMessage), BaseHornetQTaskServer.SERVER_TASK_COMMANDS_QUEUE);
              }
            }
          }
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oout;
    try {
      oout = new ObjectOutputStream(baos);
      oout.writeObject(object);
      ClientMessage message = session.createMessage(true);
      message.getBodyBuffer().writeBytes(baos.toByteArray());
      message.putStringProperty("producerId", name);
      producer.send(message);
    } catch (IOException e) {
      throw new RuntimeException("Error creating message", e);
    } catch (HornetQException e) {
      throw new RuntimeException("Error writing message", e);
View Full Code Here

            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());
               System.out.println("Sending the message.");

               producer.send(message);

               ClientConsumer messageConsumer = session.createConsumer(queueName);
               session.start();

               ClientMessage messageReceived = messageConsumer.receive(1000);
               System.out.println("Received TextMessage:" + messageReceived.getStringProperty(propName));
            } finally {
               if (session != null) {
                  session.close();
               }
            }
View Full Code Here

                @Override
                public void run() {
                    while (!shutdown.get()) {
                        try {
                            ClientMessage message = consumer.receive(500);
                            if (message == null) {
                                continue;
                            }
                            String s = message.getStringProperty(BODY);
                            log.info("-----> Received: " + s);
                            synchronized (receivedMessages) {
                                receivedMessages.add(s);
                            }
                        } catch (HornetQException e) {
View Full Code Here

    }

    public void sendMessage(String txt) throws Exception {
        System.out.println("-----> Attempting to send message");
        ClientProducer producer = session.createProducer(QUEUE_EXAMPLE_QUEUE);
        ClientMessage message = session.createMessage(false);

        message.putStringProperty(BODY, "'" + txt + "' sent at " + new Date());
        System.out.println("-----> Sending message");
        producer.send(message);
    }
View Full Code Here

         notifConsumer.setMessageHandler(flowRecord);

         session.start();

         ClientMessage message = session.createMessage(false);
         if (HornetQServerLogger.LOGGER.isTraceEnabled())
         {
            HornetQServerLogger.LOGGER.trace("Requesting sendQueueInfoToQueue through " + this, new Exception("trace"));
         }
         ManagementHelper.putOperationInvocation(message,
View Full Code Here

      QueueControl queueControl = createManagementControl(address, queue);
      Assert.assertEquals(0, queueControl.getScheduledCount());

      ClientProducer producer = session.createProducer(address);
      ClientMessage message = session.createMessage(false);
      message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
      producer.send(message);

      long timeout = System.currentTimeMillis() + 5000;
      while (timeout > System.currentTimeMillis() && queueControl.getScheduledCount() != 1)
      {
View Full Code Here

      session.createQueue(address, queue, null, false);

      QueueControl queueControl = createManagementControl(address, queue);

      ClientProducer producer = session.createProducer(address);
      ClientMessage message = session.createMessage(false);
      message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
      message.putIntProperty(new SimpleString("key"), intValue);
      producer.send(message);
      // unscheduled message
      producer.send(session.createMessage(false));

      Map<String, Object>[] messages = queueControl.listScheduledMessages();
View Full Code Here

TOP

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

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.