Examples of MQConnection


Examples of net.sf.xbus.technical.mq.MQConnection

    {
      // Use the static MQConnection.newInstance() method to instantiate a
      // new
      // 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();
    }
    catch (Exception exc)
    {
      System.out.println("Exception gefangen");
      exc.printStackTrace();
View Full Code Here

Examples of net.sf.xbus.technical.mq.MQConnection

    {
      // Use the static MQConnection.newInstance() method to instantiate a
      // new connection
      // for messagequeues and creates a JMS QueueSender for the given
      // queue.
      MQConnection mqCon = MQConnection.getInstance();
      QueueSender qs = mqCon.getSender(new XBUSSystem(logQueuename));

      // Create a JMS-TextMessage for each element of the vector and send
      // this message to the queue.
      // Use the QueueSender's default delivery mode, timeToLive and
      // 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!");
          ex.printStackTrace();
          System.exit(1);
        }
      }

      mqCon.commit();
      mqCon.close();
    }
    catch (Exception exc)
    {
      System.out.println("Exception gefangen!");
      exc.printStackTrace();
View Full Code Here

Examples of net.sf.xbus.technical.mq.MQConnection

    {
      // Use the static MQConnection.newInstance() method to instantiate a
      // new
      // 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();
    }
    catch (Exception exc)
    {
      System.out.println("Exception gefangen");
      exc.printStackTrace();
View Full Code Here

Examples of net.sf.xbus.technical.mq.MQConnection

      // Use the static MQConnection.newInstance() method to instantiate a
      // new connection
      // for messagequeues and creates a JMS QueueReceiver for the given
      // queue.
      MQConnection mqCon = MQConnection.getInstance();
      QueueReceiver qr = mqCon.getReceiver(new XBUSSystem(logQueuename));

      int commitCounter = 0;
      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();
            }
          }
        }
        catch (Exception exc)
        {
          System.out.println("Exception gefangen!");
          exc.printStackTrace();
          mqCon.rollback();
          continue;
        }
      }

      mqCon.commit();
      mqCon.close();
    }
    catch (Exception exc)
    {
      System.out.println("Exception gefangen!");
      exc.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.