public static String getCharsetFromContentType(String contentType) { if (contentType != null) { // find the charset and set it to the Exchange int index = contentType.indexOf("charset="); if (index > 0) { String charset = contentType.substring(index + 8); // there may be another parameter after a semi colon, so skip that if (charset.contains(";")) { charset = StringHelper.before(charset, ";"); } return IOHelper.normalizeCharset(charset); } } return null; }
public static String getCharsetFromContentType(String contentType) { if (contentType != null) { // find the charset and set it to the Exchange int index = contentType.indexOf("charset="); if (index > 0) { String charset = contentType.substring(index + 8); // there may be another parameter after a semi colon, so skip that if (charset.contains(";")) { charset = StringHelper.before(charset, ";"); } return IOHelper.normalizeCharset(charset); } } return null; }
protected void updateCharactorEncodingInfo(Exchange exchange) { if (exchange.getProperty(Exchange.CHARSET_NAME) == null && encoding != null) { exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(encoding)); } }
charset = IOHelper.normalizeCharset(charset); if (charset != null) { boolean supported;
@Override protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { Object in = msg; if (LOG.isDebugEnabled()) { LOG.debug("Channel: {} received body: {}", ctx.channel(), in); } // create Exchange and let the consumer process it final Exchange exchange = consumer.getEndpoint().createExchange(ctx, msg); if (consumer.getConfiguration().isSync()) { exchange.setPattern(ExchangePattern.InOut); } // set the exchange charset property for converting if (consumer.getConfiguration().getCharsetName() != null) { exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(consumer.getConfiguration().getCharsetName())); } if (consumer.getConfiguration().isReuseChannel()) { exchange.setProperty(NettyConstants.NETTY_CHANNEL, ctx.channel()); } // we want to handle the UoW consumer.createUoW(exchange); beforeProcess(exchange, ctx, msg); // process accordingly to endpoint configuration if (consumer.getEndpoint().isSynchronous()) { processSynchronously(exchange, ctx, msg); } else { processAsynchronously(exchange, ctx, msg); } }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent messageEvent) throws Exception { Object in = messageEvent.getMessage(); if (LOG.isDebugEnabled()) { LOG.debug("Channel: {} received body: {}", messageEvent.getChannel(), in); } // create Exchange and let the consumer process it final Exchange exchange = consumer.getEndpoint().createExchange(ctx, messageEvent); if (consumer.getConfiguration().isSync()) { exchange.setPattern(ExchangePattern.InOut); } // set the exchange charset property for converting if (consumer.getConfiguration().getCharsetName() != null) { exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(consumer.getConfiguration().getCharsetName())); } // we want to handle the UoW consumer.createUoW(exchange); beforeProcess(exchange, messageEvent); // process accordingly to endpoint configuration if (consumer.getEndpoint().isSynchronous()) { processSynchronously(exchange, messageEvent); } else { processAsynchronously(exchange, messageEvent); } }
exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(getConfiguration().getCharsetName()));
exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(getConfiguration().getCharsetName()));