Package org.mokai.persist

Examples of org.mokai.persist.MessageCriteria


      response.contentType("application/json; charset=UTF-8").print( jsonMessages.toString() );
    }
  }

  private Collection<Message> listMessages(Direction direction, String recipientKey, Value recipientValue, Value status, Value numRecords) {
    MessageCriteria criteria = new MessageCriteria()
      .direction(direction)
      .orderBy("id")
      .orderType(OrderType.DOWNWARDS)
      .numRecords( numRecords == null ? 2000 : numRecords.asInteger() );

    if (recipientValue != null) {
      criteria.addProperty(recipientKey, recipientValue.asString());
    }

    if (status != null) {
      List<Value> statusList = status.asList();
      for (Value s : statusList) {
        criteria.addStatus(s.asInteger().byteValue());
      }
    }

    return routingEngine.getMessageStore().list(criteria);
  }
View Full Code Here


    routingEngine.stop();
  }

  @ManagedAttribute(description="Number of messages that failed or are being retried.")
  public int getNumFailedMessages() {
    MessageCriteria criteria = new MessageCriteria()
      .addStatus(Message.STATUS_FAILED)
      .addStatus(Message.STATUS_RETRYING);

    return routingEngine.getMessageStore().list(criteria).size();
  }
View Full Code Here

    MessageStore messageStore = resourceRegistry.getResource(MessageStore.class);

    ProducerTemplate producer = camelContext.createProducerTemplate();

    MessageCriteria criteria = new MessageCriteria()
        .addStatus(Message.STATUS_FAILED)
        .orderBy("creation_time")
        .orderType(OrderType.UPWARDS);

    Collection<Message> messages = messageStore.list(criteria);
View Full Code Here

        log.warn("MessageStore is null: ignoring submit_sm response: " + response.submitSMResp.toString());
        return;
      }

      // try to find a message that matches the criteria
      MessageCriteria criteria = new MessageCriteria()
        .direction(context.getDirection())
        .addProperty("destination", context.getId())
        .addProperty("smsc_sequencenumber", response.submitSMResp.getSequenceNum());

      long startTime = new Date().getTime();
View Full Code Here

      String messageId = drMessage.getProperty("messageId", String.class);
      messageId = convertMessageId(messageId);
      String to = drMessage.getProperty("to", String.class);
      String from = drMessage.getProperty("from", String.class);

      MessageCriteria criteria = new MessageCriteria()
        .direction(context.getDirection())
        .addProperty("destination", context.getId())
        .addProperty("smsc_messageid", messageId);

      long startTime = new Date().getTime();
View Full Code Here

    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_CONNECTIONS);
    handler.updateMessagesStatus(conn, criteria, Message.STATUS_RETRYING);

    verify(outHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
View Full Code Here

    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_APPLICATIONS);
    handler.updateMessagesStatus(conn, criteria, Message.STATUS_RETRYING);

    verify(inHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
View Full Code Here

    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    handler.updateMessagesStatus(conn, new MessageCriteria(), Message.STATUS_RETRYING);

    verify(inHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
    verify(outHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
View Full Code Here

    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    handler.updateMessagesStatus(conn, new MessageCriteria().direction(Direction.UNKNOWN),
        Message.STATUS_RETRYING);

    verify(inHandler, never()).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
    verify(outHandler, never()).updateMessagesStatus(any(Connection.class),
View Full Code Here

      .thenReturn(Collections.singleton(new Message()));

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Collection<Message> message = handler.listMessages(conn, new MessageCriteria());
    Assert.assertEquals(2, message.size());
  }
View Full Code Here

TOP

Related Classes of org.mokai.persist.MessageCriteria

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.