Package org.mokai

Examples of org.mokai.Message


  @SuppressWarnings("rawtypes")
  private Collection<Message> createMessages(ResultSet rs) throws SQLException {
    Collection<Message> messages = new ArrayList<Message>();

    while (rs.next()) {
      Message message = new Message();

      message.setDirection(getMessageDirection());

      message.setId(rs.getLong("id"));
      message.setReference(rs.getString("reference"));
      message.setSource(rs.getString("source"));
      message.setDestination(rs.getString("destination"));
      message.setStatus(rs.getByte("status"));

      message.setProperty("to", rs.getString("smsc_to"));
      message.setProperty("from", rs.getString("smsc_from"));
      message.setProperty("text", rs.getString("smsc_text"));
      message.setProperty("sequenceNumber", rs.getInt("smsc_sequencenumber"));
      message.setProperty("messageId", rs.getString("smsc_messageid"));
      message.setProperty("commandStatus", rs.getInt("smsc_commandstatus"));
      message.setProperty("receiptStatus", rs.getString("smsc_receiptstatus"));
      message.setProperty("receiptTime", rs.getTimestamp("smsc_receipttime"));

      String jsonString = rs.getString("other");
      if (jsonString != null && !"".equals(jsonString)) {
        try {
          JSONObject json = new JSONObject(jsonString);

          Iterator iterator = json.keys();
          while (iterator.hasNext()) {
            String key = (String) iterator.next();
            message.setProperty(key, json.get(key));
          }

        } catch (JSONException e) {
          log.error("JSONException while retreiving string: " + jsonString + ": " + e.getMessage(), e);
        }
      }

      message.setCreationTime(rs.getTimestamp("creation_time"));
      message.setModificationTime(rs.getTimestamp("modification_time"));

      messages.add(message);
    }

    return messages;
View Full Code Here


* @author Alejandro Riveros Cruz <lariverosc@gmail.com>
*/
public class RabbitMqMessageConverter {

  public Message fromByteArray(AMQP.BasicProperties basicProperties, byte[] body) throws UnsupportedEncodingException {
    Message mokaiMessage = new Message();
    mokaiMessage.setProperty("body", new String(body, "UTF-8"));
    return mokaiMessage;
  }
View Full Code Here

    ConnectorService connectorService = buildConnectorService("test1", p1, a1, a2);

    TestRouter router = new TestRouter(Collections.singletonList(connectorService));

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "endpoint-test1");
  }
View Full Code Here

  @Test
  public void shouldReturnUnroutableUriIfEmptyConnectors() throws Exception {
    TestRouter router = new TestRouter(new ArrayList<ConnectorService>());

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "unroutable");
  }
View Full Code Here

    Acceptor a1 = buildAcceptor(true);
    ConnectorService connectorService = buildConnectorService("test1", c1, a1);

    TestRouter router = new TestRouter(Collections.singletonList(connectorService));

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "unroutable");
  }
View Full Code Here

    connectorServices.add(cs1);
    connectorServices.add(cs2);

    TestRouter router = new TestRouter(connectorServices);

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "endpoint-test1");
  }
View Full Code Here

    connectorServices.add(cs1);
    connectorServices.add(cs2);

    TestRouter router = new TestRouter(connectorServices);

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "endpoint-test2");
  }
View Full Code Here

    connectorServices.add(cs1);
    connectorServices.add(cs2);

    TestRouter router = new TestRouter(connectorServices);

    String endpointUri = router.route(new Message().withDestination("test2"));
    Assert.assertEquals(endpointUri, "endpoint-test2");
  }
View Full Code Here

  @Test
  public void shouldReturnUnroutableIfMsgDestinationNotFound() throws Exception {
    TestRouter router = new TestRouter(new ArrayList<ConnectorService>());

    String endpointUri = router.route(new Message().withDestination("test2"));
    Assert.assertEquals(endpointUri, "unroutable");
  }
View Full Code Here

    ConnectorService cs1 = buildConnectorService("test1", p1);
    connectorServices.add(cs1);

    TestRouter router = new TestRouter(connectorServices);

    String endpointUri = router.route(new Message().withDestination("test1"));
    Assert.assertEquals(endpointUri, "unroutable");
  }
View Full Code Here

TOP

Related Classes of org.mokai.Message

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.