Cormedan
Cormedan

Reputation: 23

How do I use Camel mina hl7codec in an OSGi container (JBoss Fuse)

I have the following bean defined in my Spring DSL Camel context:

<bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
    <property name="charset" value="iso-8859-1" />
</bean> 

And I use here at the start of a route:

<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- <dataFormats><camel:hl7/></dataFormats> -->
<route id="input">

    <!-- Here is the HL7 Receiver -->
    <from uri="mina2:tcp://0.0.0.0:19191?sync=true&amp;codec=#hl7codec" id="CMHL7ReceiverTrinFeed"/>
<to uri="direct:process"/>   
   </route> 

When I run my Camel context as a local context, i.e. in the Eclipse Fuse IDE, everything is fine. A connection is opened at port 19191 and I happily receive HL7 MLLP messages from a sending system. However, when I run the bundle in a local instance of the JBoss Fuse Karaf, I get the following runtime exception:

JBossFuse:karaf@root> Exception in thread "SpringOsgiExtenderThread-2" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route input: Route[[From[mina2:tcp://0.0.0.0:19191?sync=true&codec=#hl7co... because of Failed to resolve endpoint: mina2://tcp://0.0.0.0:19191?codec=%23hl7codec&sync=true due to: Could not find a suitable setter for property: codec as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.mina.filter.codec.ProtocolCodecFactory with value #hl7codec

It was my understanding from Claus Ibsen's invaluable "Camel In Action" book that in an OSGi environment Camel will fall back on the default ApplicationContextRegistry if a service isn't named in the OSGi service registry. I don't know if that is relevant here or if there is an issue somewhere else. I'm not sure why a suitable setter for property: codec can be found in one runtime environment and not another. The bundle installs fine so I think I have all the dependencies taken care but starting the bundle throws this exception.

Thanks for any advice and help. I'd be glad to provide more information if necessary. Using JBoss Fuse (6.0.0.redhat-056), JDK 1.7.0_45

Upvotes: 2

Views: 598

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55760

JBoss Fuse 6.0 comes with Apache Camel 2.10.x. And the camel-hl7 component is using Mina 1.x in that release. So you need to use mina, and not mina2.

You can see from the hl7 documentation which mina component to use: http://camel.apache.org/hl7 (See the last bullet on the top of the page)

Upvotes: 0

Related Questions