当前位置: 首页 > 知识库问答 >
问题:

如何将原始消息存储到JMS队列而不是组织中。springframework。消息传递。MessageDeliveryException表单

那铭
2023-03-14

我第一次使用Spring集成

脚本

  1. 从源JMS队列读取消息,然后推送到目标JMS队列使用的通道。如果目标Jndi名称错误,重试机制就会启动。
  2. 重试耗尽后,消息推送到异常JMS队列中。
  3. 所有队列都在我本地的Weblogic 12c中。该应用程序是Spring Boot 2.1.10。释放Spring集成5.1.9。释放
  4. 当目标JMS队列的Jndi正确时,则消息发送成功。这正在工作,我可以看到消息,因为我将提取有效负载设置为true。

问题:

  1. 我可以在异常队列中看到消息,但它的格式是org。springframework。消息传递。MessageDeliveryException无法查看,如上文第4点所述。是否可以将原始消息存储在异常队列而不是组织中。springframework。消息传递。MessageDeliveryException表单
  2. 如何使用下面的代码实现这一点

代码:[更新的soln]

@Configuration
@EnableRetry
@EnableIntegration
@Slf4j
public class JmsRoutingConfig {
    @Bean(name = "executor")
    ThreadPoolTaskExecutor executor() {
        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
        ...
        return threadPoolTaskExecutor;
    }

    public RequestHandlerRetryAdvice retryAdvice() {
        SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
        retryPolicy.setMaxAttempts(3);

        ExponentialBackOffPolicy exponentialBackOff = new ExponentialBackOffPolicy();
        exponentialBackOff.setInitialInterval(5000);
        exponentialBackOff.setMultiplier(2);
        exponentialBackOff.setMaxInterval(30 * 1000);

        RequestHandlerRetryAdvice retryAdvice = new RequestHandlerRetryAdvice();
        RetryTemplate retryTemplate = new RetryTemplate();
        retryTemplate.setBackOffPolicy(exponentialBackOff);
        retryTemplate.setRetryPolicy(retryPolicy);

        RecoveryCallback<Object> recoveryCallBack = new ErrorMessageSendingRecoverer(exceptionQueueChannel());
        retryAdvice.setRecoveryCallback(recoveryCallBack);
        retryAdvice.setRetryTemplate(retryTemplate);
        return retryAdvice;
    }

    @Bean(name = "exceptionQueueChannel")
    public PublishSubscribeChannel exceptionQueueChannel() {
       return new PublishSubscribeChannel();
    }

    @Bean(name = "errorChannel")
    public PublishSubscribeChannel errorChannel() {
        return new PublishSubscribeChannel();
    }

    @Bean
    public IntegrationFlow errorHandlingFlow() {
        return IntegrationFlows.from(errorChannel()).transform("payload.failedMessage").routeByException(r -> r.advice(retryAdvice())).get();
    }

    @Bean
    public IntegrationFlow exceptionHandlingFlow(@Qualifier("exceptionJmsTemplate") JmsTemplate exceptionJmsTemplate) {
    return IntegrationFlows.from(exceptionQueueChannel()).transform("payload.failedMessage").handle(Jms.outboundAdapter(exceptionJmsTemplate).extractPayload(true).get())
            .get();
    }

    @Bean(name = "multiSubcriptionChannel")
    public PublishSubscribeChannel multiSubcriptionChannel(@Qualifier("executor") ThreadPoolTaskExecutor executor) {
        return new PublishSubscribeChannel(executor);
    }

    @Bean(name = "headerValueRouter")
    public HeaderValueRouter headerValueRouter(@Qualifier("multiSubcriptionChannel") PublishSubscribeChannel multiSubcriptionChannel) {
        multiSubcriptionChannel.subscribe(Jms.outboundAdapter(getTargetJmsTemplate()).extractPayload(true).get());
        HeaderValueRouter router = new HeaderValueRouter("jms_correlationId");
        router.setChannelMapping("77", multiSubcriptionChannel.getBeanName());
        return router;
    }

    @Bean
    public IntegrationFlow inFlow(@Qualifier("headerValueRouter") HeaderValueRouter headerValueRouter) {
        return IntegrationFlows.from(jmsInboundChannel()).route(headerValueRouter).get();
    }

    @Bean(name = "listenerErrorChannel")
    public PublishSubscribeChannel listenerErrorChannel() {
        return new PublishSubscribeChannel();
    }

    @Bean
    public IntegrationFlow listenerErrorHandlingFlow() {
        return IntegrationFlows.from(listenerErrorChannel())
                .handle(message -> log.error("LISTENER error (Headers): [{}], (Payload): [{}]",
                        ((MessagingException) message.getPayload()).getFailedMessage().getHeaders(),
                        ((MessagingException) message.getPayload()).getFailedMessage().getPayload())).get();
    }

    @Bean(name = "jmsInboundChannel")
    public JmsMessageDrivenEndpoint jmsInboundChannel() {

    return Jms.messageDrivenChannelAdapter(routingCachingJmsConnectionFactory()).
            configureListenerContainer(
            defaultMessageListenerContainerJmsListenerContainerSpec ->
            defaultMessageListenerContainerJmsListenerContainerSpec
                    .destinationResolver(routingJmsDestinationResolver()).acceptMessagesWhileStopping(false)
                    .sessionTransacted(true).sessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE)
                    .concurrency(routingSourceJmsLowerUpperConcurrentThreadCount).concurrentConsumers(3).maxConcurrentConsumers(3))
            .errorChannel(listenerErrorChannel()).shutdownContainerOnStop(false)
            .destination(routingSourceJmsQueue).autoStartup(true)
            .get();
    }
...
}

日志:

15:28:20.839 [DefaultMessageListenerContainer-3] DEBUG o.s.j.l.DefaultMessageListenerContainer - Received message of type [class weblogic.jms.common.TextMessageImpl] from consumer [weblogic.jms.client.WLConsumerImpl@12af28a8] of session [Cached JMS Session: weblogic.jms.client.WLSessionImpl@4e918fd1]
15:28:20.841 [DefaultMessageListenerContainer-3] DEBUG o.s.i.j.ChannelPublishingJmsMessageListener - converted JMS Message [TextMessage[ID:<322457.1582057700831.0>, WWW]] to integration Message payload [WWW]
15:28:20.845 [DefaultMessageListenerContainer-3] DEBUG o.s.i.channel.DirectChannel - preSend on channel 'inFlow.channel#0', message: GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}]
15:28:20.846 [DefaultMessageListenerContainer-3] DEBUG o.s.i.router.HeaderValueRouter - headerValueRouter received message: GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}]
15:28:20.846 [DefaultMessageListenerContainer-3] DEBUG o.s.i.c.PublishSubscribeChannel - preSend on channel 'multiSubcriptionChannel', message: GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}]
15:28:20.848 [executor-1] DEBUG o.s.i.jms.JmsSendingMessageHandler - org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11 received message: GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}]
15:28:20.849 [DefaultMessageListenerContainer-3] DEBUG o.s.i.c.PublishSubscribeChannel - postSend (sent=true) on channel 'multiSubcriptionChannel', message: GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}]
15:28:20.850 [DefaultMessageListenerContainer-3] DEBUG o.s.i.channel.DirectChannel - postSend (sent=true) on channel 'inFlow.channel#0', message: GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}]
15:28:20.864 [executor-1] DEBUG o.s.jms.core.JmsTemplate - Executing callback on JMS Session: weblogic.jms.client.WLSessionImpl@24067d07
15:28:20.865 [executor-1] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc/NON_EXISTING_QUEUE]
15:28:20.903 [executor-1] DEBUG o.s.j.s.d.JndiDestinationResolver - Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc'
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
    at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
    at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
    at weblogic.jndi.internal.ServerNamingNode_1034_WLStub.lookup(Unknown Source)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:423)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:157)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:92)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:157)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:96)
    at org.springframework.jms.support.destination.JndiDestinationResolver.resolveDestinationName(JndiDestinationResolver.java:114)
    at org.springframework.jms.support.destination.JmsDestinationAccessor.resolveDestinationName(JmsDestinationAccessor.java:115)
    at org.springframework.jms.core.JmsTemplate.lambda$send$3(JmsTemplate.java:585)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:504)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:584)
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:691)
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:671)
    at org.springframework.integration.jms.JmsSendingMessageHandler.send(JmsSendingMessageHandler.java:219)
    at org.springframework.integration.jms.JmsSendingMessageHandler.handleMessageInternal(JmsSendingMessageHandler.java:184)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:176)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher.invokeHandler(BroadcastingDispatcher.java:224)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher.access$000(BroadcastingDispatcher.java:56)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher$1.run(BroadcastingDispatcher.java:204)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:57)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc'
    at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1180)
    at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:270)
    ...
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:523)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
15:28:20.909 [executor-1] DEBUG o.s.i.c.PublishSubscribeChannel - preSend on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]
15:28:20.915 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Retry: count=0
15:28:20.916 [executor-1] DEBUG o.s.i.r.ErrorMessageExceptionTypeRouter - errorHandlingFlow.router#0 received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]
15:28:20.917 [executor-1] DEBUG o.s.r.b.ExponentialBackOffPolicy - Sleeping for 5000
15:28:25.918 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Checking for rethrow: count=1
15:28:25.918 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Retry: count=1
15:28:25.919 [executor-1] DEBUG o.s.i.r.ErrorMessageExceptionTypeRouter - errorHandlingFlow.router#0 received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]
15:28:25.919 [executor-1] DEBUG o.s.r.b.ExponentialBackOffPolicy - Sleeping for 10000
15:28:35.919 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Checking for rethrow: count=2
15:28:35.919 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Retry: count=2
15:28:35.920 [executor-1] DEBUG o.s.i.r.ErrorMessageExceptionTypeRouter - errorHandlingFlow.router#0 received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]
15:28:35.920 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Checking for rethrow: count=3
15:28:35.920 [executor-1] DEBUG o.s.retry.support.RetryTemplate - Retry failed last attempt: count=3
15:28:35.921 [executor-1] DEBUG o.s.i.h.a.ErrorMessageSendingRecoverer - Sending ErrorMessage: failedMessage: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]
org.springframework.messaging.MessageDeliveryException: No channel resolved by router 'errorHandlingFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' and no 'defaultOutputChannel' defined.
    at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:198)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:169)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice$1.cloneAndExecute(AbstractRequestHandlerAdvice.java:93)
    at org.springframework.integration.handler.advice.RequestHandlerRetryAdvice.lambda$doInvoke$1(RequestHandlerRetryAdvice.java:82)
    at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287)
    at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:211)
    at org.springframework.integration.handler.advice.RequestHandlerRetryAdvice.doInvoke(RequestHandlerRetryAdvice.java:82)
    at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice.invoke(AbstractRequestHandlerAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy93.handleMessage(Unknown Source)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher.invokeHandler(BroadcastingDispatcher.java:224)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher.dispatch(BroadcastingDispatcher.java:180)
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:73)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:453)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47)
    at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109)
    at org.springframework.integration.channel.MessagePublishingErrorHandler.handleError(MessagePublishingErrorHandler.java:95)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:60)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
15:28:35.921 [executor-1] DEBUG o.s.i.c.PublishSubscribeChannel - preSend on channel 'exceptionQueueChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageDeliveryException: No channel resolved by router 'errorHandlingFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' and no 'defaultOutputChannel' defined., failedMessage=ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}], headers={id=7d86b3e2-287f-e867-af54-0bb6744c2853, timestamp=1582057715920}]
15:28:35.921 [executor-1] DEBUG o.s.i.jms.JmsSendingMessageHandler - org.springframework.integration.jms.JmsSendingMessageHandler@38b61501 received message: ErrorMessage [payload=org.springframework.messaging.MessageDeliveryException: No channel resolved by router 'errorHandlingFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' and no 'defaultOutputChannel' defined., failedMessage=ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}], headers={id=7d86b3e2-287f-e867-af54-0bb6744c2853, timestamp=1582057715920}]
15:28:35.923 [executor-1] DEBUG o.s.jms.core.JmsTemplate - Executing callback on JMS Session: weblogic.jms.client.WLSessionImpl@e0750f9
15:28:35.924 [executor-1] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc/JMSExceptionQueue]
15:28:35.926 [executor-1] DEBUG o.s.j.s.d.JndiDestinationResolver - Located object with JNDI name [jdbc/JMSExceptionQueue]
15:28:35.944 [executor-1] DEBUG o.s.jms.core.JmsTemplate - Sending created message: ObjectMessage[null,org.springframework.messaging.MessageDeliveryException: No channel resolved by router 'errorHandlingFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' and no 'defaultOutputChannel' defined., failedMessage=ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]]
15:28:35.955 [executor-1] DEBUG o.s.i.c.PublishSubscribeChannel - postSend (sent=true) on channel 'exceptionQueueChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageDeliveryException: No channel resolved by router 'errorHandlingFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' and no 'defaultOutputChannel' defined., failedMessage=ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}], headers={id=7d86b3e2-287f-e867-af54-0bb6744c2853, timestamp=1582057715920}]
15:28:35.955 [executor-1] DEBUG o.s.i.c.PublishSubscribeChannel - postSend (sent=true) on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jms.JmsSendingMessageHandler@f9d2b11]; nested exception is org.springframework.jms.support.destination.DestinationResolutionException: Destination [jdbc/NON_EXISTING_QUEUE] not found in JNDI; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.NON_EXISTING_QUEUE'. Resolved 'jdbc']; remaining name 'NON_EXISTING_QUEUE', failedMessage=GenericMessage [payload=WWW, headers={jms_redelivered=false, JMSXDeliveryCount=1, jms_destination=SystemModule!SourceQueue, jms_correlationId=77, id=ca2e8e8f-9b15-fbb2-4940-8b72c601c105, priority=4, jms_timestamp=1582057700831, jms_messageId=ID:<322457.1582057700831.0>, timestamp=1582057700845}], headers={id=7097a41a-6def-cff7-6b65-6ec42cf0ba26, timestamp=1582057700909}]

共有1个答案

龚奕
2023-03-14

就像日志处理程序中的一样:

@Bean
public IntegrationFlow listenerErrorHandlingFlow() {
    return IntegrationFlows.from(listenerErrorChannel())
            .handle(message -> log.error("LISTENER error (Headers): [{}], (Payload): [{}]",
                    ((MessagingException) message.getPayload()).getFailedMessage().getHeaders(),
                    ((MessagingException) message.getPayload()).getFailedMessage().getPayload())).get();
}

您需要向错误流添加转换器,通过从异常中提取失败消息来转换消息。

.transform("payload.failedMessage")
.handle(Jms...)
.get();
 类似资料:
  • 我正在尝试创建一条骆驼路线,它将: 从队列中获取JMS消息,消息体是SOAP请求 这是我的代码: endpoint配置: 我觉得我误解了这个场景中骆驼工作的一些基本原理。似乎是soap信封的存在导致了此问题。我曾假设camel能够获取原始soap消息并将其转换为cxfendpoint的正确消息格式。 有人能向我解释一下如何将SOAP请求传递给CXFendpoint吗?

  • 我设置了一个EJB项目,使用JMS将持久性实体对象发送到MDB。我使用JBoss EAP 7,使用Apache ActiveMQ作为消息传递提供程序。我像这样设置ConnectionFactory和队列: 这是我的消息生成器,它接收“Account”实体对象作为参数并将其发送到队列: EntityEnqueueBean。Java语言 MDB从队列接收消息并对其进行处理: java账户 不确定我做错

  • 我正在使用WSO2ESB4.7.0和ActiveMQ5.8.0。我希望将消息存储在队列中,为此我尝试使用这段代码,但它不工作。我创建了存储库,这将有助于存储消息,我的conumeing过程已经在JAVA代码中完成,所以我不必担心消费,如果我这样做了,我的消息将出现在acivemq UI中。我的配置如下所示 我试图通过代理传递消息,为此我编写了简单的代理服务 在这种情况下,我的队列没有在Active

  • 我正在使用AWS sdk开发基于SQS的队列pub-sub。 在非常基本的原型中,我将消息并发地推送到我已经创建的队列中。但是,如何才能确定我的消息正在被推送到队列中呢?

  • Artemis 2.2.0的新版本有一个,它显然是在内部消息ID(而不是JMS消息ID)上操作的。 问题是:如何在Artemis Version2.x中使用JMS消息ID将消息从一个队列移动到另一个队列?

  • 我们的环境由3个jboss服务器组成(门户、jms、协调)。 协调服务器托管骆驼路由,该路由具有消耗自队列(SLAQueue)的路由 JMS服务器托管了我们的所有队列 最近,我们发现了一个错误,即托管在JMS服务器上的TaskQueue中的一些消息没有传递到门户服务器上的MDB。由于某些原因,它们被卡住了,当我们重新启动JMS服务器时,卡住的消息被传递 为了进行调查,我们在“org.apache.