CXF + ActiveMQ + MTOM Problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CXF + ActiveMQ + MTOM Problem

lightning
Hi everyone,

I'm relative new to the subject of Webservice and JMS programming. So i ran into many problems which i eventually could solve. But now there is something i do not understand.

On serverside i've got a byte[] which is passed to the client via DataHandler. On the serverside (length = 176844) when the array get through on the clientside per

mtomIn = (InputStream) handler.value.getContent();
byte[] byteArray=org.apache.commons.io.IOUtils.toByteArray(mtomIn);

the byte[] length = 304977 and the File is corruted. Anybody an idea?

Thank you in advance!

My beans.xml:

<bean id="jmsConnectionFactory"
                class="org.springframework.jms.connection.CachingConnectionFactory">
                <property name="targetConnectionFactory">
                        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                                <property name="brokerURL" value="tcp://localhost:61616" />
                        </bean>
                </property>
        </bean>


        <bean id="jmsConfig" class="org.apache.cxf.transport.jms.JMSConfiguration"
                p:connectionFactory-ref="jmsConnectionFactory" p:targetDestination="webmediator.query.queue" />


        <bean id="jmsConfigData" class="org.apache.cxf.transport.jms.JMSConfiguration"
                p:connectionFactory-ref="jmsConnectionFactory" p:targetDestination="webmediator.data.queue" />


        <jaxws:endpoint xmlns:tns="http://web.biba.de/" id="webmediator"
                implementor="de.biba.web.WebMediatorImpl" endpointName="tns:WebMediatorImplPort"
                serviceName="tns:WebMediatorImplService" address="jms://">
                <jaxws:features>
                        <bean class="org.apache.cxf.feature.LoggingFeature" />
                        <bean class="org.apache.cxf.transport.jms.JMSConfigFeature"
                                p:jmsConfig-ref="jmsConfig" />
                </jaxws:features>
        </jaxws:endpoint>


        <jaxws:endpoint xmlns:tns="http://web.biba.de/" id="webmediatorData"
                implementor="de.biba.web.WebMediatorDataImpl" endpointName="tns:WebMediatorDataImplPort"
                serviceName="tns:WebMediatorDataImplService" address="jms://">
                <jaxws:features>
                        <bean class="org.apache.cxf.feature.LoggingFeature" />
                        <bean class="org.apache.cxf.transport.jms.JMSConfigFeature"
                                p:jmsConfig-ref="jmsConfigData" />
                </jaxws:features>
                <jaxws:properties>
                        <entry key="mtom-enabled" value="true" />
                </jaxws:properties>
        </jaxws:endpoint>
Reply | Threaded
Open this post in threaded view
|

Re: CXF + ActiveMQ + MTOM Problem

Freeman-2
Hi,

You need add
messageType="binary"
for your jmsConfig, this can ensure that using binary mode to transfer the mtom attachment.

And we need check if  it's mtom enabled in JMSDestination before we send back response message, if it's mtom enabled and has attachments we need set messageType as binary. We have done similar check on JMSConduit(client side) but don't do it for server side.

Freeman
-------------
Freeman Fang

FuseSource
Email:[hidden email]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-9-1, at 上午3:47, lightning wrote:

> Hi everyone,
>
> I'm relative new to the subject of Webservice and JMS programming. So i ran
> into many problems which i eventually could solve. But now there is
> something i do not understand.
>
> On serverside i've got a byte[] which is passed to the client via
> DataHandler. On the serverside (length = 176844) when the array get through
> on the clientside per
>
> mtomIn = (InputStream) handler.value.getContent();
> byte[] byteArray=org.apache.commons.io.IOUtils.toByteArray(mtomIn);
>
> the byte[] length = 304977 and the File is corruted. Anybody an idea?
>
> Thank you in advance!
>
> My beans.xml:
>
> <bean id="jmsConnectionFactory"
> class="org.springframework.jms.connection.CachingConnectionFactory">
> <property name="targetConnectionFactory">
> <bean class="org.apache.activemq.ActiveMQConnectionFactory">
> <property name="brokerURL" value="tcp://localhost:61616" />
> </bean>
> </property>
> </bean>
>
>
> <bean id="jmsConfig" class="org.apache.cxf.transport.jms.JMSConfiguration"
> p:connectionFactory-ref="jmsConnectionFactory"
> p:targetDestination="webmediator.query.queue" />
>
>
> <bean id="jmsConfigData"
> class="org.apache.cxf.transport.jms.JMSConfiguration"
> p:connectionFactory-ref="jmsConnectionFactory"
> p:targetDestination="webmediator.data.queue" />
>
>
> <jaxws:endpoint xmlns:tns="http://web.biba.de/" id="webmediator"
> implementor="de.biba.web.WebMediatorImpl"
> endpointName="tns:WebMediatorImplPort"
> serviceName="tns:WebMediatorImplService" address="jms://">
> <jaxws:features>
> <bean class="org.apache.cxf.feature.LoggingFeature" />
> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature"
> p:jmsConfig-ref="jmsConfig" />
> </jaxws:features>
> </jaxws:endpoint>
>
>
> <jaxws:endpoint xmlns:tns="http://web.biba.de/" id="webmediatorData"
> implementor="de.biba.web.WebMediatorDataImpl"
> endpointName="tns:WebMediatorDataImplPort"
> serviceName="tns:WebMediatorDataImplService" address="jms://">
> <jaxws:features>
> <bean class="org.apache.cxf.feature.LoggingFeature" />
> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature"
> p:jmsConfig-ref="jmsConfigData" />
> </jaxws:features>
> <jaxws:properties>
> <entry key="mtom-enabled" value="true" />
> </jaxws:properties>
> </jaxws:endpoint>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-ActiveMQ-MTOM-Problem-tp5713418.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: CXF + ActiveMQ + MTOM Problem

lightning
Ah! Thank you!
You really made my day!

Best regards