Open-Source ESBs in Action: Example Implementations in Mule and ServiceMix by Jos Dirksen Tijs Rademakers

Open-Source ESBs in Action: Example Implementations in Mule and ServiceMix by Jos Dirksen Tijs Rademakers

Author:Jos Dirksen Tijs Rademakers [Tijs Rademakers, Jos Dirksen]
Language: eng
Format: mobi
Publisher: Manning Publications
Published: 2011-07-08T14:45:05.138000+00:00


host The location where the JNDI registry is running

port The port the JNDI registry is running on

method The method to invoke on the remote EJB

object The name under which the EJB is registered

Note that the default EJB connector in Mule doesn’t support EJB 3, but only EJB 2.1. So the Mule EJB connector will expect an EJB home interface to be available. Luckily, we can easily make our EJB 3 implementation of the person service (listing 6.36) EJB 2.1–compliant by adding a @RemoteHome annotation, which references a PersonServiceEJBHome interface. We also need to implement an EJB object interface class with PersonServiceEJB-Object. Now our person service is EJB 2.1–compliant and we can invoke the EJB with the Mule EJB connector.

Make sure the OpenEJB container is started (ext:start-openejb) and the EJB is deployed (chapter6-ejb-deploy-ejb). When you run this example with the chapter6-ejb Ant target and drop the test file, query-person.txt, into the chapter6/6-ejb/in directory, you’ll see that this method is invoked and that the Persons found are stored in the directory specified by the last endpoint. Now let’s move on to the last section of this chapter, where we implement the same example in ServiceMix.

6.6.2. EJB 3 and ServiceMix

ServiceMix doesn’t provide a standard EJB binding component or service engine. Various JBI-based EJB binding components are available that we can use instead. However, in this section we show how you can use Spring with the ServiceMix JSR181 binding component to provide EJB 3 connectivity.

With this component, it’s very easy to expose POJOs as services. To use this functionality to connect to EJBs, we use Spring’s JndiObjectFactoryBean. With this component we can expose a remote EJB 3 bean and access it as a normal POJO, so with this Spring bean we can use the JSR181 component to expose remote EJBs. You might remember the servicemix-bean component from chapter 3, which could also be used to expose POJOs to ServiceMix. The main difference is that with the servicemix-bean component, we need to implement a couple of lifecycle methods and be able to handle the JBI-specific way services are called. When we use the JSR181 binding component, we can just expose a POJO and don’t have to worry about the underlying JBI specifics.

Listing 6.40 shows how you need to configure Spring and this component so that you can access remote EJBS.

Listing 6.40. ServiceMix configuration that exposes EJBs as services to the NMR



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.