@Test public void testConsume() throws Exception { DefaultCMessagingConfigService s = createServiceWithXml("consume_both.xml"); assertEquals(CMessagingConfigService.CONSUME_FROM_CMESSAGING, s.getConsumerType("ex1", "cid0", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_CMESSAGING, s.getConsumerType("ex1", "cid1", "1.1.1.3")); assertEquals(CMessagingConfigService.CONSUME_FROM_CMESSAGING, s.getConsumerType("ex1", "unknown", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_CMESSAGING, s.getConsumerType("ex2", "unknown", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_CMESSAGING, s.getConsumerType("ex10", "unknown", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_BOTH, s.getConsumerType("ex1", "cid1", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_BOTH, s.getConsumerType("ex1", "cid1", "1.1.1.2")); assertEquals(CMessagingConfigService.CONSUME_FROM_BOTH, s.getConsumerType("ex1", "cid2", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_BOTH, s.getConsumerType("ex1", "cid2", "1.1.1.3")); assertEquals(CMessagingConfigService.CONSUME_FROM_BOTH, s.getConsumerType("ex3", "unknown", "1.1.1.3")); assertEquals(CMessagingConfigService.CONSUME_FROM_HERMES, s.getConsumerType("ex1", "cid3", "1.1.1.1")); assertEquals(CMessagingConfigService.CONSUME_FROM_HERMES, s.getConsumerType("ex1", "cid3", "1.1.1.3")); assertEquals(CMessagingConfigService.CONSUME_FROM_HERMES, s.getConsumerType("ex4", "cid1", "1.1.1.3")); }
@Override public int getConsumerType(String exchangeName, String identifier, String ip) { Exchange exchange = findExchange(exchangeName); if (exchange == null || exchange.getConsume() == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(exchange.getConsume().getState())) { ConsumeGroup group = exchange.getConsume().findConsumeGroup(identifier); if (group == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(group.getState())) { Node node = group.findNode(ip); if (node == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { return CMessagingConfigService.CONSUME_FROM_BOTH; } } else { return nonGrayConsumeStateToInt(group.getState()); } } } else { return nonGrayConsumeStateToInt(exchange.getConsume().getState()); } } }
DefaultCMessagingConfigService implements CMessagingConfigService, Initializable { @Override public int getConsumerType(String exchangeName, String identifier, String ip) { Exchange exchange = findExchange(exchangeName); if (exchange == null || exchange.getConsume() == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(exchange.getConsume().getState())) { ConsumeGroup group = exchange.getConsume().findConsumeGroup(identifier); if (group == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(group.getState())) { Node node = group.findNode(ip); if (node == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { return CMessagingConfigService.CONSUME_FROM_BOTH; } } else { return nonGrayConsumeStateToInt(group.getState()); } } } else { return nonGrayConsumeStateToInt(exchange.getConsume().getState()); } } } }
DefaultCMessagingConfigService implements CMessagingConfigService, Initializable { @Override public int getConsumerType(String exchangeName, String identifier, String ip) { Exchange exchange = findExchange(exchangeName); if (exchange == null || exchange.getConsume() == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(exchange.getConsume().getState())) { ConsumeGroup group = exchange.getConsume().findConsumeGroup(identifier); if (group == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(group.getState())) { Node node = group.findNode(ip); if (node == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { return CMessagingConfigService.CONSUME_FROM_BOTH; } } else { return nonGrayConsumeStateToInt(group.getState()); } } } else { return nonGrayConsumeStateToInt(exchange.getConsume().getState()); } } }  }
DefaultCMessagingConfigService implements CMessagingConfigService, Initializable { @Override public int getConsumerType(String exchangeName, String identifier, String ip) { Exchange exchange = findExchange(exchangeName); if (exchange == null || exchange.getConsume() == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(exchange.getConsume().getState())) { ConsumeGroup group = exchange.getConsume().findConsumeGroup(identifier); if (group == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(group.getState())) { Node node = group.findNode(ip); if (node == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { return CMessagingConfigService.CONSUME_FROM_BOTH; } } else { return nonGrayConsumeStateToInt(group.getState()); } } } else { return nonGrayConsumeStateToInt(exchange.getConsume().getState()); } } }  @Override String getTopic(String exchangeName); @Override String getGroupId(String exchangeName, String idAndQueueName); @Override boolean isHermesProducerEnabled(String exchangeName, String identifier, String ip); @Override int getConsumerType(String exchangeName, String identifier, String ip); @Override void initialize(); }
DefaultCMessagingConfigService implements CMessagingConfigService, Initializable { @Override public int getConsumerType(String exchangeName, String identifier, String ip) { Exchange exchange = findExchange(exchangeName); if (exchange == null || exchange.getConsume() == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(exchange.getConsume().getState())) { ConsumeGroup group = exchange.getConsume().findConsumeGroup(identifier); if (group == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { if (Consume.GRAY.equalsIgnoreCase(group.getState())) { Node node = group.findNode(ip); if (node == null) { return CMessagingConfigService.CONSUME_FROM_CMESSAGING; } else { return CMessagingConfigService.CONSUME_FROM_BOTH; } } else { return nonGrayConsumeStateToInt(group.getState()); } } } else { return nonGrayConsumeStateToInt(exchange.getConsume().getState()); } } }  @Override String getTopic(String exchangeName); @Override String getGroupId(String exchangeName, String idAndQueueName); @Override boolean isHermesProducerEnabled(String exchangeName, String identifier, String ip); @Override int getConsumerType(String exchangeName, String identifier, String ip); @Override void initialize();  }