camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kaiser75 <gvar...@yahoo.com>
Subject Re: Java Rest DSL Spring boot and Rabbitmq
Date Thu, 18 May 2017 15:52:41 GMT
thanks souciance.  Here is my code , my question is how do I rteurn  a custom message when
the request is successful. Currently for some reason, my code returns the transformed payload
along with 200 ok, I want to send a custom message something like { statuscode = 200, message="success"}
as a response 

public void configure() throws Exception { 

                        // errorHandler(deadLetterChannel("jms:queue:dead")); 
                        handleProcessingException(); 
                        handleHttpOperationFailedException(); 

                        restConfiguration().component("netty4-http").host("0.0.0.0").port(9090).enableCORS(true) 
                                        .dataFormatProperty("prettyPrint",
"true"); 

                        rest("/ewarehouse").description("Adjustments REST service").produces("application/json") 
                                        .consumes("application/json").post("/adjustments").to("stream:out").to("direct:adjustmentsToRMQ") 
                                        .responseMessage().code(200).message("Success").endResponseMessage(); 

                        from("direct:adjustmentsToRMQ") 
                       .bean(new ValidateEWAdjustments()) 
                       .bean(new EWAdjustmentsBean()) 
                        .bean(new JsonSerializerBean()).split().jsonpath("$.*").parallelProcessing() 
                        .bean(new JsonSerializerBean()) 
                        .to("spring-amqp:camel.ew.temp?type=direct&exchangePattern=InOnly"); 
                                

                } 


currently im returning the output from ".bean(new EWAdjustmentsBean()).bean(new JsonSerializerBean())" 

On Sunday, May 14, 2017, 10:00:14 AM EDT, souciance [via Camel] <ml+s465427n5799484h64@n5.nabble.com>
wrote: Have a look at the camel-rabbitmq component, there are some parameters for pooling
but I haven't used them myself. Maybe the unit tests provide more information.
I believe .to("rabbitmq...") opens and closes a new connection.
For json schema validation there are various frameworks you can use to use in your code. One
is https://github.com/networknt/json-schema-validatorAdd a bean, validate your json, throw
an error if it fails or continue processing.
 
|  | Virusfritt. www.avast.com  |


On Sat, May 13, 2017 at 6:58 PM, kaiser75 [via Camel] <[hidden email]> wrote:

 I've a use case where I need to expose a rest end point to receive a request, validate it
and then post it to a Rabbitmq queue. 

I'm thinking of using Java Rest DSL , spring boot components to build this service out. I
do have a few questions, 

How do I enable connection pooling for my connections to Rabbit? 

Does  to("rabbitmq://localhost: 5672/ex2")   open and close a new connection every time
it is invoked?

how do I add json schema validation to validate inbound requests ?

Thanks much
GV  

I'm planning to model my code after the spirng-boot-rest-jpa sample in the camel examples

 
 
   If you reply to this email, your message will be added to the discussion below: http://camel.465427.n5.nabble.
com/Java-Rest-DSL-Spring-boot- and-Rabbitmq-tp5799453.html   To start a new topic under Camel
- Users, email [hidden email] 
 To unsubscribe from Camel - Users, click here.
 NAML 

 
 
   If you reply to this email, your message will be added to the discussion below: http://camel.465427.n5.nabble.com/Java-Rest-DSL-Spring-boot-and-Rabbitmq-tp5799453p5799484.html
  To unsubscribe from Java Rest DSL Spring boot and Rabbitmq, click here.
 NAML 



--
View this message in context: http://camel.465427.n5.nabble.com/Java-Rest-DSL-Spring-boot-and-Rabbitmq-tp5799453p5799796.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message