[jboss-jira] [JBoss JIRA] (DROOLS-267) DroolsExecuteProducer is loosing all Camel Exchange headers

A Majewski (JIRA) jira-events at lists.jboss.org
Wed Sep 18 19:37:04 EDT 2013


A Majewski created DROOLS-267:
---------------------------------

             Summary: DroolsExecuteProducer is loosing all Camel Exchange headers
                 Key: DROOLS-267
                 URL: https://issues.jboss.org/browse/DROOLS-267
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions:  6.0.0.CR3, 5.5.0.Final,  6.0.0.CR4
            Reporter: A Majewski
            Assignee: Mark Proctor


When using drools endpoint inside camel project the DroolsExecuteProducer is loosing all the Camel Exchange headers.

Usually the InOut camel producers should be copy all In Exchange Headers to Out Exchange. Please refer to community discussion: https://community.jboss.org/message/837533#837533

Additional tests casess in org.drools.camel.component.CamelEndpointTest class showing exact problem.
{code}

...
@Test
    public void testNoSessionInsertWithHeaders() throws Exception {
        
    	MockEndpoint mockResult = context.getEndpoint("mock:resultWithHeader",MockEndpoint.class);
    	
    	String headerName ="testHeaderName";
        String headerValue ="testHeaderValue";
        
        Person person = new Person();
        person.setName( "Mauricio" );

        InsertObjectCommand cmd = (InsertObjectCommand) CommandFactory.newInsert( person,
                                                                                  "salaboy" );

        Map<String,Object> headers= new HashMap<String, Object>();
        headers.put(headerName,headerValue);
        headers.put( DroolsComponent.DROOLS_LOOKUP,"ksession1");
        
        // set mock expectations
        mockResult.expectedMessageCount(1);
        mockResult.expectedHeaderReceived(headerName,headerValue);
        
        ExecutionResults response = (ExecutionResults) template.requestBodyAndHeaders("direct:test-no-session-withHeader",
                cmd,headers);
        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) != null );
        
        mockResult.assertIsSatisfied();
    }


@Test
    public void testSessionBatchExecutionCommandWithHeader() throws Exception {
        
    	MockEndpoint mockResult = context.getEndpoint("mock:resultWithHeader",MockEndpoint.class);
    	
    	String headerName ="testHeaderName";
        String headerValue ="testHeaderValue";
        
    	Person john = new Person();
        john.setName("John Smith");

        List<Command> commands = new ArrayList<Command>();
        commands.add(CommandFactory.newInsert(john, "john"));
        BatchExecutionCommand batchExecutionCommand = CommandFactory.newBatchExecution(commands);

        Map<String,Object> headers= new HashMap<String, Object>();
        headers.put(headerName,headerValue);
        
        // set mock expectations
        mockResult.expectedMessageCount(1);
        mockResult.expectedHeaderReceived(headerName,headerValue);
        
        //do test
        template.requestBodyAndHeaders("direct:test-with-session-withHeader",
                batchExecutionCommand,headers);
        
        ExecutionResults response = mockResult.getReceivedExchanges().get(0).getIn().getBody(ExecutionResults.class);
        
        assertTrue( "Expected valid ExecutionResults object",
                response != null );
        assertTrue( "ExecutionResults missing expected fact",
                response.getFactHandle( "john" ) != null );
        assertTrue( "ExecutionResults missing expected fact",
                response.getFactHandle( "john" ) instanceof FactHandle);
        
        mockResult.assertIsSatisfied();
    }

@Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                from( "direct:test-with-session" ).to( "drools://node/ksession1" );
                from( "direct:test-no-session" ).to( "drools://node" );
                from( "direct:test-with-session-withHeader" ).to( "drools://node/ksession1" ).to("mock:resultWithHeader");
                from( "direct:test-no-session-withHeader" ).to( "drools://node/ksession1" ).to("mock:resultWithHeader");
            }
        };
    }

{code}

I am going to create a pull request to fix this issue. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list