Guest User

Untitled

a guest
Jul 17th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. import org.apache.camel.Exchange;
  2. import org.apache.camel.Processor;
  3. import org.apache.camel.builder.RouteBuilder;
  4.  
  5. public class MyRouteBuilder extends RouteBuilder {
  6.  
  7. @Override
  8. public void configure() throws Exception {
  9. from("activemq:alfresco-queue")
  10. .process(new Processor() {
  11. public void process(Exchange exchange) throws Exception {
  12. byte[] bytes = exchange.getIn().getBody(byte[].class);
  13.  
  14. // All of that not working...
  15. // exchange.getIn().setHeader("content", bytes); gives "java.lang.IllegalAgrumentException: Request header is too large"
  16. // exchange.getIn().setBody(bytes, byte[].class); gives "size of content is -1"
  17. // exchange.getIn().setBody(bytes); gives "size of content is -1"
  18. // ???
  19.  
  20. // ??? But I can print file content here
  21. for(int i=0; i < bytes.length; i++) {
  22. System.out.print((char) bytes[i]);
  23. }
  24. }
  25. })
  26.  
  27. .setHeader(Exchange.HTTP_METHOD, constant("POST"))
  28. .setHeader(Exchange.CONTENT_TYPE, constant("multipart/form-data"))
  29. .to("http://vm-alfce52-31......com:8080/alfresco/s/someco/queuefileuploader?guest=true")
  30.  
  31. .process(new Processor() {
  32. public void process(Exchange exchange) throws Exception {
  33. System.out.println("The response code is: " + exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE));
  34. }
  35. });
  36. }
  37. }
  38.  
  39. // somewhere on an external resource
  40. Content content = request.getContent();
  41. long len = content.getSize() // is always == -1.
Add Comment
Please, Sign In to add comment