SimpleRoutingStrategy implements RoutingStrategy.Router { @Override public ContainerAddress selectDestinationForMessage(final KeyedMessageWithType message) { if(!isRunning.get()) throw new IllegalStateException( "attempt to use " + SimpleRoutingStrategy.class.getSimpleName() + " prior to starting it or after stopping it."); return address.get(); } SimpleRoutingStrategy(final SimpleRoutingStrategyFactory mom, final ClusterId clusterId, final Infrastructure infra); @Override ContainerAddress selectDestinationForMessage(final KeyedMessageWithType message); @Override Collection<ContainerAddress> allDesintations(); @Override void release();  }
@Test public void testInboundWithOutbound() throws Exception { final Manager<RoutingStrategy.Inbound> manager = new Manager<>(RoutingStrategy.Inbound.class); try (final RoutingStrategy.Inbound ib = manager.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName());) { assertNotNull(ib); assertTrue(SimpleInboundSide.class.isAssignableFrom(ib.getClass())); final ClusterId cid = new ClusterId("test", "test"); ib.setContainerDetails(cid, new ContainerAddress(new DummyNodeAddress("here"), 0), (l, m) -> {}); ib.start(infra); assertTrue(waitForReg(session)); try (final ClusterInfoSession ses2 = sessFact.createSession()) { try (final RoutingStrategyManager obman = chain(new RoutingStrategyManager(), o -> o.start(makeInfra(ses2, sched))); final RoutingStrategy.Factory obf = obman.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName());) { obf.start(makeInfra(ses2, sched)); final RoutingStrategy.Router ob = obf.getStrategy(cid); final KeyedMessageWithType km = new KeyedMessageWithType(null, null, ""); assertTrue(poll(o -> ob.selectDestinationForMessage(km) != null)); final ContainerAddress ca = ob.selectDestinationForMessage(km); assertNotNull(ca); assertEquals("here", ((DummyNodeAddress) ca.node).name); session.close(); assertTrue(poll(o -> ob.selectDestinationForMessage(km) == null)); try (ClusterInfoSession ses3 = sessFact.createSession(); RoutingStrategy.Inbound ib2 = manager.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName())) { ib2.setContainerDetails(cid, ca, (l, m) -> {}); ib2.start(makeInfra(ses3, sched)); assertTrue(poll(o -> ob.selectDestinationForMessage(km) != null)); } } } } }