You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Madhav Bhargava <un...@gmail.com> on 2010/10/11 08:59:03 UTC

OSGi + ActiveMQBlob Message with Camel does not pick up the custom type converter

Hi All,

I have a simple camel route where a ActiveMQBlobMessage is created and put
into a JMS endpoint and then passed to a file endpoint to be written to a
file.

I have the following spring-camel configuration:

<bean id="connectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
        <constructor-arg
value="vm://localhost:40016?jms.blobTransferPolicy.uploadUrl=ftp://user:password@localhost/archive/"
/>
              <property name="maxConnections" value="16" />
</bean>

<camelContext trace="true" id="blob_message_route" xmlns="
http://camel.apache.org/schema/spring">
        <route>
            <!-- <from uri="activemq:queue:in.q?messageConverter=#converter"
/> -->
            <from uri="activemq:queue:in.q" />
            <to
uri="file:///c:/temp/?fileName=result-${date:now:yyyyMMddHHmmssSSS}.txt" />
        </route>
</camelContext>

I have also created a custom type converter which converts from BlobMessage
to InputStream and added a fall back converter to it as well. I have exposed
this converter as a separate OSGi service. When the run time starts then the
service is properly registered and is active. When i put a break point in
activator the custom converter is picked up properly and registered.

However JmsBinding fails to create message body as there is no inherent
support for ActiveMQBlobMessage (understandably since it is not a part of
standard JMS spec) however a plug should have been provided for custom types
here so that a body could be created.

It finally looks for StreamCache to JmsMessage converter which it cannot
find. I am not sure yet where StreamCache comes from because in this route i
only need an InputStream outbound and not a StreamCache. Since is not able
to find a converter it fails as well.

There is only one way i could make the ActiveMQBlobMessage work and that is
by creating a custom MessageConverter and registering it on the URI (which
in my opinion is not a proper way of doing it) - <from
uri="activemq:queue:in.q?messageConverter=#converter" />

Where does the type converter get picked up from the TypeConverterRegistry?
I will put some break points in DefaultTypeConverter as that is the only
implementation of TypeConverterRegistry i could locate and check how i can
make camel recognize the custom type converter.

Any help would be really appreciated.


Best Regards,
Madhav


-- 
When I tell the truth, it is not for the sake of convincing those who do not
know it, but for the sake of defending those that do

Re: OSGi + ActiveMQBlob Message with Camel does not pick up the custom type converter

Posted by Willem Jiang <wi...@gmail.com>.
Hi

Did you have chance to go through these document[1]?
You need to add some @Converter,@FallbackConverter annotations and 
update the file of META-INF/services/org/apache/camel/TypeConverter.

[1]http://camel.apache.org/type-converter.html


On 10/11/10 2:59 PM, Madhav Bhargava wrote:
> Hi All,
>
> I have a simple camel route where a ActiveMQBlobMessage is created and put
> into a JMS endpoint and then passed to a file endpoint to be written to a
> file.
>
> I have the following spring-camel configuration:
>
> <bean id="connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>          <constructor-arg
> value="vm://localhost:40016?jms.blobTransferPolicy.uploadUrl=ftp://user:password@localhost/archive/"
> />
>                <property name="maxConnections" value="16" />
> </bean>
>
> <camelContext trace="true" id="blob_message_route" xmlns="
> http://camel.apache.org/schema/spring">
>          <route>
>              <!--<from uri="activemq:queue:in.q?messageConverter=#converter"
> />  -->
>              <from uri="activemq:queue:in.q" />
>              <to
> uri="file:///c:/temp/?fileName=result-${date:now:yyyyMMddHHmmssSSS}.txt" />
>          </route>
> </camelContext>
>
> I have also created a custom type converter which converts from BlobMessage
> to InputStream and added a fall back converter to it as well. I have exposed
> this converter as a separate OSGi service. When the run time starts then the
> service is properly registered and is active. When i put a break point in
> activator the custom converter is picked up properly and registered.
>
> However JmsBinding fails to create message body as there is no inherent
> support for ActiveMQBlobMessage (understandably since it is not a part of
> standard JMS spec) however a plug should have been provided for custom types
> here so that a body could be created.
>
> It finally looks for StreamCache to JmsMessage converter which it cannot
> find. I am not sure yet where StreamCache comes from because in this route i
> only need an InputStream outbound and not a StreamCache. Since is not able
> to find a converter it fails as well.
>
> There is only one way i could make the ActiveMQBlobMessage work and that is
> by creating a custom MessageConverter and registering it on the URI (which
> in my opinion is not a proper way of doing it) -<from
> uri="activemq:queue:in.q?messageConverter=#converter" />
>
> Where does the type converter get picked up from the TypeConverterRegistry?
> I will put some break points in DefaultTypeConverter as that is the only
> implementation of TypeConverterRegistry i could locate and check how i can
> make camel recognize the custom type converter.
>
> Any help would be really appreciated.
>
>
> Best Regards,
> Madhav
>
>


-- 
Willem
----------------------------------
Open Source Integration: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang