@Override
    public void handle(Message<?> message) {
      ServerMessage msg =
          new ServerMessageImpl(
              storageManager.generateID(), VertxConstants.INITIAL_MESSAGE_BUFFER_SIZE);
      msg.setAddress(new SimpleString(queueName));
      msg.setDurable(true);
      msg.encodeMessageIDToBuffer();

      String replyAddress = message.replyAddress();
      if (replyAddress != null) {
        msg.putStringProperty(VertxConstants.VERTX_MESSAGE_REPLYADDRESS, replyAddress);
      }

      // it'd be better that Message expose its type information
      int type = getMessageType(message);

      msg.putIntProperty(VertxConstants.VERTX_MESSAGE_TYPE, type);

      manualEncodeVertxMessageBody(msg.getBodyBuffer(), message.body(), type);

      try {
        postOffice.route(msg, null, false);
      } catch (Exception e) {
        ActiveMQVertxLogger.LOGGER.error("failed to route msg " + msg, e);
      }
    }
コード例 #2
0
  @Test
  public void testAMQDurable() throws Exception {
    filter = FilterImpl.createFilter(new SimpleString("AMQDurable='DURABLE'"));

    message.setDurable(true);

    Assert.assertTrue(filter.match(message));

    message.setDurable(false);

    Assert.assertFalse(filter.match(message));

    filter = FilterImpl.createFilter(new SimpleString("AMQDurable='NON_DURABLE'"));

    message = new ServerMessageImpl();
    message.setDurable(true);

    Assert.assertFalse(filter.match(message));

    message.setDurable(false);

    Assert.assertTrue(filter.match(message));
  }