JMS Error handling in Switchyard
patrickawilson Dec 7, 2013 3:10 PMI am trying to get Switchyard to handle a JMS send failure. The happy path is to have the message hit the GenericGSCIMServiceBean where it is processed and a message is sent to an external JMS queue. This works.
In my test case I intentionally misconfigure the connectivity information to cause a failure. The error handling goal is to route the same message to an error handler upon failure of GenericGSCIMServiceBean. My problem is that the underlying framework is swallowing the exception. It is not propagated up through GenericGSCIMServiceBean (there would be no need for a separate error handler if it was) nor is the GenericGSCIMErrorHandlerBean being invoked.
from("switchyard://GenericGSCIMService") | |
.to("switchyard://GenericGSCIMServiceBean") | |
.onException(java.lang.Exception.class) | |
.to("switchyard://GenericGSCIMErrorHandlerBean"); |
I would expect GenericGSCIMErrorHandlerBean to be invoked upon failure, but it is not. What happens instead is that GenericGSCIMServiceBean simply completes as though the delivery was successful.
The message trace is below:
13:34:16,848 ERROR [org.switchyard.bus.camel.DefaultErrorListener] (http-localhost/127.0.0.1:8088-1)
------- Begin Message Trace -------
Consumer -> {urn:com.example.switchyard:GSCIMSwitchyard:1.0}GenericGSCIMServiceBean/ConsertOpsCenterService
Provider -> {urn:com.example.switchyard:GSCIMSwitchyard:1.0}ConsertOpsCenterService
Operation -> send
MEP -> IN_ONLY
Phase -> IN
State -> OK
Exchange Context ->
CamelCreatedTimestamp ............................: Sat Dec 07 13:34:15 CST 2013
CamelExceptionCaught .............................: org.switchyard.HandlerException: SWITCHYARD037234: Failed to process JMS outbound interaction
CamelFailureEndpoint .............................: direct://%7Burn:com.example.switchyard:GSCIMSwitchyard:1.0%7DGenericGSCIMServiceBean/ConsertOpsCenterService
CamelFilterMatched ...............................: false
CamelToEndpoint ..................................: direct://%7Burn:com.example.switchyard:GSCIMSwitchyard:1.0%7DGenericGSCIMServiceBean/ConsertOpsCenterService
org.switchyard.bus.camel.consumer ................: ServiceReference [name={urn:com.example.switchyard:GSCIMSwitchyard:1.0}GenericGSCIMServiceBean/ConsertOpsCenterService, interface=SWITCHYARD010007: BaseServiceInterface [type=java, operations=[SWITCHYARD010008: send : IN_ONLY : [java:byte[], null, null]]], domain=ServiceDomain [name=null]]
org.switchyard.bus.camel.contract ................: org.switchyard.metadata.BaseExchangeContract@7fab60fc
org.switchyard.bus.camel.dispatcher ..............: org.switchyard.bus.camel.ExchangeDispatcher@67c27eab
org.switchyard.bus.camel.labels ..................: {org.switchyard.exchangeGatewayName=[org.switchyard.label.behavior.transient], org.switchyard.exchangeInitiatedNS=[org.switchyard.label.behavior.transient], org.switchyard.exchange.transaction.beforeInvoked=[org.switchyard.label.behavior.transient], org.switchyard.security.context.SecurityContext=[org.switchyard.label.behavior.transient]}
org.switchyard.bus.camel.phase ...................: IN
org.switchyard.bus.camel.provider ................: Service [name={urn:com.example.switchyard:GSCIMSwitchyard:1.0}ConsertOpsCenterService, interface=SWITCHYARD010007: BaseServiceInterface [type=java, operations=[SWITCHYARD010008: send : IN_ONLY : [java:byte[], null, null]]], domain=ServiceDomain [name=null], metadata=org.switchyard.metadata.ServiceMetadataBuilder$ServiceMetadataImpl@1b9c0622]
org.switchyard.exchange.transaction.beforeInvoked : true
org.switchyard.exchangeGatewayName ...............: _ConsertOpsCenterService_jca_1
org.switchyard.exchangeInitiatedNS ...............: 108928955949314
org.switchyard.security.context.SecurityContext ..: DefaultSecurityContext@542552151[systemUUID=8b95a749-1954-4702-b154-80bc9c688561, expirationMillis=0, credentials=[ConfidentialityCredential@458436695[confidential=false]], securityDomainsToSubjects={}]
Message Context ->
breadcrumbId ..............................: ID-CONSERT-SA101-64859-1386444499824-4-6
org.switchyard.bus.camel.labels ...........: {org.switchyard.contentType=[org.switchyard.label.behavior.transient], org.switchyard.bus.camel.messageSent=[org.switchyard.label.behavior.transient], org.switchyard.transform.TransformSequence=[org.switchyard.label.behavior.transient]}
org.switchyard.bus.camel.messageSent ......: true
org.switchyard.contentType ................: java:byte[]
org.switchyard.messageId ..................: ID-CONSERT-SA101-64859-1386444499824-4-6
org.switchyard.transform.TransformSequence : org.switchyard.transform.TransformSequence@728aadc4
------ End Message Trace -------
The exceptions are exactly what one would expect given bad connectivity data - connection refused, etc.
Caught exception of type org.switchyard.HandlerException with message: SWITCHYARD037234: Failed to process JMS outbound interaction
Caused by exception of type com.ibm.msg.client.jms.DetailedJMSException, message: MQJCA1011: Failed to allocate a JMS connection.
Caused by exception of type javax.resource.ResourceException, message: IJ000658: Unexpected throwable while trying to create a connection: null
Caused by exception of type com.ibm.mq.connector.DetailedResourceException, message: MQJCA1011: Failed to allocate a JMS connection., error code: MQJCA1011
etc. etc. etc.
Caused by: com.ibm.msg.client.jms.DetailedJMSException: MQJCA1011: Failed to allocate a JMS connection.
An internal error caused an attempt to allocate a connection to fail.
See the linked exception for details of the failure.
at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:146)
Caused by: javax.resource.ResourceException: IJ000658: Unexpected throwable while trying to create a connection: null
Caused by: com.ibm.mq.connector.DetailedResourceException: MQJCA1011: Failed to allocate a JMS connection., error code: MQJCA1011 An internal error caused an attempt to allocate a connection to fail. See the linked exception for details of the failure.
Caused by: com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'LAB02OPSC01' with connection mode 'Client' and host name '10.18.20.136(12345)'.
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host '10.18.20.136(12345)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2538;AMQ9213: A communications error for occurred. [1=java.net.ConnectException[Connection refused: connect],3=vip-mq-lab02opsc01.fe.stg01.bwi01.consert.com]],3=10.18.20.136(12345),5=RemoteTCPConnection.connnectUsingLocalAddress]
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9213: A communications error for occurred. [1=java.net.ConnectException[Connection refused: connect],3=vip-mq-lab02opsc01.fe.stg01.bwi01.consert.com]
Caused by: java.net.ConnectException: Connection refused: connect