1 year ago

#387379

test-img

Anand

Cause: Cannot determine reply destination: Request message does not contain reply-to destination, and no default reply destination set

Using JMSConfig i am creating MQ Connection factory and i have InboundGatewayConfig and OutboundGatewayConfig , in Inbound Config i am reading the Message payload from one queue and in Outbound config sending the message to another queue and my goad is toset reply channel to acknowledge the sender queue once queue receive the message.

InboundGatewayConfig:

@Configuration
@EnableIntegration
public class InboundGatewayConfig {

@Autowired
JmsConfig jmsConfig;

@Value("${fcb.inbound.receiver.queue.name}")
private String orderRequestDestination;

@Bean
public MessageChannel inboundOrderRequestChannel() {
    return new DirectChannel();
}

@Bean
public MessageChannel inboundOrderResponseChannel() {
    return new DirectChannel();
}

@Bean
@ServiceActivator(inputChannel = "inboundOrderRequestChannel")
public OrderService orderService() {
    return new OrderService();
}

@Bean
public JmsInboundGateway jmsInboundGateway() {
    JmsInboundGateway gateway = new JmsInboundGateway(
            defaultMessageListenerContainer(),
            channelPublishingJmsMessageListener());
    gateway.setRequestChannel(inboundOrderRequestChannel());

    return gateway;
}


@Bean
public DefaultMessageListenerContainer defaultMessageListenerContainer() {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(jmsConfig.fcbCachingConnectionFactory());
    container.setDestinationName(orderRequestDestination);
    container.setRecoveryInterval(5000);
    container.setErrorHandler(t -> System.out.println("Error in JMS Configurations  \t" + t.getCause()));
    return container;
}

@Bean
public ChannelPublishingJmsMessageListener channelPublishingJmsMessageListener() {
    ChannelPublishingJmsMessageListener channelPublishingJmsMessageListener = new ChannelPublishingJmsMessageListener();
    channelPublishingJmsMessageListener.setExpectReply(true);

    return channelPublishingJmsMessageListener;
}
}

OutboundGatewayConfig :

   @Configuration
    public class OutboundGatewayConfig {

 @Value("${fcb.inbound.receiver.queue.name}")
  private String orderRequestDestination;

   @Value("${fcb.inbound.response.queue.name}")
   private String orderResponseDestination;

   @Autowired
   JmsConfig jmsConfig;

   @Bean
   public MessageChannel outboundOrderRequestChannel() {
    return new DirectChannel();
  }

  @Bean
  public MessageChannel outboundOrderResponseChannel() {
  return new QueueChannel();
  }

  @Bean
  @ServiceActivator(inputChannel = "outboundOrderRequestChannel")
  public JmsOutboundGateway jmsOutboundGateway() {
  JmsOutboundGateway gateway = new JmsOutboundGateway();
   gateway.setConnectionFactory(jmsConfig.fcbCachingConnectionFactory());
   gateway.setRequestDestinationName(orderRequestDestination);
   gateway.setReplyDestinationName(orderResponseDestination);
   gateway.setReplyChannel(outboundOrderResponseChannel());

   return gateway;
   }
  }

and this my service class

    public class OrderService {

     private static final Logger LOGGER =
          LoggerFactory.getLogger(OrderService.class);

         public Message<?> order(Message<?> order) {
         LOGGER.info("received order='{}'", order);

         Message<?> status = MessageBuilder.withPayload("Accepted")
         .setHeader("jms_correlationId",
          order.getHeaders().get("jms_messageId"))
         .setReplyChannelName("inboundOrderResponseChannel").build();
          LOGGER.info("sending status='{}'", status);

          return status;
        }
       }

While running the application InboundGateway able to receive the message payload from request queue but while reply , giving bellow warning message.

2022-04-07 16:06:24.303 WARN 19408 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer : Setup of JMS message listener invoker failed for destination 'xxx.yyy.queue' - trying to recover. Cause: Cannot determine reply destination: Request message does not contain reply-to destination, and no default reply destination set.

java

spring

spring-boot

spring-integration

0 Answers

Your Answer

Accepted video resources