Error sending messages from jetty to the queue(use camel) - apache-camel

I use servicemix. I'm trying to send messages from jetty to the queue, but I get the following error:
enter image description here
my blueprint:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="jetty:http://localhost:8180/test"/>
<to uri="activemq://events_test" />
</route>
</camelContext>
if i use route from jetty to file - everything works as it should

Exchange pattern of your route is InOut, so your jetty consumer waiting response from activemq producer. Response will appear if you have activemq consumer that will process your jetty request. If activemq producer shouldn't make response and you need just save request in queue use "inOnly" instead if "to", like this:
<inOnly uri="activemq://events_test" />

Related

Resend Message again on failure endpoints in camel route

I am developing a sample route
FROM: SOURCE ENDPOINT URI
Doing some transformation(Ex: XML TO JSON)
TO: TRANS ENDPOINT URI // Connection Error Occurred at this TRANS endpoint
TO: TARGET ENDPOINT URI
I need to send my message directly to TRANS ENDPOINT URI not FROM endpoint again. Because I have already done some transformation before in the middle of FROM endpoint to TRANS endpoint. I am saving my message using
OnExpection useorginalmessage=false and saved in my local directory with the filename
So I need to send the transformed message to the TRANS endpoint URI.
<route>
<from uri="file:C:/MINTS/Source/"/>
<to uri="c:/maps/xmltojson.xslt"/>
<to uri="file:C:/MINTS/TRANS/"/><!--connection error or exception occured -->
<to uri="file:C:/MINTS/TARGET/"/>
<onException useOrginalMessage=false>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<process ref="MyExceptionProcessor" />
</onException>
</route>

Create route in Apache ServiceMix Bundle:List state is Grace Period

I create a route on apache servicemix and put it in deploy. When the server started and I check the bundle:list it says that my route is in Grace Period and it's not working.
Currently I'm routing ftp to file server and do this format.
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="FTP:username#//hostname /DB?password=password"/>
<to uri="file:\\storage\folder\anotherFolder\anotherFolder\anotherFolder\"/>
</route>
</camelContext>
I did not input the exact credentials I use but that is the format that I used.
Is there any problem with my code or it's on my apache service mix? Please help I doing this for a week.
P.S. It works when its file to file server
You can install ftp using feature:install camel-ftp .

Limit netty4 tcp endpoint to a single instance

I have a mock endpoint at 8001 that will echo anything provided to it.
I have an http endpoint that will submit the end of the URL to the mock endpoint, and provide a response from the endpoint's response.
That works fine.
The challenge is, I want the http route to use only 1 tcp connection to the 8001 endpoint.
I created a worker group as explained elsewhere, and set the worker count to 1. Looking through the source code, I'm thinking this approach should work.
However, when I do this bash command:
for a in {1..5}; do curl "http://localhost:8080/upstream/REQUESTNUM$a" > $a.txt & done;
I see multiple connections to 8001. I would have expected the http endpoint requests would have to share a single pool worker, but that doesn't seem to be the case.
Perhaps I am missing something, or perhaps there is another way to accomplish my goal of using only 1 back-end tcp connection for all the http requests.
How do I accomplish it?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext
xmlns="http://camel.apache.org/schema/spring">
<route id="mockUpstream">
<from
uri="netty4:tcp://localhost:8001?sync=true&textline=true&keepAlive=true&disconnect=false&reuseChannel=true" />
<log message="Incoming to upstream: ${body}" />
<transform>
<simple>${body}</simple>
</transform>
</route>
<route id="httpServer">
<from
uri="netty4-http:http://0.0.0.0:8080/upstream?matchOnUriPrefix=true" />
<!-- optional just use CamelHttpQuery from header, for full query -->
<log
message="Incoming http command: ${in.headers[CamelHttpPath]}" />
<transform>
<simple>${in.headers[CamelHttpPath]}</simple>
</transform>
<to
uri="netty4:tcp://localhost:8001?workerGroup=#sharedPool&sync=true&textline=true&keepAlive=true&disconnect=false&reuseChannel=true" />
<transform>
<simple>${body}</simple>
</transform>
</route>
</camelContext>
<bean id="poolBuilder"
class="org.apache.camel.component.netty4.NettyWorkerPoolBuilder">
<property name="workerCount" value="1" />
</bean>
<bean id="sharedPool" class="io.netty.channel.EventLoopGroup"
factory-bean="poolBuilder" factory-method="build"
destroy-method="shutdown">
</bean>
</beans>
Looking at the logs, with TRACE level logging, I saw the NettyProducer's pool was indeed set to use 1 max active connection, but the NettyProducer was allowed 100 idle connections. I changed the following line and it is now behaving as expected:
<to
uri="netty4:tcp://localhost:8001?workerGroup=#sharedPool&sync=true&textline=true&keepAlive=true&disconnect=false&reuseChannel=true&producerPoolMaxActive=1&producerPoolMaxIdle=1" />
I assumed the "producer" settings were only good for the producer side (netty in mock host route) of the connection, but it looks like they can be used by the consumer end (netty in http route), too.
edit: I confused the terms producer and consumer and got that backwards above. Seeing that the "to" element is producing a request for something to consume, the producer* parameters make sense for (netty in http route). The (netty in mock host route) is the consumer of requests.

How can I get a response from an Apache camel jetty request?

I am new to apache camel.
I want to create a service bus (middle ware) using apache camel by making a jetty Post request and then get the response from the server.
Here is what I've done
<route streamCache="true">
<from uri="jetty:{{wrapperEntry.protocol}}://{{wrapperEntry.host}}:{{wrapperEntry.port}}/rsb/SubmitNewCaseForAndroid?continuationTimeout=0" />
<convertBodyTo type="java.lang.String" />
<to uri="direct:helloworld"/>
</route>
<route streamCache="true">
<from uri="direct:helloworld"/>
<transform>
<simple>
Hello World
</simple>
</transform>
<convertBodyTo type="java.lang.String" />
</route>
the request goes successfully to the server and submit my case, other wise I cannot get the response back from the server.
Note: the response comes from the is the server is string it comes like this
'code':0,
'description':'operation completed succrssfully',
'complaintId':'45285'
Thank in Advacnce

Camel and Spring Integration

I want to test camel spring integration example from the apache camel site
http://camel.apache.org/springintegration.html but I am getting the exception
org.apache.camel.RuntimeCamelException: org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel outputchannel.
my short code is given below:
<channel id="inChannel"/>
<channel id="outputChannel"/>
<beans:bean id="greeting" class="com.javarticles.spring.integration.Greeting"/>
<service-activator input-channel="inChannel" ref="greeting" method="sayHello" output-channel="outputChannel"/>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq:activemqsource"/>
<to uri="log:input"/>
<to uri="spring-integration:inChannel? inputChannel=outputChannel"/>
<to uri="log:output"/>
</route>
I tried to search related problems but I did not get with camel could any one tell me how to subscribe the outputchannel
According to the Camel documentation mentioned by you, the config should be like this:
<to uri="spring-integration:inputChannel?inOut=true&inputChannel=outputChannel"/>
Your issue is inOut=true:
The exchange pattern that the Spring integration endpoint should use. If inOut=true then a reply channel is expected, either from the Spring Integration Message header or configured on the endpoint.

Resources