Has anyone worked on Kafka manual commit using Apache camel, we are not finding any clue to implement it, We are trying to do so using camel router as :
from("kafka:{{kafka.hostname}}:{{kafka.port}}?topic={{kafka.topic}}&groupId={{kafka.consumer.groupid}}&autoOffsetReset=none&autoCommitEnable=false&maxPollRecords=3").process(new Processor() {
#Override
public void process(Exchange exchange) throws Exception {.....}).end();
Kindly help us out in the issue,
Thanks.
Related
I need to download Keystore and use it while creating the source connector, currently, I am overriding open method but this gets called for each of my source connectors.
#Override
public void open(Configuration configuration) throws Exception {
// do few things like download Keystore to default path etc
super.open(configuration)
}
Is there an option to init a few pre stuff as soon as the task manager came up?
I am working on a project where I am using Apache Camel to establish a connection to a URL using Java code in a method:
public void establishConnection()
{
final CamelContext context = new DefaultCamelContext();
camelContext.addRoutes(new RouteBuilder(){//logic});
camelContext.start();
Thread.sleep(7500);
camelContext.stop();
}
The issue is that it is necessary to pause the thread, otherwise the following code executes, so to wait for the response as it takes camel time to start.
Now the issue is if this method gets called many times and I want the camel context to be initialized once only with the route so that we dont have to use the sleep here for subsequent calls.
What context are you in? You don't need to do the work to start/stop by yourself (as Adam also commented), Camel does it for you.
When you are building a Spring Boot application, check out how to use Camel with Spring Boot.
When you use Camel standalone, have a look at this example.
I have a message that comes in via a queue. I want to send that message off to a signing service. This service returns a signature. I then want to put the original message and the signature message into a Zip file as two seperate Zip entries. I want to asked for the world on a stick and do this as a blueprint, and entirely via XML with no compiled java code (other than my signing microservice which is already built and running in our infrastructure).
Ideas?
Looking at the docs and playing around with it I think I can...maybe.
It seems the default aggregators might not do quite what I need for this usecase.
Just found the solution. Below is a PoC:
context.addRoutes(new RouteBuilder() {
#Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&period=1s").to("direct:start");
from("direct:start").setBody().simple("hello").multicast(new ZipAggregationStrategy(true, true)).to("direct:a", "direct:b").end().to("file://target?fileName=any.zip");
from("direct:a").setHeader("CamelFileName").simple("data.txt").to("log:mylog");
from("direct:b").setHeader("CamelFileName").simple("signature.txt").to("http://mysignatureservice");
}
});
My Entity has a property,
#Embedded
#XmlTransient
private ReleaseTraits traits;
#XmlTransient
public ReleaseTraits getTraits() {
return traits;
}
But RestEasy (in JBoss AS 7.1) keeps putting it to the JSON.
Also, the null values are not omitted.
Any idea why and how to achieve the property to be left out?
#JsonIgnore works. It seems that the docs is wrong about which provider is the default in JBoss AS 7.
I filed https://issues.jboss.org/browse/AS7-5604 and https://issues.jboss.org/browse/AS7-5605 to target this.
This related question discusses some options for configuring your JBoss deployment to use Jettison rather than Jackson for JSON marshalling: Set JSON provider at RESTEasy on JBoss 7.1.1
For the benefit of others, #XmlTransient works correctly for me in WildFly 8.0, which is using RestEasy 3.0.x.
I need to implement a consumer to an XML-RPC based service over TCP. Upon establishing a connection to the server, it requires that
Authentication credentials be sent by the client
An event subscription request be sent by the client, and finally
The client is to switch into a "receiving" mode where messages will be sent asynchronously
When the client is no longer interested in receiving more events, the client ought to "unwind" steps 1-3.
So, I would like to use Apache Camel to implement the client, with an obvious entry endpoint of a Mina Component ("mina:tcp://host:_port_?textline=true&decoderMaxLineLength=10240&sync=true"). My question is, how would I go about implementing steps 1, 2, and 4 above? How would I go about performing those "handshake" steps before the processor in my RouteBuilder gets call? Is this even possible with Camel or will I have to write a straight Mina client to handle this. Are there better options for dealing with this type of integration scenario?
Thank you.
-Santi
This is a really good tutorial on implementing a session handshaking protocol with Netty, which is quite similar to Mina. You could implement this with Camel's Netty Component or draw on the tutorial to build the same with Mina.
it's maybe too late but others may be need the answer.
the key point is you need to use a Processor. something like this
from("mina:tcp:////host:_port_?textline=true&decoderMaxLineLength=10240&sync=true")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String inboundMessage = exchange.getIn().getBody(String.class);
String outboundMessage = "echo:"+inboundMessage;
exchange.getOut().setBody(outboundMessage);
}
}).to(""mock:result"");
the outboundMessage will be a reply to form end point mina:tcp:////host:_port_?textline=true&decoderMaxLineLength=10240&sync=true