Forum Home » Fuse Distributions » Fuse ESB

Thread: FUSE ESB as a pass through?

 
This question is answered.


Permlink Replies: 16 - Last Post: Jan 8, 2012 12:31 AM Last Post By: ffang
hellosir1979

Posts: 14
Registered: 01/04/12
FUSE ESB as a pass through?
Posted: Jan 4, 2012 11:12 PM
 
  Click to reply to this thread Reply
Hi there,

Currently, I have two web services that call each other directly. I want to insert FUSE ESB in the middle as a straight pass through. What I want is for web service 1 to go through FUSE to get to web service 2.

The format I'm trying to use is

web service 1 --> endpoint-bc --> endpoint-se --> web service 2.

Lets say that web service 1 invokes a "test" operation on web service 2 currently.

What I want to happen now is that web service 1 invokes a "test" stub that then calls the actual "test" operation in web service 2.

Is this a good way to implement something like this? Or is there an easier way?

Thanks in advance.
mjabali

Posts: 25
Registered: 04/09/09
Re: FUSE ESB as a pass through?
Posted: Jan 4, 2012 11:31 PM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Hi,

I'd recommend you to take a look on the Apache Camel (FUSE Mediation Router) web service proxy sample available at http://camel.apache.org/cxf-proxy-example.html

Then you can host that web service proxy on FUSE ESB (ServiceMix).

There is also a thread that Claus Ibsen responded a similar question mentioning the reasons to follow that approach http://stackoverflow.com/questions/5939067/using-servicemix-to-proxy-remote-web-service ).

Hope this helps,

-Marcelo
ffang

Posts: 1,320
Registered: 12/24/07
Re: FUSE ESB as a pass through?
Posted: Jan 5, 2012 2:18 AM   in response to: mjabali in response to: mjabali
 
  Click to reply to this thread Reply
Hi,

Yeah, if you start a new project from the scratch, then we suggest you use camel component but not the JBI component.

If you have to stick to use JBI, then the work flow for your scenario is
cxfbc:consumer===>cxfse(web service1)===>cxfse:proxy(web service2)====>cxfbc:provider

the cxfse:proxy works as a normal object invocation
Take a look at [1] to get more details about how cxfse:proxy works, the "Proxies" part.

[1]http://servicemix.apache.org/servicemix-cxf-se.html

Freeman
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 7:15 PM   in response to: mjabali in response to: mjabali
 
  Click to reply to this thread Reply
Hi thanks for the help. I'm able to deploy the artifact into fuse esb 4.3.0, but when i try to start it i get this message

karaf@root> Exception in thread "SpringOsgiExtenderThread-17" java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 're
fresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplication
ContextExecutor.java:345)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.fail(DependencyWaiterApplicationC
ontextExecutor.java:401)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicat
ionContextExecutor.java:287)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicati
onContextExecutor.java:175)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.j
ava:175)
at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:718)
at java.lang.Thread.run(Thread.java:662)


Is there some feature or bundle I need to install to get this to work in Fuse?

Thanks in advance.

mjabali

Posts: 25
Registered: 04/09/09
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 7:24 PM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Couple of comments:
  • The current version of the FUSE ESB is 4.4.1. If you have no requirements to run your solution in 4.3 then you should move the latest release.
  • The reported exception doesn't tell us much. I'd suggest that you run:
karaf@root> log:display
and see if there is anything obvious there.
  • Can you tell us what approach are you using? Camel or JBI? Feel free to post your route to give us a better idea how/what are you trying to do.

-Marcelo
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 7:34 PM   in response to: mjabali in response to: mjabali
 
  Click to reply to this thread Reply
Hi,

We do have explicit instructions to be running 4.3.

In the servicemix.log,

this error seems to be what is causing the problem.

13:12:51,619 | ERROR | xtenderThread-17 | ContextLoaderListener | 72 - org.springframework.osgi.extender - 1.2.0 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=org.apache.camel.proxy, config=osgibundle:/META-INF/spring/*.xml))

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace http://camel.apache.org/schema/cxf
Offending resource: URL bundleentry://227.fwk31664352/META-INF/spring/camel-config.xml

at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)59:org.springframework.beans:3.0.5.RELEASE

mjabali

Posts: 25
Registered: 04/09/09
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 7:50 PM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Try running the following:
karaf@root> osgi:list |grep camel
and reporting the results back here in the forum...
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 7:56 PM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Hi, we are using camel route.

Here is the camel-config.xml

...

<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:${proxy.port}/cxs"
endpointName="s:Port"
serviceName="s:Service"
wsdlURL="etc/ts.wsdl"
xmlns:s="http://cxs/ts.wsdl"/>

<camelContext xmlns="http://camel.apache.org/schema/spring">

<propertyPlaceholder id="properties" location="classpath:incident.properties,file:target/custom.properties"/>

<endpoint id="callRealWebService" uri="http://cxs.com:7777/Service"/>

<route>
<!-- CXF consumer using MESSAGE format -->
<from uri="cxf:bean:reportIncident?dataFormat=MESSAGE"/>
<!-- log input received -->
<to uri="log:input"/>

<!-- send proxied request to real web service -->
<to ref="callRealWebService"/>
<!-- log answer from real web service -->
<to uri="log:output"/>
</route>

</camelContext>

...

hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 7:58 PM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
karaf@root> osgi:list | grep camel

68 Active [ ] [ ] 60 camel-core (2.6.0.fuse-03-01)
75 Active [ ] [ ] 60 camel-spring (2.6.0.fuse-03-01)
76 Active Created [ ] 60 camel-blueprint (2.6.0.fuse-03-01)
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 6, 2012 8:43 PM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Quick backtrack...

In the example linked below,

http://camel.apache.org/cxf-proxy-example.html

I am able to run it using mvn camel:run.

Question is, how do I then deploy this example to run in fuse esb servicemix?
mjabali

Posts: 25
Registered: 04/09/09
Re: FUSE ESB as a pass through?
Posted: Jan 7, 2012 1:51 AM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Try adding the following to your pom file:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>

If I remember correctly you also need to install the camel-http feature before you deploy this bundle.
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 7, 2012 2:38 AM   in response to: mjabali in response to: mjabali
 
  Click to reply to this thread Reply
Hi,

I added the plugin you suggested to my pom file, but still same error when I try to start the bundle.

i installed the

camel-cxf
camel-http
camel-spring

as you can see by the lines below

200 Active [ ] [ ] 60 camel-cxf (2.6.0.fuse-03-01)
201 Active [ ] [ ] 60 camel-http (2.6.0.fuse-03-01)
204 Active [ ] [ ] 60 camel-spring (2.6.0.fuse-03-01)
205 Installed [ ] [ ] 60 camel-example-cxf-proxy (2.7.1.fuse-00-27)

when i run

karaf@root> osgi:start 205

this error occurs, and I cannot figure out what I am missing or doing wrong.

Please help! Thanks a lot in advance!!

Error executing command: The bundle "org.apache.camel.camel-example-cxf-proxy_2.7.1.fuse-00-27 205" could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.camel.spring; version="[2.7.0,2.8.0)"


I also copied the error from the servicemix.log


org.osgi.framework.BundleException: The bundle "org.apache.camel.camel-example-cxf-proxy_2.7.1.fuse-00-27 205" could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.camel.spring; version="[2.7.0,2.8.0)"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1317)osgi-3.6.0.v20100517.jar:
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1301)osgi-3.6.0.v20100517.jar:
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:319)osgi-3.6.0.v20100517.jar:
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:284)osgi-3.6.0.v20100517.jar:
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:276)osgi-3.6.0.v20100517.jar:
at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:29)27:org.apache.karaf.shell.osgi:2.1.6.fuse-01-01
at org.apache.karaf.shell.osgi.BundlesCommand.doExecute(BundlesCommand.java:49)27:org.apache.karaf.shell.osgi:2.1.6.fuse-01-01
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at org.apache.karaf.shell.console.jline.Console.run(Console.java:170)14:org.apache.karaf.shell.console:2.1.6.fuse-01-01
at java.lang.Thread.run(Thread.java:662):1.6.0_27


here is the camel-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: e1 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">

<!-- needed cxf imports -->
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>

<!-- use a bean to start and stop the real web service (is not Camel specific) -->
<!-- in a real use-case the real web service would be located on another server
but we simulate this in the same JVM -->
<bean id="realWebService" class="org.apache.camel.example.cxf.proxy.RealWebServiceBean"
init-method="start" destroy-method="stop">
<!-- this is the url of the real web service we have proxied -->
<property name="url" value="http://localhost:9081/real-webservice"/>
</bean>

<!-- a bean to enrich the input -->
<bean id="enrichBean" class="org.apache.camel.example.cxf.proxy.EnrichBean"/>

<!-- this is the CXF webservice we use as front end -->
<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:9080/camel-example-cxf-proxy/webservices/incident"
endpointName="s:ReportIncidentEndpoint"
serviceName="s:ReportIncidentEndpointService"
wsdlURL="etc/report_incident.wsdl"
xmlns:s="http://reportincident.example.camel.apache.org"/>

<!-- this is the camel route which proxy the web service and forward it to the real web service -->
<camelContext xmlns="http://camel.apache.org/schema/spring">

<route>
<!-- cxf consumer using MESSAGE format -->
<from uri="cxf:bean:reportIncident?dataFormat=MESSAGE"/>
<!-- log input received -->
<to uri="log:input"/>
<!-- enrich the input by ensure the incidentId parameter is set -->
<to uri="bean:enrichBean"/>
<!-- send proxied request to real web service -->
<to uri="http://localhost:9081/real-webservice?throwExceptionOnFailure=false"/>
<!-- log answer from real web service -->
<to uri="log:output"/>
</route>

</camelContext>

</beans>


and here is the pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.camel</groupId>
<artifactId>examples</artifactId>
<version>2.7.1-fuse-00-27</version>
</parent>

<artifactId>camel-example-cxf-proxy</artifactId>
<name>Camel :: Example :: CXF Proxy</name>
<description>An example which uses Camel to proxy a web service</description>
<packaging>bundle</packaging>

<properties>
<camel.osgi.export.pkg>
org.apache.camel.example.*
</camel.osgi.export.pkg>
<camel.osgi.import.additional>
META-INF.cxf
</camel.osgi.import.additional>
<camel.osgi.private.pkg>
org.apache.camel.example.reportincident
</camel.osgi.private.pkg>
<!-- to avoid us import bunch of cxf package -->
<camel.osgi.dynamic>*</camel.osgi.dynamic>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.7.0</version>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>

<!-- cxf -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>${cxf-version}</version>
</dependency>
<!-- used by the real web service -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<!-- regular http transport -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>

<!-- logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>

<!-- cxf web container for unit testing -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf-version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<!-- CXF wsdl2java generator, will plugin to the compile goal -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf-version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/etc/report_incident.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>


</plugins>
</build>
</project>


The pom and camel-config are straight from the camel-example-cxf-proxy with the one plugin you had me put in.

To deploy the bundle, i did a "mvn install" and then copied the jar into the "deploy" folder of servicemix.

It installs, but is unable to start with that error message.

mjabali

Posts: 25
Registered: 04/09/09
Re: FUSE ESB as a pass through?
Posted: Jan 7, 2012 3:17 AM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
On your pom file, where you have the camel-spring dependency:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.7.0</version>
</dependency>

remove the version and re-deploy to see if that solves the problem. So, it should be like this:

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</dependency>

Please let me know if that works for you...
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 7, 2012 3:28 AM   in response to: mjabali in response to: mjabali
 
  Click to reply to this thread Reply
Hi, I tried what you said and still the same error.
mjabali

Posts: 25
Registered: 04/09/09
Re: FUSE ESB as a pass through?
Posted: Jan 7, 2012 5:47 AM   in response to: hellosir1979 in response to: hellosir1979
Correct
  Click to reply to this thread Reply
I noticed you're deploying the jar file onto the $SMX/deploy directory and that may be causing the issue once the camel version might not be matching.

I could successfully deploy the sample on SMX 4.3.1 using the following in the ServiceMix console:

karaf@root> osgi:install mvn:org.apache.camel/camel-example-cxf-proxy/2.6.0

Hope this helps
hellosir1979

Posts: 14
Registered: 01/04/12
Re: FUSE ESB as a pass through?
Posted: Jan 7, 2012 9:25 AM   in response to: mjabali in response to: mjabali
 
  Click to reply to this thread Reply
Very interesting. I have been installing it thru $SMX/deploy and also by typing this

karaf@root> osgi:install mvn:org.apache.camel/camel-example-cxf-proxy

However, both ways did not work.

Once I added the "/2.6.0" like you did, it is able to start.

Thank you for the help, although I am puzzled as to why it works.
ffang

Posts: 1,320
Registered: 12/24/07
Re: FUSE ESB as a pass through?
Posted: Jan 8, 2012 12:31 AM   in response to: hellosir1979 in response to: hellosir1979
 
  Click to reply to this thread Reply
Hi,

The error is caused by that your camel version mismatch, the FUSE ESB 4.3 use camel version 2.6.x, so this container provider camel package range like [2.6, 2.7), however your example need camel version 2.7.x, so that the container can't meet the example bundle requirement.
You should be careful the package version when you use OSGi bundles.

Freeman