public static boolean getIsAlert(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.IS_ALERT)) {
      return false;
    }

    return message.getBooleanProperty(MessagePropertyNames.IS_ALERT);
  }
示例#2
0
  public Object fromMessage(Message msg) throws JMSException, MessageConversionException {
    log.debug("--OperationlogMsgConverter fromMessage--");
    if (!(msg instanceof MapMessage)) {
      throw new MessageConversionException("Message isn't a MapMessage");
    }

    if ((msg == null) || (msg.getBooleanProperty("NullMessage"))) {
      return null;
    }

    MapMessage mapMessage = (MapMessage) msg;
    OperationLog optLog = new OperationLog();
    @SuppressWarnings("unused")
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    optLog.setMainType(Integer.valueOf(mapMessage.getInt("mainType")));
    optLog.setMinorType(Integer.valueOf(mapMessage.getInt("minorType")));
    optLog.setCtrlUnitId(Integer.valueOf(mapMessage.getInt("ctrlUnitId")));
    optLog.setUserId(Integer.valueOf(mapMessage.getInt("userId")));

    optLog.setTriggerTime(Calendar.getInstance().getTime());

    optLog.setResourceId(Integer.valueOf(mapMessage.getInt("resourceId")));
    try {
      if (mapMessage.getString("logTxt") == null) {
        return null;
      }
      optLog.setLogTxt(new String(mapMessage.getString("logTxt").getBytes("ISO-8859-1"), "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      log.error(e.getMessage());
    }

    return optLog;
  }
  /**
   * Get property
   *
   * @param name The name
   * @return The value
   * @throws JMSException Thrown if an error occurs
   */
  @Override
  public boolean getBooleanProperty(final String name) throws JMSException {
    if (ActiveMQRAMessage.trace) {
      ActiveMQRALogger.LOGGER.trace("getBooleanProperty(" + name + ")");
    }

    return message.getBooleanProperty(name);
  }
 /**
  * Test that an attempt to get a <code>boolean</code> property which does not exist returns <code>
  * false</code>
  */
 @Test
 public void testGetBooleanProperty() {
   try {
     Message message = senderSession.createMessage();
     Assert.assertEquals(false, message.getBooleanProperty("prop"));
   } catch (JMSException e) {
     fail(e);
   }
 }
    @Override
    public void run() {

      try {
        startSignal.await();
        log.info(workerName);
        Session sess = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        MessageConsumer consumer = sess.createConsumer(queueName);
        workerStarted.countDown();

        while (true) {
          if (counters[0] == 0 && counters[1] == 0 && counters[2] == 0) {
            doneSignal.countDown();
            log.info(workerName + " done...");
            break;
          }

          Message msg = consumer.receive(500);
          if (msg == null) continue;

          msg.acknowledge();

          String group = msg.getStringProperty("JMSXGroupID");
          msg.getBooleanProperty("JMSXGroupFirstForConsumer");

          if ("A".equals(group)) {
            --counters[0];
            update(group);
          } else if ("B".equals(group)) {
            --counters[1];
            update(group);
          } else if ("C".equals(group)) {
            --counters[2];
            update(group);
          } else {
            log.warn(workerName + ", unknown group");
          }
          if (counters[0] != 0 || counters[1] != 0 || counters[2] != 0) {
            msg.acknowledge();
          }
        }
        consumer.close();
        sess.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }