使用JNDI的Spring JMS配置

时间:2017-07-26 20:12:06

标签: java ibm-mq jndi spring-jms

我正在尝试使用JNDI将队列连接工厂配置加载到My应用程序中,当我们使用不受保护的队列管理器(IBM Websphere MQ)时,它可以正常工作。但是当我们更改为安全的队列管理器时,相同的JNDI查找不起作用。我在下面添加用于JNDI的逻辑。

public class EpsJmsConfig {

    @Bean
    public JndiObjectFactoryBean connectionFactoryBean() {
        JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
        bean.setJndiName("jms/NotificationCF");
        bean.setResourceRef(false);
        return bean;
    }

    @Bean
    public ConnectionFactory connectionFactory() {
        return (ConnectionFactory) connectionFactoryBean().getObject();
    }

    @Bean
    public JndiObjectFactoryBean epsXiBillPayNotificationDestinationBean() {
        JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
        bean.setJndiName("jms/epsXiBillPayNotificationQ");
        return bean;
    }

    @Bean
    public Destination epsXiBillPayNotificationDestination() {
        return (Destination) epsXiBillPayNotificationDestinationBean().getObject();
    }

    @Bean(name = "xiBillpayNotificationJmsTemplate")
    public JmsTemplate xiBillpayNotificationJmsTemplate() {
        JmsTemplate jmsTemplate = new JmsTemplate();
        jmsTemplate.setConnectionFactory(connectionFactory());
        jmsTemplate.setDefaultDestination(epsXiBillPayNotificationDestination());
        return jmsTemplate;
    }
}

0 个答案:

没有答案