Camel 2.14/Netty: How to add ByteArrayDecoder to ServerChannelPipeline?

2015-06-28 Thread SteveR
I have a linux Java7 stand-alone application using Camel 2.14 and the
camel-netty component. I have a route that receives via netty:udp and then
attempts to mirror the received packets also via netty:udp. I'm also using
the *LengthFieldBasedFrameDecoder *to decode the UDP packets into message
frames based on a 2-byte length field within each UDP message.

The UDP messages I'm receiving contain certain characters that don't decode
in UTF-8 (e.g. 0xa1 0xb2, 0xc3 ), so I've been trying to use the
*iso-8859-1* charset. I'm thinking that what I want in my
ServerPipelineFactory subclass is the
*io.netty.handler.codec.bytes.ByteArrayDecoder*, but I'm unable to get it to
compile with the *addlast()* method.

I've been using the approach outlined  here

 
thus far, but then I run into this compile issue with *io.netty *versus
*org.jboss.netty*.

Which leads me to believe that I'm confused wrt imports for *io.netty*
versus *org.jboss.netty*?  Below is my extended *ServerPipelineFactory
*class which I'd like to switch the StringDecoder/StringEncoder for
ByteArrayDecoder/ByteArrayEncoder.

Any help is greatly appreciated!

  Thanks, SteveR


package multiprotocollistenerrouter;

//import io.netty.handler.codec.bytes.ByteArrayDecoder;
//import io.netty.handler.codec.bytes.ByteArrayEncoder;
//import io.netty.channel.ChannelPipeline;
//import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

import io.netty.util.CharsetUtil;
import org.apache.camel.component.netty.NettyConsumer;
import org.apache.camel.component.netty.ServerPipelineFactory;
import org.apache.camel.component.netty.handlers.ServerChannelHandler;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;

//import org.jboss.netty.handler.logging.LoggingHandler;
//import org.jboss.netty.logging.InternalLogLevel;

import org.slf4j.Logger;// The org.slf4j.Logger interface is the
main user entry point of SLF4J API.
import org.slf4j.LoggerFactory; // Utility class producing Loggers for
various logging APIs, most notably for log4j.

/**
 * Consumer linked channel pipeline factory for the MCQ source provider.
 * Provides custom support for reception/parsing/processing of MCQ.
 *
 * @author steve
 *
 * @see http://camel.apache.org/netty.html
 * @see
http://opensourceknowledge.blogspot.com/2010/08/customizing-netty-endpoints-using.html#
 * @see
http://seeallhearall.blogspot.com/2012/06/netty-tutorial-part-15-on-channel.html
 * @see
https://github.com/apache/camel/blob/master/components/camel-netty/src/test/
 * 
java/org/apache/camel/component/netty/NettyCustomPipelineFactorySynchTest.java
 */
public class McqServerPipelineFactory extends ServerPipelineFactory  {
private final static Logger logger   =
LoggerFactory.getLogger(McqServerPipelineFactory.class);
private static final String NEW_LINE =
System.getProperty("line.separator");

// ---
// Stateless, singleton handler instances...re-used across connections
// ---
private static final ChannelHandler STR_ENCODER = new
StringEncoder(CharsetUtil.ISO_8859_1);
private static final ChannelHandler STR_DECODER = new
StringDecoder(CharsetUtil.ISO_8859_1);

//private static final ChannelHandler LOG_HANDLER = new
LoggingHandler(InternalLogLevel.INFO);

//private static final ByteArrayDecoder BYTES_DECODER = new
ByteArrayDecoder();
//private static final ByteArrayEncoder BYTES_ENCODER = new
ByteArrayEncoder();

private final NettyConsumer consumer;

private final int maxFrameLength;
private final int lengthFieldOffset;
private final int lengthFieldLength;
private final int lengthAdjustment;
private final int initialBytesToStrip;
private boolean   invoked;
private StringrouteId;

@Override
public ChannelPipeline getPipeline() throws Exception {  
logger.trace("getPipeline(): ENTER");

invoked = true;  
ChannelPipeline channelPipeline = Channels.pipeline();  

String theRouteId = consumer.getRoute().getId();
logger.info("getPipeline(): {}, routeId = {}", consumer.toString(),
theRouteId);

// ---
// Add logger to print incoming and outgoing data.
// This is both an upstream/downstream handler.
// ---
//String loggerName = "MCQ_LOGGING_HANDLER_" + theRouteId;
//channelPipeline.addLast(loggerName, LOG_HANDLER);

  

Camel website is not showing the code blocks

2015-06-28 Thread xlogger
I tried with a few different browsers on my PC (Firefox, Chrome, and IE..)
but found that the code blocks in all the Camel web pages are not displaying
properly... it looks like they are all collapsed... It was Okay last week
when I browse around

E.g.
http://camel.apache.org/content-based-router.html

 



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-website-is-not-showing-the-code-blocks-tp5768644.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: route specification in web.xml

2015-06-28 Thread Hans Orbaan
Hi,

Apparently all code snippets on camel.apache.org are invisible at the moment. I 
think it is a syntax highlighter issue.
You can still look up the code in the page source. Just right click and view 
page source

-Oorspronkelijk bericht-
Van: Tim Dudgeon [mailto:tdudgeon...@gmail.com] 
Verzonden: Sunday 28 June 2015 11:43
Aan: users@camel.apache.org
Onderwerp: Re: route specification in web.xml

Thanks. That's what I need.
But are you aware that all the code snippets are missing from that page?

Tim


On 27/06/2015 09:30, Claus Ibsen wrote:
> Hi
>
> Yes there is more documentation here
> http://camel.apache.org/servletlistener-component.html
>
> On Thu, Jun 25, 2015 at 1:40 PM, Tim Dudgeon  wrote:
>> I was trying to get some servlets working, based on the 
>> camel-example-servlet-tomcat-no-spring example.
>>
>> I'm a bit confused by this section:
>>
>> 
>>  routeBuilder-MyRoute
>>  
>>   
>> classpath:camel-config.xml
>>
>>
>> I worked out by trial and error how to specify an individual 
>> RouteBuilder implementation as a Java class:
>> foo.bar.bazMyRouteBuilderClass
>>
>> and how to do a package scan for multiple RouteBuilders:
>> packagescan:foo.bar.baz
>>
>> But is there and more detailed information on this sort of thing anywhere?
>>
>> For instance, what other options are available here, and if you 
>> needed to run multiple camel contexts (separate servlets?) how could you do 
>> this.
>>
>> Thanks
>> Tim
>
>



http-proxying and headerfiltering

2015-06-28 Thread caretka808
It's noted in many of the http components (http4, for example) that the
component will copy the In message headers to the Out message headers. It's
also documented as an example that camel can be used as a proxy bridge from
one HTTP endpoint to another. There are posts that recommend that folks make
use of removeHeaders() or extending a header filter strategy for known
headers. In the case where you are proxying to an http resource where you
don't know or even care what most of the headers are in the request (the
client can pretty much send whatever they want), how can you prevent these
request headers from being copied and subsequent returned to the client?
Typical proxies don't return request headers as a response to the client,
and camel as a proxy (by example given) shouldn't either.

I don't understand the statement that 'in headers are copied to out headers
to preserve routing'. The http4 component isn't tampering with in headers in
the exchange (is it?) so how would not copying the headers  prevent the next
component in a route from being able to work with the exchange? 

Thanks.



--
View this message in context: 
http://camel.465427.n5.nabble.com/http-proxying-and-headerfiltering-tp5768641.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel activemq consumer

2015-06-28 Thread rbkumar88
Hi,

Is there anyway to have a camel activemq consumer to consume only one
message at a time.
PFB the scenario.

I have a quartz scheduler which runs every 10 minutes and checks for a
condition, if the condition is satisfied, pull only one message from queue
else do nothing.

Regards
Bharath.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-activemq-consumer-tp5768640.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: route specification in web.xml

2015-06-28 Thread Tim Dudgeon

Thanks. That's what I need.
But are you aware that all the code snippets are missing from that page?

Tim


On 27/06/2015 09:30, Claus Ibsen wrote:

Hi

Yes there is more documentation here
http://camel.apache.org/servletlistener-component.html

On Thu, Jun 25, 2015 at 1:40 PM, Tim Dudgeon  wrote:

I was trying to get some servlets working, based on the
camel-example-servlet-tomcat-no-spring example.

I'm a bit confused by this section:


 routeBuilder-MyRoute
 
 
classpath:camel-config.xml
   

I worked out by trial and error how to specify an individual RouteBuilder
implementation as a Java class:
foo.bar.bazMyRouteBuilderClass

and how to do a package scan for multiple RouteBuilders:
packagescan:foo.bar.baz

But is there and more detailed information on this sort of thing anywhere?

For instance, what other options are available here, and if you needed to
run multiple camel contexts (separate servlets?) how could you do this.

Thanks
Tim







Re: Unable to shutdown endpoint when intercepted with interceptSendToEndpoint

2015-06-28 Thread Claus Ibsen
Hi

Yeah seems like a little bug, you are welcome to log a ticket

On Thu, Jun 25, 2015 at 11:53 AM, gterral  wrote:
> Hello,
>
> I'm facing an issue with the version of camel 2.15.2
>
> I have a component that create an endpoint.
>
> This endpoint override the shutdown and doShutdown method so we can log
> values at shutdown time.
>
> But when this endpoint is intercept with the interceptSendToEnpoint method
> the shutdown is not called.
>
> Here is an example of code to reproduce:
>
> the Component:
>
>
> the Endpoint:
>
>
> the route:
>
>
> When there is an interceptor the shutdown on the endpoint is not called,
> when there is no interceptor the shutdown is called.
>
> After some debugging I noticed that in the DefaultCamelContext at the
> shutdown time the shutdown is called on the list of endpoints, when there is
> an interceptor the list do not contain the CustomEnpoint but only the
> Interceptor, and because the interceptor does not implement
> ShutdownableAware the shutdown is not propagate to the underlying endpoint
> (here the CustomEndpoint)
>
> Without the interceptor the CustomEndpoint appears in the list and the
> shutdown method is called.
>
> Is this expected or not ?
>
> If it's not should I create an issue on your Jira ?
>
> Thanks in advance,
>
> Guillaume
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Unable-to-shutdown-endpoint-when-intercepted-with-interceptSendToEndpoint-tp5768574.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


Re: activemq away catch exception

2015-06-28 Thread Claus Ibsen
Hi

Check the AMQ documentation as it has some sendAsync alwaysSendSync
options you can enable. Also you can configure the connection to not
try failover etc. and if so a maximum number etc.

On Fri, Jun 26, 2015 at 11:35 AM, ndaniel  wrote:
> hi everyone,
>
> I'm testing camel with activemq using servlet-rest-tomcat example (I'm not a
> CAMEL expert).
>
> I'm trying to response an error if I can't connect to activemq.
>
> activemq is not start. I have the following line in my log :
>
> 11:22:43.003 [ActiveMQ Task-1] WARN  o.a.a.t.f.FailoverTransport - Failed to
> connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry.
>
> but I'm not able to catch this exception in my route.
>
> here is my route :
>
> rest("/actofmanagement").description("rest Service")
>  .consumes("application/json").produces("application/json")
>
>  .put("/updateEmail").description("UPDATE an
> email").outType(ActsOfManagementResponse.class)
> .route()
> .doTry()
> .process(fillQueueUpdateEmail) // insert data 
> in the queue
> .doCatch(CamelException.class, 
> JMSException.class,
> ConnectException.class,Exception.class, IOException.class,
> InterruptedException.class )
>
> .to("bean:ActsOfManagementWebService?method=responseErrorToClient(${body})").stop().end()
>
> .to("bean:ActsOfManagementWebService?method=responseToClient(${body})")
> .endRest()
>
> I also tried a global onException, but nothing happening too. (empty result)
>
> If someone has already tried this, let me know.
>
> thanks all.
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/activemq-away-catch-exception-tp5768595.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


Re: Camel proxy through Tomcat Servlet tunning

2015-06-28 Thread Claus Ibsen
Hi

There is a faster one here
http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html

On Thu, Jun 25, 2015 at 2:04 PM, Emmanouil Gkatziouras
 wrote:
> Greetings
>
> I had success on creating a camel http proxy that receives data from a
> tomcat
> servlet (using http://camel.apache.org/servlet-tomcat-example.html)
> and redirects the
> request to another url.
>
> I am concerned about the throughput and the configurations that should be
> applied.
>
> Considering the fact that a servlet is called by many threads, in order to
> create the proxy I changed the http client configuration and replaced the
> the BasicHttpClientConnectionManager (which is thread safe), with the
> PoolingClientConnectionManager. However throughput is low. Is there any
> other solution to increase the throughput(for example increasing camels pool
> size)? Also are there any other thread safe classes or resources that I
> should take into consideration?
>
> Thank you
>



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/