FUSE Mediation Router
  1. FUSE Mediation Router
  2. MR-414

routing from activemq JMS to CXF web service

    Details

    • Type: Task Task
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: 2.4.0-fuse-02-00
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      all
    • Similar Issues:
      Show 9 results 

      Description

      I need a camel route that receives a one-way JMS message, modifies the message so that its suitable for the destination web service, then invokes the external web service.
      I'm thinking the following (pseudo) route could do the trick.

      <camelContext xmlns="http://camel.apache.org/schema/spring">
      <route>
      <from uri="activemq:queue:requestQueue"/>
      <bean ref="myProcessor" method="process"/>
      <to uri="cxf:bean:serviceEndpoint"/>
      </route>
      </camelContext>

      What i'm not clear on is this the best approach? Will the myProcess step be able to transform the jms message into a payload suitable for the cxf producer endpoint? What will the process() method use - wsdl2java/jaxb object perhaps? - as the argument to setBody() on message before it goes to the cxf producer endpoint?
      I can imagine an alternative approach would be for the myProcessor bean to hold on to a CXF client-side proxy (set via Spring injection) and invoke on that. That way i could just use the JAX-WS / JAXB object model to map and populate the outgoing request from the content of the JMS message.
      Thoughts? Have u seen this done and/or any sample code?

        Activity

        Hide
        Lowry Curry
        added a comment -

        Comments from Torsten Mielke below:

        CXF support 3 different message modes: PAYLOAD, MESSAGE and POJO. On the producer side you should have the choice between PAYLOAD and POJO.
        If you need to use the POJOmode in your cxf producer endpoint, then check the part
        "How to prepare the message for the camel-cxf endpoint in POJO data format" on the camel-cxf documentation. You will need to do the transformation to the Java List yourself in a custom processor.

        If you already receive a valid XML snippet that conforms to the WSDL operation you want to invoke on using the cxf producer, then PAYLOAD mode should be fine as well.

        I'll attach a demo which uses a cxf producer endpoint to invoke on a CORBA server. In the scenario of using CORBA as the binding and transport in CXF, I had to use the POJO mode. Check the camel route definition and how I convert the message payload to JAXB.
        If you already have some good XML Payload, you should be able to use the PAYLOAD mode.

        Btw, the Forge Demos project will be restarted some time soon and that we should all capture those kind of demos in this project for future reference.

        Show
        Lowry Curry
        added a comment - Comments from Torsten Mielke below: CXF support 3 different message modes: PAYLOAD, MESSAGE and POJO. On the producer side you should have the choice between PAYLOAD and POJO. If you need to use the POJOmode in your cxf producer endpoint, then check the part "How to prepare the message for the camel-cxf endpoint in POJO data format" on the camel-cxf documentation. You will need to do the transformation to the Java List yourself in a custom processor. If you already receive a valid XML snippet that conforms to the WSDL operation you want to invoke on using the cxf producer, then PAYLOAD mode should be fine as well. I'll attach a demo which uses a cxf producer endpoint to invoke on a CORBA server. In the scenario of using CORBA as the binding and transport in CXF, I had to use the POJO mode. Check the camel route definition and how I convert the message payload to JAXB. If you already have some good XML Payload, you should be able to use the PAYLOAD mode. Btw, the Forge Demos project will be restarted some time soon and that we should all capture those kind of demos in this project for future reference.
        Hide
        Torsten Mielke
        added a comment -

        Hi Lowry,

        Do you need anything else? Or can we close this JIRA?

        Show
        Torsten Mielke
        added a comment - Hi Lowry, Do you need anything else? Or can we close this JIRA?
        Hide
        Lowry Curry
        added a comment - - edited

        yes you can close this issue.
        Just adding reference code snippet for processing bean (just prior to call on camel cxf producer).
        Here i convert the JMS message to format suitable for invocation on cxf web service.

        // Use Camel language annotations to bind from the exchange to bean params
        public void upsert(@XPath("/CaseUpsertRequest/CallingSite/text()") String callingSite,
        @XPath("/CaseUpsertRequest/CallingUser/text()") String callingUser,
        @XPath("/CaseUpsertRequest/CaseID/text()") String caseID,
        Exchange exchange)

        { logger.debug( "Calling upsert() on CaseRegProcessor!"); logger.debug( "callingSite = " + callingSite); logger.debug( "callingUser = " + callingUser); logger.debug( "caseID = " + caseID); // Database lookup goes here // Perform mapping from lookup into web service parameter CaseRegInput input = new CaseRegInput(); input.setErrorSpcCode(callingSite); ListOfBpsrcaseregistration list = new ListOfBpsrcaseregistration(); BpServiceRequest e = new BpServiceRequest(); e.setId("New"); e.setSRType("Benefits Investigation"); e.setSource("Web"); e.setStatus("Pending"); e.setSubStatus("Case created"); e.setUSONACMProviderId("1-355-7215"); e.setUSONClinicalContactId("1-31L-8882"); e.setUSONPatientId("1-36Q-10478"); e.setUSONProgram("Shire"); e.setUSONReferralState("TX"); e.setUSONCaseNotes("JMS Case ID: " + caseID); list.getBpServiceRequest().add(e); input.setListOfBpsrcaseregistration(list); // Prepare for call to Web Service // Add the method parameters to a list, and initialize the message with this parameter list List outElements = new ArrayList<Element>(); outElements.add(input); // for details of packing params and preparing Exchange for CXF producer endpoint see: // http://camel.apache.org/cxf.html#CXF-HowtopreparethemessageforthecamelcxfendpointinPOJOdataformat // and // http://camelbot.blogspot.com/2010/10/should-you-getin-or-getout.html // TODO: may be more efficient to set the In (i.e. 'exchange.getIn().setBode()' , etc) // This works so i'm leaving for now (lowry curry) exchange.getOut().setBody(outElements); exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setHeader(CxfConstants.OPERATION_NAME, "CaseReg"); exchange.getOut().setHeader(CxfConstants.OPERATION_NAMESPACE, "http://www.USON/BP/siebel/Case/CaseRegistration"); // passing (out-of-band) values to subsequent processor exchange.getOut().setHeader("callingSite", callingSite); exchange.getOut().setHeader("callingUser", callingUser); exchange.getOut().setHeader("caseID", caseID); }
        Show
        Lowry Curry
        added a comment - - edited yes you can close this issue. Just adding reference code snippet for processing bean (just prior to call on camel cxf producer). Here i convert the JMS message to format suitable for invocation on cxf web service. // Use Camel language annotations to bind from the exchange to bean params public void upsert(@XPath("/CaseUpsertRequest/CallingSite/text()") String callingSite, @XPath("/CaseUpsertRequest/CallingUser/text()") String callingUser, @XPath("/CaseUpsertRequest/CaseID/text()") String caseID, Exchange exchange) { logger.debug( "Calling upsert() on CaseRegProcessor!"); logger.debug( "callingSite = " + callingSite); logger.debug( "callingUser = " + callingUser); logger.debug( "caseID = " + caseID); // Database lookup goes here // Perform mapping from lookup into web service parameter CaseRegInput input = new CaseRegInput(); input.setErrorSpcCode(callingSite); ListOfBpsrcaseregistration list = new ListOfBpsrcaseregistration(); BpServiceRequest e = new BpServiceRequest(); e.setId("New"); e.setSRType("Benefits Investigation"); e.setSource("Web"); e.setStatus("Pending"); e.setSubStatus("Case created"); e.setUSONACMProviderId("1-355-7215"); e.setUSONClinicalContactId("1-31L-8882"); e.setUSONPatientId("1-36Q-10478"); e.setUSONProgram("Shire"); e.setUSONReferralState("TX"); e.setUSONCaseNotes("JMS Case ID: " + caseID); list.getBpServiceRequest().add(e); input.setListOfBpsrcaseregistration(list); // Prepare for call to Web Service // Add the method parameters to a list, and initialize the message with this parameter list List outElements = new ArrayList<Element>(); outElements.add(input); // for details of packing params and preparing Exchange for CXF producer endpoint see: // http://camel.apache.org/cxf.html#CXF-HowtopreparethemessageforthecamelcxfendpointinPOJOdataformat // and // http://camelbot.blogspot.com/2010/10/should-you-getin-or-getout.html // TODO: may be more efficient to set the In (i.e. 'exchange.getIn().setBode()' , etc) // This works so i'm leaving for now (lowry curry) exchange.getOut().setBody(outElements); exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setHeader(CxfConstants.OPERATION_NAME, "CaseReg"); exchange.getOut().setHeader(CxfConstants.OPERATION_NAMESPACE, "http://www.USON/BP/siebel/Case/CaseRegistration"); // passing (out-of-band) values to subsequent processor exchange.getOut().setHeader("callingSite", callingSite); exchange.getOut().setHeader("callingUser", callingUser); exchange.getOut().setHeader("caseID", caseID); }

          People

          • Assignee:
            Torsten Mielke
            Reporter:
            Lowry Curry
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: