-
Exception handling
Hi,
I have an application what use WebSphere MQ to messaage processing.
I send message with jms:outbound-channel-adapter. It works correcly, but...
I have to know, the send was success or not.
Before this soulution, I wrote the "simple" send process, when if I got an exception, then I can resend the message or set the status. (For example: Exception because the queueu managed doesn't run, etc.)
At this time, I have no information about the sending. I know, this errors come from system, not application error, but the unsuccessfull message sending without processing the error is business problem.
I try to use "errorChannell", but I did not get message.
The configuration:
Code:
<bean id="connectionFactoryFCC" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value="${MQ_FCC_HOST}" />
<property name="port" value="${MQ_FCC_PORT}" />
<property name="queueManager" value="${MQ_FCC_QUEUE_MANAGGER}" />
<property name="CCSID" value="${MQ_FCC_CCSID}" />
<property name="channel" value="${MQ_FCC_CHANNEL}" />
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP" />
</property>
</bean>
<si:gateway id="outMqMessage" service-interface="com.MQReader.OutMqMessage" />
<si:channel id="outMessSplit" />
<si:channel id="outMessRouter" />
<si:channel id="outMessSendFcc" />
<si:channel id="outMessSendFccErr" />
<si:channel id="outMessSendSap" />
<si:channel id="outMessSendCec" />
<si:channel id="errorChannel" >
<si:queue capacity="500" />
</si:channel>
<stream:stderr-channel-adapter id="stdOutErr" channel="errorChannel" append-newline="true" />
<bean id="mqMsgConv" class="com.MQReader.MqMsgConv" >
<property name="Source" value="${MQ_FCC_SOURCE}" />
<property name="Destination" value="${MQ_FCC_DEST}" />
<property name="JmsType" value="${GF_MSG_NAME}" />
</bean>
<bean id="outputDestination" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="${MQ_FCC_OUTPUT_QUEUE}"/>
<property name="TargetClient">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_CLIENT_JMS_COMPLIANT" />
</property>
</bean>
<jms:outbound-channel-adapter id="sendMessageFcc"
connection-factory="connectionFactoryFCC"
destination="outputDestination"
channel="outMessSendFcc"
message-converter="mqMsgConv"
/>
The exception on "main" level:
Code:
Exception in thread "main" org.springframework.integration.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler#0]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:84)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
... 42 more
Could someone show me the working solution to this problen?
Thx!
Feri
-
Well, the fact that you got exception thrown back to you (the caller) is a correct behavior. The error-channel only plays a role in the async flows.
For example if the flow was picked up by a different thread (when using task-executor), then the calling thread (the client) has no way of knowing about the state of the flow because error will be re-thrown only to the beginning of the thread which is already outside of the client's boundary. In that case the executing thread has an option to generate the Error Message and send it to an error-channel form which you can retrieve the message which signals the failure of the flow. In the sync case (in your example), there is no need to send the message to the error channel because the beginning of the thread is the actual client. Think about it as real-time notification.
Does that help?
-
Hi Oleg,
Thank you, it has helped!
Finally I understand how does it work!
Feri
-
Exception handling
Hi Oleg,
Thank you, it has helped. Finally I will understand how does it work! :)
Thanks again!
Feri