cpiotr / blog

Source code for blog entries
Apache License 2.0
7 stars 12 forks source link

Connecting to IBM MQ with Spring Boot and JMS #2

Open FrankenGit opened 7 years ago

FrankenGit commented 7 years ago

Piotr, sorry I am not a Spring-expert but we need to use Spring to connect to Websphere-MQ. How would you wire up the code and make it start from within Spring. A sample call would be nice! Thanks a lot for your help! Regards Frank

cpiotr commented 7 years ago

@FrankenGit, have you checked http://ciruk.pl/2015/04/connecting-to-ibm-mq-with-spring-boot-and-jms/ ?

FrankenGit commented 7 years ago

Piotr, yes, we have checked you page. That was our starting point. My problem is, that I am not a Spring Boot expert and what you describe as "piece of cake" is my problem. Spring boot itself comes with is a couple of MQ-sample (including activemq..) but unfortunately not with Websphere MQ. So if you could provide me with a 3 liner on how to instantiate spring boot using your Gateway-class it would be a great help. Thanks in advance!

FrankenGit commented 7 years ago

Piotr, we figured it out but couldn't get it running with the TransactionManagement enabled.

//@EnableTransactionManagement public class MQConfiguration { @Inject MQConfiguration.MQProperties properties;

//@Autowired
//PlatformTransactionManager transactionManager;

@Bean(name = "DefaultJmsListenerContainerFactory")
public DefaultJmsListenerContainerFactory provideJmsListenerContainerFactory() {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();          
    factory.setConnectionFactory(connectionFactory());
    //factory.setTransactionManager(transactionManager);
    factory.setConcurrency("5-10");
    factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
    factory.setSessionTransacted(true);
    return factory;
}