1

currently I am working with camel and wmq. What I tried to do is sending a message to wmq. I configure the camel by using Spring Framework. Here is how configure the wmq:

component.xml

<bean id="websphere-mq" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory">
            <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
                <property name="transportType">
                    <util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP" />
                </property>
                <property name="hostName" value="localhost" />
                <property name="port" value="1414" />
                <property name="queueManager" value="localmanager" />
                <property name="channel" value="CH.ADM1" />
                <property name="CCSID" value="819"/>
                <property name="useConnectionPooling" value="true" />
            </bean>
        </property>
</bean>

config.xml

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

    <route>
        <from uri="stream:in?promptMessage=Ausweisnummer: "/>
        <process ref="TransformToXML"/>
        <to uri ="xslt:mobako.sender.xsl"/>
        <to uri ="websphere-mq:queue:LSMH.ZKSEAP.SERVICEBUS"/>
    </route>

    <route>
        <from uri="websphere-mq:queue:ZKSEAP.LSMH.SERVICEBUS"/>
        <to uri="stream:out"/>
    </route>

</camelContext>

When I check the to the wmq, I found out that the wmq has been listening to my process, but it did not get any message.

Then to check if my wmq configuration is right, I tried to change my config.xml into something like this:

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

    <route>
        <from uri="websphere-mq:queue:ZKSEAP.LSMH.SERVICEBUS"/>
        <to uri="stream:out"/>
    </route>

</camelContext>

After that I tried to write the message manually to the wmq. And when I tried to run my process, then the message from wmq is writen on my console.

Then, I sum up that, with my configuration, I can get the message from the wmq, but I can not write to wmq.

What is the problem actually? Is there something wrong or missing from my configuration? Thanks so much.

EDITED

Hey, finally I found out what is wrong. The problem is: my jms version not the same with my camel version. But, after I changed the jms version, I got following error (regarding to the wmq) on my server:

2014-06-05 15:14:34,859 [Axis2 Task] ERROR WMQMsg - Expected MQ message format ' MQSTR ', but received 'MQHRF2 '

How to solve it? Thanks again.

pokopang
  • 507
  • 1
  • 11
  • 27
  • do you observe any errors thrown at the mq layer? Any mq return code in the linked exception? Does the queue you are trying to put has put authority for this application or channel? Are you running MQ 7.1/7.5 or below? – Umapathy Jun 05 '14 at 10:25
  • I have checked it and there is no errors. Fyi I am running MQ 7.1 – pokopang Jun 05 '14 at 11:08
  • Are you sure you have a valid exchange body after the `xslt:` line, can you add a log statement between that and the next line? – vikingsteve Jun 05 '14 at 12:38
  • hi nsupathy and vikingsteve, I have found out the problem, which is my jms version. But I got a new error regarding to the wmq. which said: "2014-06-05 15:14:34,859 [Axis2 Task] ERROR WMQMsg - Expected MQ message format ' MQSTR ', but received 'MQHRF2 '" Do you know how to solve it? Thanks a bunch – pokopang Jun 05 '14 at 13:28
  • MQHRF2 is the MQ JMS format. The message usually has a header (in XML) whereas MQSTR is just plain text. The reader is expecting a plain text message but encountering a JMS format instead. – Umapathy Jun 05 '14 at 13:59
  • then, how can I solve it? – pokopang Jun 05 '14 at 14:01
  • why "axis2 task" error message? – Petter Nordlander Jun 05 '14 at 21:52
  • Did you see my answer in your latest question? http://stackoverflow.com/questions/24014807/apache-camel-is-it-possible-to-configure-wmq-without-using-spring/24028672#24028672 – Aliti Jun 06 '14 at 03:55

2 Answers2

0

I think your problem is in your JMS message types and conversion. Please see following link and try to convert your message type that you get from stream:in.

http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.0.1/com.ibm.mq.csqzaw.doc/jm25524_.htm?cp=SSFKSJ_7.0.1%2F1-25-3-4-1-1-1&lang=en

http://www.capitalware.com/rl_blog/?p=1168

Processing MQ ByteMessage using JMS client

Community
  • 1
  • 1
Aliti
  • 2,025
  • 2
  • 27
  • 39
0

Firstly, I don't really understand your route:

Specifically, you have two .to uris. Maybe I am wrong, but logically you'd need some kind of logic to route a message to one endpoint or another.

Secondly, if I may, I will provide you with a solution that worked for me. As I understood, you only need to set up a camel endpoint of type jms, and then let the camel do all the boilerplate code for you. You do require a specific ConnectionFactory (in our case wmq). I will create it in Java, doing it with Spring beans just adds complexity.

CamelContext camelContext = new DefaultCamelContext();
    MQQueueConnectionFactory connectionFactory = new MQQueueConnectionFactory();
    connectionFactory.setHostName("localhost");
try {
        connectionFactory.setPort(1414);
        connectionFactory.setQueueManager("QueueManagerName");
        connectionFactory.setChannel("ChannelName");
        connectionFactory.setTransportType(1);
    } catch (JMSException e) {
        e.printStackTrace();
    }
    camelContext.addComponent("wmq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

For the second part, we can use the wmq as any other endpoint.

try {
        camelContext.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("file://data/in/?noop=true")
                        .to("wmq:queue:YourQueueName");
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
moldovean
  • 3,132
  • 33
  • 36