Package org.mokai.persist

Examples of org.mokai.persist.MessageStore


  @Test
  public void testToConnectionsMessageFlow() throws Exception {
    final CyclicBarrier barrier = new CyclicBarrier(2);

    // a custom message store
    MessageStore messageStore = new MockMessageStore(barrier, Message.STATUS_PROCESSED);

    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      routingEngine.setMessageStore(messageStore);
View Full Code Here


  @Test
  public void testToApplicationsMessageFlow() throws Exception {
    final CyclicBarrier barrier = new CyclicBarrier(2);

    // a custom message store
    MessageStore messageStore = new MockMessageStore(barrier, Message.STATUS_PROCESSED);

    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      routingEngine.setMessageStore(messageStore);
View Full Code Here

  @Test
  public void testUnroutableConnections() throws Exception {
    final CyclicBarrier barrier = new CyclicBarrier(2);

    // a custom message store
    MessageStore messageStore = new MockMessageStore(barrier, Message.STATUS_UNROUTABLE);

    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      routingEngine.setMessageStore(messageStore);
View Full Code Here

  @Test
  public void testUnroutableApplications() throws Exception {
    final CyclicBarrier barrier = new CyclicBarrier(2);

    // a custom message store
    MessageStore messageStore = new MockMessageStore(barrier, Message.STATUS_UNROUTABLE);

    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      routingEngine.setMessageStore(messageStore);
View Full Code Here

    Message m2 = new Message();
    m2.setStatus(Message.STATUS_FAILED);
    m2.setDirection(Direction.TO_APPLICATIONS);
    failedMessages.add(m2);

    MessageStore messageStore = mock(MessageStore.class);
    when(messageStore.list(any(MessageCriteria.class))).thenReturn(failedMessages);

    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      routingEngine.setMessageStore(messageStore);
View Full Code Here

    // create a default redelivery policy and add it to the resource registry
    RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    resourceRegistry.putResource(RedeliveryPolicy.class, redeliveryPolicy);

    // create a default message store and add it to the registry
    MessageStore messageStore = new DefaultMessageStore();
    resourceRegistry.putResource(MessageStore.class, messageStore);

    camelContext = new DefaultCamelContext();
    resourceRegistry.putResource(CamelContext.class, camelContext);
View Full Code Here

  public final void retryFailedMessages() {
    log.trace("retrying failed messages ... ");

    long startTime = new Date().getTime();

    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);
    logCollectionSize(messages.size()); // log the size of the collection
    for (Message message : messages) {
      // update the message and send it
      message.setStatus(Message.STATUS_RETRYING);
      message.setModificationTime(new Date());
      messageStore.saveOrUpdate(message);

      if (message.getDirection().equals(Direction.TO_CONNECTIONS)) {
        producer.sendBody(UriConstants.CONNECTIONS_ROUTER, ExchangePattern.InOnly, message);
      } else if (message.getDirection().equals(Direction.TO_APPLICATIONS)) {
        producer.sendBody(UriConstants.APPLICATIONS_ROUTER, ExchangePattern.InOnly, message);
View Full Code Here

  @Override
  public final void process(Exchange exchange) throws Exception {
    Message message = (Message) exchange.getIn().getBody(Message.class);

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

      boolean insert = message.getId() == null;

      long startTime = new Date().getTime();
      messageStore.saveOrUpdate(message);
      long endTime = new Date().getTime();

      if (insert) {
        log.trace("insert message with id " + message.getId() + " took " + (endTime - startTime) + " milis");
      } else {
View Full Code Here

      }

    });
    server.setPacketProcessor(pp);

    MessageStore messageStore = Mockito.mock(MessageStore.class);

    Message m = new Message();
    m.setProperty("to", "3002175604");
    m.setProperty("from", "3542");

    Mockito.when(messageStore.list(Mockito.any(MessageCriteria.class)))
        .thenReturn(Collections.singletonList(m));

    SmppConfiguration configuration = new SmppConfiguration();
    configuration.setHost("localhost");
    configuration.setPort(SERVER_PORT);
View Full Code Here

      }

    });
    server.setPacketProcessor(pp);

    MessageStore messageStore = Mockito.mock(MessageStore.class);

    SmppConfiguration configuration = new SmppConfiguration();
    configuration.setHost("localhost");
    configuration.setPort(SERVER_PORT);
    configuration.setSystemId("test");
View Full Code Here

TOP

Related Classes of org.mokai.persist.MessageStore

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.