Search in sources :

Example 1 with Rfc5425FrameDecoder

use of org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder in project camel by apache.

the class NettyRfc5425LongMessageTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    context().getRegistry(JndiRegistry.class).bind("rfc5426FrameDecoder", new Rfc5425FrameDecoder());
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            context.setTracing(true);
            DataFormat syslogDataFormat = new SyslogDataFormat();
            // we setup a Syslog listener on a random port.
            from(uri).unmarshal(syslogDataFormat).process(new Processor() {

                @Override
                public void process(Exchange ex) {
                    assertTrue(ex.getIn().getBody() instanceof SyslogMessage);
                }
            }).to("mock:syslogReceiver").marshal(syslogDataFormat).to("mock:syslogReceiver2");
            // Here we need to turn the request body into ByteBuf
            from("direct:start").convertBodyTo(ByteBuf.class).to(uri);
        }
    };
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Exchange(org.apache.camel.Exchange) Rfc5425FrameDecoder(org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) DataFormat(org.apache.camel.spi.DataFormat) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with Rfc5425FrameDecoder

use of org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder in project camel by apache.

the class NettyRfc5425Test method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    context().getRegistry(JndiRegistry.class).bind("rfc5426FrameDecoder", new Rfc5425FrameDecoder());
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            context.setTracing(true);
            DataFormat syslogDataFormat = new SyslogDataFormat();
            // we setup a Syslog listener on a random port.
            from(uri).unmarshal(syslogDataFormat).process(new Processor() {

                @Override
                public void process(Exchange ex) {
                    assertTrue(ex.getIn().getBody() instanceof SyslogMessage);
                }
            }).to("mock:syslogReceiver").marshal(syslogDataFormat).to("mock:syslogReceiver2");
            from("direct:checkStructuredData").unmarshal(syslogDataFormat).process(new Processor() {

                @Override
                public void process(Exchange ex) {
                    Object body = ex.getIn().getBody();
                    assertTrue(body instanceof Rfc5424SyslogMessage);
                    assertEquals("[exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"]", ((Rfc5424SyslogMessage) body).getStructuredData());
                }
            }).to("mock:syslogReceiver");
        }
    };
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Exchange(org.apache.camel.Exchange) Rfc5425FrameDecoder(org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) DataFormat(org.apache.camel.spi.DataFormat)

Example 3 with Rfc5425FrameDecoder

use of org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder in project camel by apache.

the class NettyRfc5425LongMessageTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("decoder", new Rfc5425FrameDecoder());
    jndi.bind("encoder", new Rfc5425Encoder());
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Rfc5425FrameDecoder(org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder) Rfc5425Encoder(org.apache.camel.component.syslog.netty.Rfc5425Encoder)

Example 4 with Rfc5425FrameDecoder

use of org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder in project camel by apache.

the class NettyRfc5425Test method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("decoder", new Rfc5425FrameDecoder());
    jndi.bind("encoder", new Rfc5425Encoder());
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Rfc5425FrameDecoder(org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder) Rfc5425Encoder(org.apache.camel.component.syslog.netty.Rfc5425Encoder)

Aggregations

Rfc5425FrameDecoder (org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder)4 JndiRegistry (org.apache.camel.impl.JndiRegistry)4 Exchange (org.apache.camel.Exchange)2 Processor (org.apache.camel.Processor)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 Rfc5425Encoder (org.apache.camel.component.syslog.netty.Rfc5425Encoder)2 DataFormat (org.apache.camel.spi.DataFormat)2 ByteBuf (io.netty.buffer.ByteBuf)1