@Override protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception { String request = packet.content().toString(CharsetUtil.UTF_8); if (logger.isDebugEnabled()) logger.debug("Sender " + packet.sender() + " sent request:" + request); if (!sessionList.inverse().containsKey(packet.sender())) { String session = UUID.randomUUID().toString(); String localAddress = ctx.channel().localAddress().toString(); String remoteAddress = ctx.channel().remoteAddress().toString(); SubscriptionManagerFactory.getInstance() .add(session, session, outputType, localAddress, remoteAddress); sessionList.put(session, packet.sender()); if (logger.isDebugEnabled()) logger.debug("Added Sender " + packet.sender() + ", session:" + session); ctx.channel() .writeAndFlush( new DatagramPacket( Unpooled.copiedBuffer( Util.getWelcomeMsg().toString() + "\r\n", CharsetUtil.UTF_8), packet.sender())); } Map<String, Object> headers = getHeaders(sessionList.inverse().get(packet.sender())); producer.sendBodyAndHeaders(request, headers); }
public static RouteManager getInstance() throws FileNotFoundException, IOException { Util.getConfig(); if (manager == null) { manager = new RouteManager(); // must do this early! CamelContextFactory.setContext(manager); } return manager; }
/** * Returns an env setup with the test config. * * @return * @throws FileNotFoundException * @throws IOException */ public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException { SignalKModel model = SignalKModelFactory.getMotuTestInstance(); Util.setConfig(model); if (manager == null) { manager = new RouteManager(); // must do this early! CamelContextFactory.setContext(manager); } return manager; }