Package javax.jms

Examples of javax.jms.TextMessage


      // priority.
      for (Enumeration e = messageVec.elements(); e.hasMoreElements();)
      {
        try
        {
          TextMessage message = mqCon.createTextMessage();
          message.setText((String) e.nextElement());
          qs.send(message);
        }
        catch (JMSException ex)
        {
          System.out.println("Exception gefangen!");
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;
      Date timestamp = new Date();

      Enumeration e = qb.getEnumeration();

      while (e.hasMoreElements())
      {
        message = (TextMessage) e.nextElement();
        timestamp.setTime(message.getJMSTimestamp());
        System.out.println(Constants.getDateFormat().format(timestamp)
            + " " + message.getText());
      }

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

      int messageCounter = 0;

      // Use a TextMessage object to receive a message containing a
      // java.lang.String
      // in read-only mode.
      TextMessage message = null;

      boolean messageFound = false;
      while (!messageFound && (messageCounter < numMessages))
      {
        try
        {
          // Use this method to receive the next message that arrives
          // within the specified timeout interval.
          // This call blocks until a message arrives, the timeout
          // expires,
          // or this message consumer is closed.
          message = (TextMessage) qr.receive(1000);

          if (message == null)
          {
            System.out.println("Keine Nachricht vorhanden!");
            messageFound = true;
          }
          else
          {
            messageCounter++;
            commitCounter++;
            System.out.println("Nachricht-Nr. " + messageCounter
                + " empfangen: " + message.getText());

            if (commitCounter == mCommitRate)
            {
              commitCounter = 0;
              mqCon.commit();
View Full Code Here

         log.info("initial update requested with no real initial data for '" + SpecificDefault.toString(slaveSessionNames) + "' and for replication '" + this.replPrefix + "'");

      // send the message for the status change
      if (initialFilesLocation != null) {
         // then we save it in a file but we must tell it is finished now
         TextMessage  endMsg = session.createTextMessage();
         endMsg.setText("INITIAL UPDATE WILL BE STORED UNDER '" + initialFilesLocation + "'");
         endMsg.setBooleanProperty(INITIAL_DATA_END, true);
         endMsg.setStringProperty(INITIAL_DATA_ID, dumpId);
         endMsg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
         producer.send(endMsg);
         endMsg = session.createTextMessage();
         endMsg.setText("INITIAL UPDATE WILL BE STORED UNDER '" + initialFilesLocation + "' (going to remote)");
         endMsg.setBooleanProperty(INITIAL_DATA_END_TO_REMOTE, true);
         endMsg.setStringProperty(INITIAL_DATA_ID, dumpId);
         endMsg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
         producer.send(endMsg);
      }
      sendInitialDataResponseOnly(slaveSessionNames, replManagerAddress, minKey, maxKey);
      if (replSourceEngine != null)
         replSourceEngine.sendEndOfTransitionMessage(info, session, initialFilesLocation, shortFilename, dumpId, producer);
View Full Code Here

        LingoInvocation invocation = new LingoInvocation("foo", new Class[0], new Object[0], new MethodMetadata(false));
        Message message = marshaller.createRequestMessage(requestor, invocation);

        assertTrue("Should have created a text message: " + message, message instanceof TextMessage);

        TextMessage textMessage = (TextMessage) message;
        String text = textMessage.getText();
        assertTrue("Should have created a valid string", text != null && text.length() > 0);

        System.out.println("XML is: ");
        System.out.println(text);
    }
View Full Code Here

         Session producerSession = connection.createSession(transacted, ackMode);
         MessageProducer publisher = producerSession.createProducer(this.topic);
         connection.start();

         for (int i=0; i < this.nmax; i++) {
            TextMessage msg = producerSession.createTextMessage();
            msg.setText("this is a " + type + " jms message nr. " + i);
            publisher.send(this.topic, msg);
         }
        
         if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
            for (int i=0; i < this.nmax; i++) {
View Full Code Here

         String topic = null;
         String sessionName = "hello/1";
         MessageProducer producer = session.createProducer(new XBDestination(topic, sessionName));
         // producer.setPriority(PriorityEnum.HIGH_PRIORITY.getInt());
         // producer.setDeliveryMode(DeliveryMode.PERSISTENT);
         TextMessage msg = session.createTextMessage();
         msg.setText("Hallo");
         producer.send(msg);
      }
      catch (Exception ex) {
         ex.printStackTrace();
      }
View Full Code Here

        requestor.oneWay(null, session.createTextMessage("bonson"), 1);
        Thread.sleep(50);
        assertNull(receiver.receive(1));

        requestor.oneWay(null, session.createTextMessage("bonson2"), -1);
        TextMessage message = (TextMessage) receiver.receive(1000);
        assertNotNull(message);
        assertEquals("bonson2", message.getText());
    }
View Full Code Here

        requestor.oneWay(null, session.createTextMessage("bonson"), 1);
        Thread.sleep(50);
        assertNull(receiver.receive(1));

        requestor.oneWay(null, session.createTextMessage("bonson2"), -1);
        TextMessage message = (TextMessage) receiver.receive(1000);
        assertNotNull(message);
        assertEquals("bonson2", message.getText());
    }
View Full Code Here

      String dumpId = "" + new Timestamp().getTimestamp();
      sendEndOfTransitionMessage(info, session, null, null, dumpId, producer);
   }
  
   public void sendEndOfTransitionMessage(I_Info info, XBSession session, String initialFilesLocation, String shortFilename, String dumpId, XBMessageProducer producer) throws JMSException {
      TextMessage  endMsg = session.createTextMessage();
      SqlInfo sqlInfo = new SqlInfo(info);
      SqlDescription description = new SqlDescription(info);

      description.setAttribute(END_OF_TRANSITION , "" + true);
      endMsg.setBooleanProperty(END_OF_TRANSITION , true);
      description.setAttribute(FILENAME_ATTR, shortFilename);
      endMsg.setStringProperty(FILENAME_ATTR, shortFilename);
      if (initialFilesLocation != null) {
         description.setAttribute(INITIAL_FILES_LOCATION, initialFilesLocation);
         endMsg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
         description.setAttribute(INITIAL_DATA_ID, dumpId);
         endMsg.setStringProperty(INITIAL_DATA_ID, dumpId);
      }
      sqlInfo.setDescription(description);
      endMsg.setText(sqlInfo.toXml(""));
      producer.send(endMsg);
   }
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.