Package javax.jms

Examples of javax.jms.TextMessage


      ictx.close();

      QueueConnection qc = qcf.createQueueConnection();
      QueueSession qs = qc.createQueueSession(true, 0);
      QueueSender qsend = qs.createSender(queue);
      TextMessage msg = qs.createTextMessage();

      qc.start();
      int i;
      for (i = 0; i < 10; i++) {
        msg.setText("Test number " + i);
        qsend.send(msg);
      }

      qs.commit();
      System.out.println(i + " messages sent.");
View Full Code Here


    Session qSess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);

    MessageConsumer qConsumer = qSess.createConsumer(queue);
    cnx.start();

    TextMessage msg;

    for (int i = 0; i < 10; i++) {
      msg = (TextMessage) qConsumer.receive();
      System.out.println("Message received from queue: " + msg.getText());
    }

    cnx.close();
  }
View Full Code Here

    MessageProducer producer = sess.createProducer(topic);

    System.out.println("Produces 5 messages on the MailTopic.");

    for (int i=0; i<5; i++) {
      TextMessage msg = sess.createTextMessage();
      msg.setBooleanProperty("showProperties", false);
      msg.setText("Queue : Test number #" + i);
      producer.send(msg);
    }
    sess.commit();

    System.out.println("Messages sent.");
View Full Code Here

  }

  /* Receive message from topic subscriber */
  public void onMessage(Message message) {
    try {
      TextMessage textMessage = (TextMessage) message;
      String text = textMessage.getText( );
      System.out.println(textMessage.getStringProperty("User") + ": " + text);
    } catch (JMSException jmse) {
      jmse.printStackTrace( );
    }
  }
View Full Code Here

    }
  }

  /* Create and send message using topic publisher */
  protected void writeMessage(String text) throws JMSException {
    TextMessage message = pubSession.createTextMessage( );
    message.setText(text);
    message.setStringProperty("User", userName);
    publisher.send(message);
  }
View Full Code Here

    * Publish the given String as a JMS message to the testTopic topic.
    */
   public void publish(String msg) throws JMSException {

      // Create a message
      TextMessage message = topicSession.createTextMessage();
      message.setText(msg);

      // Publish the message
      topicPublisher.publish(topic, message);
   }
View Full Code Here

    try {
      Element eResult = (Element)aResult.buildOutputFromObject();
      eControlArea.addContent(eResult);
      syncErrorDoc.getRootElement().removeContent(eControlArea);
      syncErrorDoc.getRootElement().addContent(eControlArea);
      TextMessage syncErrorMessage = getSyncErrorPublisher().createTextMessage();
      XMLOutputter xmlOut = new XMLOutputter();
      syncErrorMessage.setText(xmlOut.outputString(syncErrorDoc));
      if (getSyncErrorPublisher().getDefaultCommandName().length() == 0 ||
        getSyncErrorPublisher().getDefaultCommandName() == null) {
        getSyncErrorPublisher().setDefaultCommandName("EnterpriseSyncErrorSync");
      }
      syncErrorMessage.setStringProperty(MessageProducer.MESSAGE_ID,msgId.toString());
      syncErrorMessage.setStringProperty(MessageProducer.COMMAND_NAME,getSyncErrorPublisher().getDefaultCommandName());
        //TODO: change this...
//      getSyncErrorPublisher().publishMessage(syncErrorMessage);
    }
    catch (Exception e) {
      logger.fatal("Error publishing Sync-Error-Sync message!");
View Full Code Here

        return session.createTextMessage(xml);
    }

    public RemoteInvocationResult extractInvocationResult(Message message) throws JMSException {
        if (message instanceof TextMessage) {
            TextMessage textMessage = (TextMessage) message;
            String text = textMessage.getText();
            return (RemoteInvocationResult) fromXML(text);
        }
        return super.extractInvocationResult(message);
    }
View Full Code Here

        return super.extractInvocationResult(message);
    }

    public RemoteInvocation readRemoteInvocation(Message message) throws JMSException {
        if (message instanceof TextMessage) {
            TextMessage textMessage = (TextMessage) message;
            String text = textMessage.getText();
            return (RemoteInvocation) fromXML(text);
        }
        return super.readRemoteInvocation(message);
    }
View Full Code Here

      // connection for messagequeues and creates a JMS-QueueBrowser for
      // the given queue.
      MQConnection mqCon = MQConnection.getInstance();
      QueueBrowser qb = mqCon.getBrowser(new XBUSSystem(logQueuename));

      TextMessage message = null;

      Enumeration e = qb.getEnumeration();

      while (e.hasMoreElements())
      {
        message = (TextMessage) e.nextElement();
        System.out.print(message.getText());
        System.out.print(Constants.QUEUE_DUMP_DELIMITER);
      }

      mqCon.commit();
      mqCon.close();
View Full Code Here

TOP

Related Classes of javax.jms.TextMessage

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.