@Override public void declareBehavior(GreenRuntime runtime) { runtime.addStartupListener(new KickoffBehavior(runtime, target)); runtime.addPubSubListener(new GenerateBehavior(runtime, "Count", target, seed)) .addSubscription("Next"); CountBehavior counter = new CountBehavior(runtime, "Next"); runtime.registerListener(counter) .addSubscription("Count", counter::triggerNextAndCount) .addSubscription("AnExample", counter::anotherMessage); }
@Override public void declareBehavior(GreenRuntime runtime) { runtime.addRestListener(new ExternalRequest(runtime, session, "/service", HANDOFF_TOPIC)) .includeRoutesByAssoc(Struct.PROXY_ROUTE); runtime.addPubSubListener(new ExternalResponse(runtime)) .acceptHostResponses(session) .addSubscription(HANDOFF_TOPIC); runtime.addRestListener(new InternalService(runtime)) .includeRoutesByAssoc(Struct.SERIVCE_ROUTE); }
@Override public void declareBehavior(GreenRuntime runtime) { ProductsBehavior listener = new ProductsBehavior(runtime, maxProductId, BEGIN_TOPIC, server); runtime.registerListener(listener) .includeRoutes(Struct.PRODUCT_UPDATE, listener::productUpdate) .includeRoutes(Struct.ALL_PRODUCTS, listener::productAll) .includeRoutes(Struct.PRODUCT_QUERY, listener::productQuery); int threads = 40; runtime.registerBlockingListener(new BlockingProducer(dbURL), Field.CONNECTION, threads, BEGIN_TOPIC, FINISHED_TOPIC); runtime.addPubSubListener(new RestResponder(runtime)).addSubscription(FINISHED_TOPIC); runtime.addResourceServer("/site","index.html").includeRoutesByAssoc(Struct.STATIC_PAGES); }
@Override public void declareBehavior(GreenRuntime runtime) { HTTPGetBehaviorSingle temp = new HTTPGetBehaviorSingle(runtime, session1); runtime.addResponseListener(new HTTPResponse(console)).acceptHostResponses(session2); runtime.addStartupListener(new HTTPGetBehaviorChained(runtime, session2)); runtime.addStartupListener("startupBehavior",temp) .acceptHostResponses(session1) //this line is required to use JSON extraction even to self behavior as consumer .addSubscription("next"); runtime.addPubSubListener("shutdownBehavior",new ShutdownBehavior(runtime)).addSubscription("shutdown"); }