Camel Duplicate messages on IBM MQ

2016-11-21 Thread Shabin5785
Hi,

I have a simple route putting data into a topic. Its given below.

from("direct:bb")
.marshal().xstream()
.setHeader("CamelJmsDestinationName",
constant("topic:///mytopic?targetClient=1"))
.to("jms:topic:/mytopic?useMessageIDAsCorrelationID=true");

I followed the camel JMS page tutorial http://camel.apache.org/jms.html ,
especially the section Setting JMS Provider Options on the Destination.

In my consumer, i get the same message twice. I thought setting the
correlation id should prevent this?

Also if I use IBM MQ browser, I get the same message, one in MQSTR format
and other in MQRFT format.

Please note that I have a queue which is subscribed to the topic and i am
consuming the above queue. (Had to do like that for a specific application).

Is this any issue with the way i have configured the route?

Thanks
Shabin Hashim



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Duplicate-messages-on-IBM-MQ-tp5790284.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apace Camel : Custom Redelivery Policy

2016-10-18 Thread Shabin5785
Thanks. Using when to check condition for re-delivery policy works :)



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891p5788944.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Apace Camel : Custom Redelivery Policy

2016-10-18 Thread Shabin5785
I have a route that calls an external rest service. I have configured my
error handler as shown below.

errorHandler(deadLetterChannel("jms:dlc").maximumRedeliveries(3));

What i want to do:

1) If connection to external api fails, i want to retry 3 times and then
send to deadLetterChannel
2) If api call is fine, i want to check the status code, log the response
and then send the message to deadLetterChannel.
For that i set throwExceptionOnFailure to false.

In my route i have a bean as the last endpoint. This bean receives the
response from the external end point and checks for the status.

void process(Exchange exchange){
  //check http status code
  //if not success
  exchange.setProperty(Exchange.ROUTE_STOP,true);
  //sendToDeadLetterQueue;
  }


My problem is that redelivery happens even when i am able to connect to API.
I expect the redelivery to happen on error. I am handling the response from
API and also stopping the exchange. So i expect my Bean to log the response
from API, send to deadLetterQueue(I have a route for that) and stop. But
redelivery happens 3 times evand so en when API call is successful and so
deadletterchannel route is invoked 3 times

Can i stop the redelivery from my bean?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Parse Json inside RecipientList

2016-09-29 Thread Shabin5785
OK got it.. I added it as a property on exchange.



Ranx wrote
> There are a number of ways but perhaps the simplest would be something
> like:
> 
> .setHeader("customerId","${body.id}")
> 
> right before the marshaling.  Then in the http statement where the ID goes
> you can fish it out of the header with something like
> ${header.customerId}.
> 
> I wrote all that free hand just now with out using an IDE so be suspicious
> of the specifics but comfortable with the general approach.
> 
> On Wed, Sep 28, 2016 at 11:35 PM, Shabin5785 <

> shabin@

> > wrote:





--
View this message in context: 
http://camel.465427.n5.nabble.com/Parse-Json-inside-RecipientList-tp5788162p5788225.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Parse Json inside RecipientList

2016-09-28 Thread Shabin5785
sparekh wrote
> If the jms message is a serialized POJO then you can use the Camel OGNL
> expression to grab the id via body.id before marshalling it to JSON.
> 
> Thanks,
> sparekh

Message is a serialized pojo. If i extract the id before marshalling, how
can i hand it over to the next stage?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Parse-Json-inside-RecipientList-tp5788162p5788181.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Parse Json inside RecipientList

2016-09-28 Thread Shabin5785
Hi,

I have a message received as Json. Logging the message body gives me below
value (example)
{ "id":22, "type":"edit"}

I need to invoke a rest api which needs the id value from the above json to
be included. Api end point is like http://x/api/customer/, where id
is the value above.

I configured the route like:

from("jms:queue") 
.marshal() 
.json(JsonLibrary.GSON) 
.setHeader(Exchange.CONTENT_TYPE,constant("application/json")) 
.setHeader(Exchange.HTTP_METHOD, constant("POST")) 
.recipientList( simple("https4://x/api/customer/"))

How can i inject the id from the body of my message? There is an xpath
option which i can embed, but there seems to be no jsonpath option. I can
only link a jsonpath expression , but cannot put it inside recipientList.





--
View this message in context: 
http://camel.465427.n5.nabble.com/Parse-Json-inside-RecipientList-tp5788162.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Http post Request returns 400 error

2016-09-27 Thread Shabin5785
Great .That worked :)

Are the  headers from the JMS message that i am receiving being passed on to
the POST call as well? I thought only the relevant headers for http call 
will be passed on.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Http-post-Request-returns-400-error-tp5788101p5788116.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Http post Request returns 400 error

2016-09-27 Thread Shabin5785
I have a camel route configured for reading from a JMS queue and POST it to a
service. My route is :

from("jms:queue")
.marshal()
.json(JsonLibrary.GSON)
.setHeader(Exchange.CONTENT_TYPE,constant("application/json"))
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.process(new Processor1())
.to("https4:xx?throwExceptionOnFailure=false")
.process(new MyProcessor());

My Configuration for setting my auth details.

HttpComponent httpc =
getContext().getComponent("http4",HttpComponent.class);
httpc.setHttpConfiguaration(customHttpConfig())

*I am getting a 400 error from the server. But i am able to hit the server
from Postman api and get successful response.*

In my Processor1 class ( before making the request), i am able to print the
body of the message, which contains a json representation of my object.

But in the processor after the POST request, i am doing this and getting
below responses:

Message in = exchange.getIn();
in.getBody(String.class); // print the error code 400
HttpServletRequest request = in.getBody(HttpServletRequest.class)// This is
null.

Anything i am doing wrong? Do i need to set the message Content to the body
of my Post Request?




--
View this message in context: 
http://camel.465427.n5.nabble.com/Http-post-Request-returns-400-error-tp5788101.html
Sent from the Camel - Users mailing list archive at Nabble.com.