コード例 #1
0
  public Boolean isExternalRedelivered() {
    Boolean answer = null;

    // check property first, as the implementation details to know if the message
    // was externally redelivered is message specific, and thus the message implementation
    // could potentially change during routing, and therefore later we may not know if the
    // original message was externally redelivered or not, therefore we store this detail
    // as a exchange property to keep it around for the lifecycle of the exchange
    if (hasProperties()) {
      answer = getProperty(Exchange.EXTERNAL_REDELIVERED, null, Boolean.class);
    }

    if (answer == null) {
      // lets avoid adding methods to the Message API, so we use the
      // DefaultMessage to allow component specific messages to extend
      // and implement the isExternalRedelivered method.
      DefaultMessage msg = getIn(DefaultMessage.class);
      if (msg != null) {
        answer = msg.isTransactedRedelivered();
        // store as property to keep around
        setProperty(Exchange.EXTERNAL_REDELIVERED, answer);
      }
    }

    return answer;
  }
コード例 #2
0
 @Test
 public void testContentOverload() {
   DefaultMessage message = new DefaultMessage();
   String str = "xxxxxxx";
   String yyy = "yyyyyyy";
   message.setContent(String.class, str);
   message.setContent(String.class, yyy);
   assertSame(yyy, message.getContent(String.class));
 }
コード例 #3
0
 @Test
 public void testContents() {
   DefaultMessage message = new DefaultMessage();
   String str = "xxxxxxx";
   message.setContent(String.class, str);
   message.setContent(Integer.class, new Integer(12));
   assertSame(str, message.getContent(String.class));
   assertNotNull(message.getContent(Integer.class));
   message.removeContent(String.class);
   assertNull(message.getContent(String.class));
 }
コード例 #4
0
  @Test
  public void testNoCancel() {
    Description pd = getSellerProtocol();

    // Create Protocol Monitor
    ProtocolMonitor monitor = new DefaultProtocolMonitor();

    DefaultMonitorContext context = new DefaultMonitorContext();

    DefaultSession conv = new DefaultSession();
    monitor.initialize(context, pd, conv);

    DefaultMessage message = new DefaultMessage();
    message.getTypes().add(ORDER_MESSAGE_TYPE);

    if (monitor.messageReceived(context, pd, conv, null, message).isValid() == false) {
      fail("Order failed");
    }

    message = new DefaultMessage();
    message.getTypes().add(CONFIRMATION_MESSAGE_TYPE);

    if (monitor.messageSent(context, pd, conv, null, message).isValid() == false) {
      fail("Confirmation failed");
    }

    message = new DefaultMessage();
    message.getTypes().add(FINISH_MESSAGE_TYPE);

    if (monitor.messageReceived(context, pd, conv, null, message).isValid() == false) {
      fail("Finish message failed");
    }

    if (conv.isFinished() == false) {
      fail("Conversation should be finished");
    }
  }
コード例 #5
0
  @Test
  public void performansTest() {
    DefaultMessage message = new DefaultMessage();
    long mark = System.currentTimeMillis();
    for (int i = 0; i < 1000; i++) {
      //            DefaultMessage MSG = new DefaultMessage();
      //            String str="xxxxxxx";
      //            MSG.setContent(String.class, str);
    }
    System.out.println(System.currentTimeMillis() - mark);
    mark = System.currentTimeMillis();
    for (int i = 0; i < 1000; i++) {
      String str = "xxxxxxx";
      message.put(String.class, str);
    }
    System.out.println(System.currentTimeMillis() - mark);

    mark = System.currentTimeMillis();
    for (int i = 0; i < 1000; i++) {
      long l = 182l;
      message.setId(l);
    }
    System.out.println(System.currentTimeMillis() - mark);
  }